• info@happli.be

Tag Archive phonegap

Phonegap – Local Notifications plugin

If you ever need to display notifications to the users of your mobile app, you’ll need a plugin. The one I’ve used is Local notifications (https://github.com/katzer/cordova-plugin-local-notifications). So far, I’m satisfied with it. The picture below illustrates the notification appearing in the notification center (iOS).


The following screenshot show it when it’s received.


Don’t be surprised if you don’t see the notifications you schedule when the app is in foreground. It depends on the platform used. Under iOs it’s “by design”. See https://github.com/katzer/cordova-plugin-local-notifications/issues/625 for more information.

You can use a simple trick to make sure your users will be notified, regardless they’re in your app (in foreground) or not (in background). This SO post explains it all: http://stackoverflow.com/questions/29606012/how-to-check-app-running-in-foreground-or-background-in-ionic-cordova-phonegap. Basically, it all comes down to declaring a boolean variable (e.g. isInForeground) and changing its state in the “pause” and “resume” event handlers.

Tested and approved 🙂