Pubnub Push Notification not working for cross platform mobile app

守給你的承諾、 提交于 2019-12-04 12:59:17
sumit

I had also raised a support request regarding this on Pubnub's support. After some nice replies from guys at Pubnub, we were able to resolve it.

We were mislead by this documentation, and we were using

"pn_gcm": {
  "data": {
      "title_for_mobile": "Test",
      "summary_for_mobile": [ "Hi" ]
   }
}

Instead, we should have used.

{
  "message": "This is some text",
  "pn_gcm": { 
     "data": {
         "title": "Demo wpush", 
         "message":"This is a pushnotification"
     }
   },
   "pn_debug": "true"
} 

Because Cordova PushPlugin is expecting message key from GCM.

// GCMIntentService.java
@Override
protected void onMessage(Context context, Intent intent) {
    //.... some code ...
    if (extras.getString("message") != null && extras.getString("message").length() != 0) {
          createNotification(context, extras);
    }
    //... some code ...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!