任何人都知道如何在前景中显示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",
};
这是iOS上的默认行为。
您需要使用此本机方法。
有很多stackoverflow示例,例如这个
可悲的是缺乏声誉意味着我无法发表评论。