【问题标题】:PubNub chat iOS app doesn't receive Push notification msgPubNub 聊天 iOS 应用程序未收到推送通知消息
【发布时间】:2018-04-16 14:22:39
【问题描述】:

我使用 PubNub 服务在我的应用程序中聊天,现在它可以正常工作了,用于:订阅频道、将消息发布到频道、接收消息... 但是,当一个用户将消息发送到用户订阅的频道时,我不想收到推送通知消息。 我在 PubNub 管理员中配置了 APNS 证书

我测试了我的 PEM 文件的 Push 服务关注 link

推送消息来了。 我将我的设备令牌添加到我订阅的频道中

[self addPushNotificationsOnChannels:@[@"channel1", @"channel2"] withDevicePushToken:self.deviceToken andCompletion:^(PNAcknowledgmentStatus * _Nonnull status) {
    if (!status.error) {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Token Chat" message:status.errorData.information delegate:@"Sent token OK" cancelButtonTitle:@"Close" otherButtonTitles:nil];
        [alert show];

    }
    else {

        UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Token error" message:status.errorData.information delegate:nil cancelButtonTitle:@"Close" otherButtonTitles:nil];
        [alert show];
    }
}];

然后,我再次检查了已添加 deviceToken 的列表频道,列表频道匹配。 但是当我尝试从聊天(从用户到用户,从用户到频道)发送(发布)消息时,我的设备没有收到任何推送消息。

我可能错过了一些步骤或什么?请指教!

【问题讨论】:

  • 您是否尝试过使用 pndebug 通道查看是否有任何错误消息? Please review this mobile push troubleshooting section 如果您从 -pndebug 频道收到任何有用的消息,请告诉我们。
  • @CraigConover 是的,我在 -pndebug 上测试过,消息来了,但是当我在频道上与用户聊天时,消息没有来

标签: apple-push-notifications pubnub apn


【解决方案1】:

PubNub 移动推送通知格式

正如在私人支持线程中所讨论的,您的留言:

{"data":{"time":1523961017642,"text":"Hello"},"event":"dev-ecteam","sender":"DOAN-dev-ecteam"}

...不包括pn_apns。为了让 PubNub 知道您想通过 APNS 将其作为推送通知发送,您必须在 pn_apns 中包含消息,并且 APNS 需要 aps 密钥(Android 需要 data 密钥)。

{
  "pn_gcm": {
   "data": {
    "time": 1523961017642,
    "text": "Hello"
   },
   "event": "dev-ecteam",
   "sender": "DOAN-dev-ecteam"
  },
  "pn_apns": {
   "aps": {
    "time": 1523961017642,
    "text": "Hello"
   },
   "event": "dev-ecteam",
   "sender": "DOAN-dev-ecteam"
  }
}

所有主动订阅的订阅者都会收到整条消息,但只有pn_gcm的内容会被Android设备接收,pn_apns的内容会被在频道上注册推送通知的iOS设备接收.

有关 PubNub 移动推送通知的更多信息,请参阅:

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-08-22
    • 2020-12-22
    • 1970-01-01
    • 1970-01-01
    • 2018-08-15
    • 2018-11-14
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多