-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Can I access Web API's from 'notification' handler? #335
Comments
Background notifications will not trigger a full reload of the application, so you won't have a new |
@fredgalvao Thanks for the response I didn't know that, when you say not a full reload..., do I have access to Web API's or plugins?, can I silently launch my app if I can't?, basically what I try to understand is how can I save data received from background notification, I tried to use localStorage/IndexDB/IndexDB plugin, all of them fail to save the data, I'm sure there is a standard(or at least correct) way to do so, I'm new to cordova but I'd be glad if you know a way to save those background notification data. |
@macdonst I retested, and I can say for 100% that the callback is not called at all when the app is at the background, I click the notification, the deviceready event fires, but there is no call at all to the notification handler, I'm using Parse to send push notifications(my android version is 4.4.4), the properties object that sends the notification via parse contains |
So, let me try to clarify. ( @macdonst explained all the scenarios pretty well in here) When you say "background notifications", I expect you refer to the following scenario:
At that point when you receive a notification with either a
And if you click it, the plugin will:
In no point in any of these steps, did your app get the need to reload, or reopen, because it was already so. Now,when you say that when you click on the notification, your app opens and the In that case, this plugin doesn't support cold start notifications on android yet, but it's pretty much on the way to being implemented afaik. |
@fredgalvao You are perfectly right, thank you so much for that clarification, I knew about pause event but most times I click the back button and the app is always on the "just used" apps list so ;), anyway I will be looking forward for that cold start, it can really help, thanks again and have a nice day. |
You're welcome! |
This thread has been automatically locked. |
Hello everyone, I just started using this great plugin, on the notification handler I check to see if it's a foreground notification and if so I alert the notification data, if not I use IndexDB+shim to save the data, when the application starts it looks like the data was never saved by IndexDB, I had the same problem with using localStorage so I'm doing something wrong, should I listen to specific event inside the notification handler and only then use a web API?
To make myself clear, I alert() the saved(supposedly) data immediately after the deviceready event(I assume that at the moment the notification is received the notification handler is called and my data is saved), I've learned somewhere that only when the notification is clicked only then the handler is called but I'm pretty confused, I assume that there is a problem to access Web API's when background notification is received, I don't know if I should use a IndexDB plugin or I should alert the saved data after another event then deviceready, have a nice day.
The text was updated successfully, but these errors were encountered: