首页 > 解决方案 > 推送通知在前台 IOS 中不起作用

问题描述

当应用程序处于后台时,推送通知工作得非常好,主要问题出现在应用程序处于前台时。我能够接收有效负载,但通知未显示在通知横幅中

下面收到的有效载荷

{"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);
}

标签: objective-cfirebasereact-nativefirebase-cloud-messaging

解决方案


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


推荐阅读