任何人都知道如何在前台显示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",
};