任何人都知道如何在前台显示 iOS 通知(当应用程序打开时)。我正在使用 react-native-fcm。一切正常,android 通知也显示在前台,但不在 iOS 中。
我已经按照文档中的所有内容进行了操作。下面的 didReceiveRemoteNotification 方法也会被调用。在 FCM.On() 监听器通知数据也是可见的。但是,当 iOS 应用程序打开时,只有通知不会显示在横幅中。
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
[RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}
使用的有效载荷如下:
to = deviceId,
badge = 0,
notification = new
{
title = "test",
body = "body",
sound = "default",
priority = "high",
badge = 0,
show_in_foreground = true,
},
data = new
{
badge = 0,
title = "title",
body = "body",
sound = "default",
fcmMessageType = notifType,
show_in_foreground = true,
},
content_available = true,
priority = "high",
};