推送通知在前台IOS中不起作用

时间:2020-06-06 16:17:47

标签: objective-c firebase react-native firebase-cloud-messaging

当应用程序在后台运行时,推送通知运行良好,主要问题出现在应用程序在前台运行时。我能够接收有效载荷,但是通知未显示在通知横幅中

下面收到的有效载荷

{"data": {"fcm_options": {"image": "https://importduniya.com/dealer/particular/TrustyCane.jpg"}}, "messageId": "1591459535622805", "mutableContent": true, "notification": {"body": "Test123", "ios": {}, "title": "Test"}, "sentTime": "1591459535"}

我认为当应用程序处于前台状态时,不会调用以下功能

//Called when a notification is delivered to a foreground app.
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
  NSLog(@"will-present");
  completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
}

1 个答案:

答案 0 :(得分:0)

您还应该实现 application:didReceiveRemoteNotification:fetchCompletionHandler:

相关问题