I have a cordova app (codova (3.4.0) running on iOS and soon also on Android. Push notifications are implemented and working. I'm having troubles detecting when the app was started through a push notification and redirecting the application to the right page.
Note: This doesn't concern starting the app from a push notification when the app is running in the background. Only when the app is completely closed!
I now have the following workflow:
Regular startup:
- Wait for cordova.js to fire the ondeviceready event.
- In the ondeviceready event redirect to the startup view of my app ( via window.location.hash)
Cold app startup from push notification:
- Wait for cordova.js to fire the ondeviceready event.
- In the ondeviceready event redirect to the startup view of my app (via window.location.hash)
- Plugin kicks in and triggers a javascript function in my app called notificationreceived
- In notificationreceived function redirect to a view based on the push notification
As you can see the cold app startup scenario going to the startup view, which is unnecessary and causes the user to wait for the first view to load, only to be redirected again.
The problem is that when deviceready fires, my javascript code isn't aware of the coming push notification yet, so i'm looking for a way around this.
Is there a way to maybe pass extra parameters to the deviceready cordova event? Or does anybody have another idea or solution to tackle this problem?