0

I am stumped here. A Phonegap/Mobile Dev newbie here. Looking for some advice.

I have a phonegap app(with push plugin) developed for both Android and iOS. I was trying to test push notifications on Android. I have the following flow

  1. Device registers with GCM(or APNS) and sends the token back to server.
  2. On Server side I determine the identity of the user and create a channel for them on PubNub.
  3. Server registers the device with PubNub along with the channels.
  4. I can verify that the device has been subscribed to a few channels.
  5. I send a message from server side.
  6. I see it in the PubNub console.
  7. But no notification on Android.

When I try to use one of the free services(found some php code on fiddle) available to try sending messages to the device, it works. I see notifications on the device.

I tried sending messages directly from the PubNub console with no luck.

{
"pn_apns": {
    "aps" : {
        "alert": "Game update 49ers touchdown",
        "badge": 2
    },
    "teams" : ["49ers", "raiders"],
    "score" : [7, 0]
},
"pn_gcm": {
    "data" : {
        "summary": "Game update 49ers touchdown",
        "teams" : ["49ers", "raiders"],
        "score" : [7, 0],
        "lastplay" : "5yd run up the middle"
    }
},
"full_game" : {
    "date" : "2014.05.20",
    "background" : "Data that is not pertinent to devices"
},"pn_debug": true
}

Note 1 - I have already added the GCM API key on PubNub. Note 2 - I am using the free tier

So, I figured, maybe something wrong with PubNub and I move to Parse.

I create channels, register device and send messages all via curl(REST). I see push notifications on parse dashboard but still no messages on the device.

I haven't tested on iOS yet(working on some other iOS related issues).

I have followed the tutorials to the line for both PubNub and Parse. At this point, I am wondering if the device themselves need to subscribe to PubNub/Parse and a backend service cannot be used to subscribe them.

Please help.

Shashi
  • 91
  • 7
  • Have you seen this article: http://www.pubnub.com/blog/sending-android-push-notifications-via-gcm-javascript-using-phonegap/ – Craig Conover Mar 12 '15 at 16:07
  • I did. Do you see any flaw in my approach. Here is my understanding: The main job of the app is register with GCM/APNS and send back the token - this works. The rest of the flow does't involve the app directly. Its all to do with integration between the backend server, PubNub and GCM/APNS. I tried testing with the PubNub console and I couldn't get it to work. – Shashi Mar 12 '15 at 16:53
  • I just read this part again > I am wondering if the device themselves need to subscribe to PubNub/Parse and a backend service cannot be used to subscribe them. I believe you need to register the device for push on channels from the device. Use the REST calls to do so. Let me know if that is helpful. – Craig Conover Mar 12 '15 at 21:59
  • I did register the device but not directly from the device. I send the device token to a backend service. The backend connects to PubNub via REST and registers the device on its behalf and subscribes to a few channels. It boils down to this. Does it have to be the device itself that needs to register or can any backend service register a device on its behalf? – Shashi Mar 12 '15 at 23:00
  • I don't think it does but can you give it a try just to see if it is consistent for your. – Craig Conover Mar 13 '15 at 03:08
  • You can definitely register for push on PubNub channels on your server on behalf of the devices as long as you provide the proper data. I do know that Android has changed the way you register for GCM (registration id as opposed to device id and there is a sender id involved - I'm not expert on that part though). But you can definitely use the PubNub mobile REST APIs for to do the add/remove devices to/from channels for GCM/APNS/MPNS. Send details to support@pubnub.com if you still need further assistance. Cheers. – Craig Conover Aug 31 '15 at 20:10

0 Answers0