1

Anyone knows how to display iOS notification in foreground(when app is open). I'm using react-native-fcm. Everything works fine the android notification also shows in foreground but not in iOS.

I've followed everything in the documentation. The following didReceiveRemoteNotification method also gets called. On FCM.On() listener notification data is also visible. But only notification do not shows in banner while iOS app is open.

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(nonnull NSDictionary *)userInfo fetchCompletionHandler:(nonnull void (^)(UIBackgroundFetchResult))completionHandler{
  [RNFIRMessaging didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
}

The payload used is following:

 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",
            };
devedv
  • 562
  • 2
  • 15
  • 45

1 Answers1

0

This is the default behaviour on iOS.

You will need to use this native method.

There's plenty of StackOverflow examples, like this one

Sadly a lack of reputation meant I couldn't comment.

Dan
  • 779
  • 2
  • 8
  • 16