1

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

1 回答 1

0

这是 iOS 上的默认行为。

您将需要使用本地方法。

有很多 StackOverflow 示例,比如这个

可悲的是,缺乏声誉意味着我无法发表评论。

于 2018-04-25T11:17:52.097 回答