简体   繁体   English

未从通知托盘中获取捆绑包中的 Pubnub 有效负载。 当应用程序被杀死时

[英]Not getting Pubnub payload in bundle from Notification tray. When app is killed

I have integrated pubnub API in one of my project.我在我的一个项目中集成了 pubnub API。 I am trying to get bundle of data that i have sent in payload.我正在尝试获取我在有效负载中发送的数据包。 I have added FCM for push notification.我为推送通知添加了 FCM。 I am getting push notification in all cases but not getting bundle data when app is killed or in background.我在所有情况下都收到推送通知,但在应用程序被杀死或在后台时没有收到捆绑数据。 Already getting payload object when app is in foreground but not getting any data when app is in background or killed.当应用程序处于前台时已经获得有效负载 object 但在应用程序处于后台或被杀死时未获取任何数据。

Payload 1:有效载荷 1:

{
   "pn_gcm": {
   "notification": {
   "title": "Barack Obama",
   "body": "12",
   "channelName": "Hell 4_656"
   }
 },
"firstName": "Barack",
"lastName": "Obama",
"displayName": "Barack Obama",
"profileImageUrl": "abcURL",
"userId": "173",
"type": "sender",
"time": "1615958943297",
"message": "12"
}

PayLoad 2:有效载荷 2:

{
pn_gcm={
  notification={
  title=BarackObama,
  body=Hello,
  image=Hell4_656
  }
  },
  firstName=Barack,
  lastName=Obama,
  displayName=BarackObama,
  time=1615958740553,
  type=sender,
  message=Hello,
  profileImageUrl=abcURL,
  userId=173
}

I am getting notification object when app is in foreground but not getting any of them when app is in background or killed.(Getting some FCM default object)当应用程序在前台时,我收到通知 object 但在应用程序在后台或被杀死时没有收到任何通知。(获取一些 FCM 默认对象)

I am trying to get notification object in bundle when launch app from Notification tray从通知托盘启动应用程序时,我试图在捆绑包中收到通知 object

Answer Made JSON payload like this:答案使 JSON 有效载荷如下:

  {
"pn_gcm": {
  "notification": {
    "title": "Barack Obama",
    "body": "18"
  },
  "body": {
    "channelName": "Hell 5_657",
    "firstName": "Barack",
    "lastName": "Obama",
    "displayName": "Barack Obama",
    "profileImageUrl": 
    "http://3.137.127.137/quiqle/uploads/profile/1615523786_4866.jpg",
    "userId": "173",
    "type": "sender",
    "time": "1615965488916",
    "message": "18"
  }
}
}

You need to add data with information which you want to receive with push into pn_gcm .您需要将data与您希望通过 push 接收的信息一起添加到pn_gcm中。 Information outside of pn_(gcm|apns) (including tjpse) will be delivered as regular messages pn_(gcm|apns)之外的信息(包括 tjpse)将作为常规消息传递

Message can be as follows:消息可以如下:

using notification :使用notification

{
   "pn_gcm":{
      "notification":{
         "title":"Chat invitation",
         "body":"John invited you to chat",
         "sound":"default"
      }
   }
}

Or using data :或使用data

{
  "pn_gcm" : {
    "data" : {
      "room" : "Portugal vs Denmark",
      "body" : "great match!"
    }
  }
}

or both:或两者:

{
  "pn_gcm" : {
    "notification": {
      "title":"Portugal vs Denmark",
      "body":"great match!"
    },
    "data" : {
      "room" : "Portugal vs Denmark",
      "body" : "great match!"
    }
  }
}

For an explanation on the different between data and notification , please read the official FCM docs, About FCM messages .关于datanotification的区别,请阅读 FCM 官方文档, 关于 FCM 消息

See also: Why are my FCM push notifications not working?另请参阅: 为什么我的 FCM 推送通知不起作用?

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从系统托盘读取推送通知数据。 - How to read the push Notification data from system tray.? 当应用程序从Ionic 2中的应用程序托盘中被杀死时,如何继续接收GCM通知 - how to continue to receive GCM notification when app killed from app tray in Ionic 2 在Android上杀死应用时收到系统托盘通知 - Receive system tray notification when app killed on Android 设备系统托盘中带有有效负载的FCM通知未传递给App - FCM Notification with payload in device's system tray not getting passed to App 当 android 应用程序处于终止状态时,如何从推送通知(使用 FCM)中获取“数据有效负载”? - How can I get “data payload” from push notification (using FCM) when android app is in killed state? 当从联想等某些设备上的多任务托盘中杀死应用程序时,Android应用程序未收到Firebase推送通知 - Android app not receiving Firebase Push Notification when application is killed from multi-task tray on some devices like lenovo 应用程序完全终止时未收到 FCM 通知 - Not getting FCM notification when app is completely killed 应用被杀死时接收PubNub推送通知 - Receive PubNub Push Notifications when app is killed 单击电源按钮后,即使从最近的应用程序托盘中删除了该应用程序,也要重新启动该应用程序 - Restarting the app when power button is clicked even after the app is killed from recent application tray 应用程序被杀死时没有收到通知 - Not receiving notification when the app is killed
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM