I got cold start notifications working! #410
Hey guys, according to the plugin instructions, onclick will not work from a cold start. However I managed to get it working. Works on Android 4.4.2, havent tried on iOS or other android versions but in theory it should work.
The idea is based on an observation that the callback for window.plugin.notification.local.onclick does get called on cold start but cant do many things. For example if you put "alert" on the callback it crashes the app on cold start, and many things like page navigation wont work either, making it appear as if onclick is not called, but it is (otherwise "alert" wouldnt be crashing the app when added to the callback).
So, I figured I could launch an activity from onclick to open a custom url-scheme that opens my app.
/* define this as a global function */
/* handleOpenURL will navigate to the custom url received */
//add a notification somewhere:
//helper to open url as activity
so far its working great. Let me know if you find issues with other android or iOS versions. cheers!
The text was updated successfully, but these errors were encountered:
FYI anyone interested reply here and I will post a more complete example. I had to make a few changes to make it work on android 4.0 and also on slow emulators. Not much more complicated than what I put above. I not have cold- start notifications that launch the app and execute the action, from 4.0 and above (and should work from 3.0 but I dont have a way to try it).