Polarsbear Polarsbear - 15 days ago 8
AngularJS Question

Cordova Local notifications plugin not working after a while

I'm working on my 2nd app and having some problems implementing notifications.
It works when app in the foreground, and about 5 min after I put it to the background, even when the app is closed.

So the app listens for a firebase change and then launches;
cordova.plugins.notification.local.schedule

If the app doesn't respond after a while, I open it and it gives me the notifications

I used cordova.plugins.backgroundMode.enable(); to make the app run in the background, but no luck.

Any ideas or is there a better way to push notifications to your app?

Answer

For everybody still searching, You have to capsulate the code in a device.ready(), if not you'll run into this bug