2
votes

I have been trying to send push notifications to a Phonegap app deployed on iOS and Android. iOS works fine, but Android doesn't work when I send push notifications from any of the dev consoles from PubNub, Parse and Amazon SNS.

I did verify that I can send notifications if I use the GCM API, so I am using the correct Sender ID, API key and the device token.

I don't see any errors on PubNub console. On Parse dashboard I see that the push notifications have been sent. No error on Amazon SNS. Yet, no push notifications on the device.

I am out of ideas. Thanks in advance for any helpful advice.

4
To start, I would analyze the adb logcat output when its working, and when you try from a 3rd party... see if there are any glarying differences or log warning/errors... - Geremy
Hi Geremy. Pardon my ignorance about Android(been using it for just 2 weeks now). I installed a terminal app on the device. I also installed aLogcat. I don't see any logs when I send notifications in both the situations. I did notice an error when I installed catlog, that it did not have root access. Any ideas how to go from here? - Shashi
I don't use Parse/PubNub/SNS, but in using only GCM, your server should receive a response code for every message it sends to your devices. It could give hints as to what errors have occurred. - Koh
Koh, Using GCM works just fine, but for my use case PubNub and Parse would add significant value, and Parse/PubNub send a success response. - Shashi
I see. You could also check your Google Developers Console for any statistics that could be helpful: On your project page, go to APIs & auth -> APIs -> Usage. - Koh

4 Answers

2
votes

With help from PubNub, figured out what the issue was. The sample on PubNub has the following format

{"pn_gcm": {
    "data" : {
        "GCMSays" : "hi" }
    }
}

But the required format was

{"pn_gcm": {
        "data" : {
            "message" : "hi" }
        }
 }

After confirming using PubNub console, I updated my JSON object in the code and it all worked like a charm.

With Parse console, I tried to create a JSON object with similar format, but it didn't work. Haven't tried Amazon SNS.

0
votes

This tutorial illustrates how to configure Android GCM with PubNub: http://www.pubnub.com/docs/java/android/tutorial/google-push-notification.html

0
votes

[Parse developer] Parse doesn't provide 1st party support for PhoneGap; their product just works with the JS SDK, which doesn't have native Push support. I describe what is necessary to get Parse to recognize your device for push in an arbitrary language in a previous question. You may however be receiving the push but not creating a notification.

In Android (unlike iOS, WinRT, or WinPhone), push doesn't necessarily imply "notification." The native android SDK from Parse creates this automatically for you. You'll need to create your own BroadcastReceiver and wire it to handle the intents that the Play Store app is sending for pushes. You can find these in our Android Push Tutorial. In your BroadcastReceiver, you'll want to create and register your own Notification object when receiving a push.

0
votes

For Firebase Cloud Messaging, I had to use this structure to receive a tray notification:

"pn_gcm": {
    "notification": {
        "title": push_title,
        "text": push_message
    }
},