在Firebase中没有调用didReceiveRemoteNotification?

时间:2017-09-27 12:06:06

标签: ios objective-c firebase firebase-cloud-messaging

我在Objective-C项目中添加了firebase。集成成功,但我无法在iPhone的通知栏中显示通知。

当通知到达时,调用此方法并在那里获取数据..

- (void)messaging:(FIRMessaging *)messaging didReceiveMessage:(FIRMessagingRemoteMessage *)remoteMessage {

    NSLog(@"FCM Received data message: >> %@", [remoteMessage appData]);


 }

但这种方法并没有打电话......

  - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
    fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {


    }

1 个答案:

答案 0 :(得分:1)

您确定您的有效负载包含notification这样的密钥

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

您的有效负载notification方法中没有didRecieveRemoteNotification密钥将不会触发。

检查这些以获取更多信息1 2