Cordova PushNotification callback not invoked when in background mode


#1

Hi guys,

i’m double posting this form https://github.com/raix/push/issues/42

I’m using this package to send push notifications but i think i’ve bumped in an issue with the Cordova PushNotification .

I paste my message here :

I’m moving some steps forward with this package : now i’m able to correctly send push notification to an android device, when my app is in foreground everything works fine and the following listener is called

Push.addListener('message', function (notification) {
        console.log(JSON.stringify(notification));
        Dialogs.alert(notification.message, function(){}, notification.payload.title, 'OK');
    });

Dialogs is a meteor package :

hybrid:dialogs 1.0.3 Cross-platform dialogs: alerts, confirms, and prompts (Cordova).

Unfortunatly when my app is in background i still receive the notification on the status bar but when i tap on it and my app pops in foreground the above callback is not called.

I did some googling and found this interesting post

extracting the best suggestions from there i tried:

[…] I had to clear the dalvik cache and restart my phone. Happened to me twice so far. Seems to a known issue in android, phonegap-build/PushPlugin#35.

[…] I had a similar issue with Cordova 3.5.0 and PushPlugin 2.2.0: notifications worked when the app was in the foreground but not when it was in the background or not running. I found the solution by reading the source code of PushPlugin (file src/com/plugin/gcm/GCMIntentService.java): the notification’s payload must include “message” and “msgcnt” keys.

but none seems working for me.

Do you have the same issue? Do you know a viable solution for this?

Thanks as usual!


#2

The package’s author gave me the answer, was really simple indeed.