【问题标题】:FCM Push notificationFCM 推送通知
【发布时间】:2017-05-22 09:37:41
【问题描述】:

我正在研究 FCM,但只有以下方法被调用。

- (void)applicationReceivedRemoteMessage:(FIRMessagingRemoteMessage *)remoteMessage {
    // Print full message
    NSLog(@"This is the message whole structure%@", remoteMessage.appData);
    NSLocalizedString(@"This is remote message%@", remoteMessage);
    NSString * msg = [remoteMessage.appData objectForKey:@"message"];
    NSLog(@"msg %@",msg);
    [self alertStatus:msg:@"Alert"];
}

我仅通过上述方法从服务器收到完整消息。但是没有任何推送通知方法被调用。我没有收到任何推送通知,所以我无法在后台接收通知。

【问题讨论】:

    标签: ios objective-c


    【解决方案1】:

    要求您的后端服务器开发人员像这样在您的有效负载中添加notification 密钥

    {
        "to" : " ...",
        "notification" : {
          "body" : "great match!",
          "title" : "Portugal vs. Denmark",
          "icon" : "myicon"
        },
        "data" : {
          "Nick" : "Mario",
          "Room" : "PortugalVSDenmark"
        }
      }
    

    如果你想为用户显示通知,你应该在你的有效载荷中使用notification 键。

    Reference 1

    Reference 2

    【讨论】:

    • 你确定这是后端问题吗?因为即使 didRecieveRemoteNotification 方法也没有被调用。
    • 是的,如果 playload 中没有“通知”键,该方法将不会调用。因为那不是通知。
    猜你喜欢
    • 2017-12-09
    • 2020-04-21
    • 2020-09-17
    • 1970-01-01
    • 2022-08-22
    • 2018-06-24
    • 2017-01-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多