문제

I can't get notifications to be received in the background and appear in the notification tray using PhoneGap Build and PushPlugin. I'm using Cordova 3.3 and the latest version of PushPlugin.

Things work fine when the app is open. I receive payloads and can respond accordingly.

Nothing appears when the app is closed or running in the background. I would expect an alert in the notification tray at the very least, but I get none.

How can I troubleshoot what is going on here? I know I have the plugin usage basically correct, because it works fine when the app is in the foreground.

도움이 되었습니까?

해결책 2

The way i solved this for iOS.

pushplugin in the app will resolve and process a message like this:

{"alert":"Hello from APNs Tester.","badge":"1"}

iOS however will only process a message with the correct structure

{"aps":{"alert":"Hello from APNs Tester.","badge":"1"}}

다른 팁

For Android:

Because this code section in the plugin, that appear at "GCMIntentService.java" near line 80:

// Send a notification if there is a message
if (extras.getString("message") != null && extras.getString("message").length() != 0) {
    createNotification(context, extras);
}

to be able to receive background notification using GCM, the message structure that comes from the server should look like this:

{"message":"Hello World", "title":"Title", "msgcnt":1, "soundname":"sound.mp3"}

And must have the "message" attribute!

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top