Using this plugin in an Ionic project I have been able to get local notifications going when a GCM push arrives (using ngCordova and the appropriate plugin).
The code flows a little something like this:
Inside the scope of an abstract app controller the pushNotification is set-up with an ecb that references a global onNotification
function (outside of angular scope all together) there a localNotification is added.
Inside the angular scope an onclick handler is declared to lead the user to the right view.
The problem is that when the app is not in foreground, the following unwanted behaviours can be observed:
- The title of the notification is not displayed (even when hardcoded)
- The desired sound does not play (the device only vibrates)
- When the app comes to foreground, the onclick notification is not fired.
My notification code looks like this:
window.plugin.notification.local.add({
message: e.payload.message,
title: e.payload.activity.name,
sound: 'android.resource://' + package_name + '/raw/bounce',
json: JSON.stringify(e.payload),
autoCancel: true,
});
Any clues as to what is going on?
FIXED: As it turns out, the event callback is never called when the app is in the background and the push notification is turned into a local notifaction - a feature I had overlooked. Thank you all for your time and trouble :/