[Push notifications] Intercom AppDelegate hook conflict with FCM configuration

Hi guys,

I’m trying to setup Intercom notifications for iOS in my React Native app, so I’m following this guide.
I already have a notifications setup for FCM using react-native-firebase.

My issue occurs after adding the following method in my AppDelegate:

- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    [Intercom setDeviceToken:deviceToken];

The problem I’m facing is that after adding this, I’m no longer notified of my FCM notifications on first app launch. When killing the app and reopening it, everything works fine.

I know this is a very specific issue and might be related to FCM rather than Intercom, but if anybody has a hint of what’s happening here it would help me a great deal !

Below is the content of my AppDelegate.m file:

#import "AppDelegate.h"

#import <React/RCTBridge.h>
#import <React/RCTBundleURLProvider.h>
#import <React/RCTRootView.h>
#import <Firebase.h>
#import "RNFirebaseNotifications.h"
#import "RNFirebaseMessaging.h"
#import "Orientation.h"
#import "Intercom/intercom.h"

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  NSString *intercomAppId = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"INTERCOM_APP_ID"];
  NSString *intercomApiKey = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"INTERCOM_API_KEY"];

  [Intercom setApiKey:intercomApiKey forAppId:intercomAppId];

  [FIRApp configure];
  [RNFirebaseNotifications configure];

  RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
  RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge

  rootView.backgroundColor = [[UIColor alloc] initWithRed:1.0f green:1.0f blue:1.0f alpha:1];

  self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
  UIViewController *rootViewController = [UIViewController new];
  rootViewController.view = rootView;
  self.window.rootViewController = rootViewController;
  [self.window makeKeyAndVisible];
  return YES;

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification {
  [[RNFirebaseNotifications instance] didReceiveLocalNotification:notification];

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

- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {
  [[RNFirebaseMessaging instance] didRegisterUserNotificationSettings:notificationSettings];

// more stuff


Thanks !

Also, I’m wondering if this hook could be replaced by this call by tinycreative/react-native-intercom Intercom.sendTokenToIntercom(FCMToken)?

Did you find any solution for this?

I have exact problem with receiving silent notifications on my App on the first launch. In my React Native app I am using https://github.com/tinycreative/react-native-intercom library. If I remove intercom library all of the notifications are received. After set up Intercom as described in github library I am not receiving silent notifications only on the firs app launch.

In device logs i can see message:

Warning: Application delegate received call to -application:didReceiveRemoteNotification:fetchCompletionHandler: but the completion handler was never called.

Problem is also describe here https://stackoverflow.com/questions/28753884/didreceiveremotenotificationfetchcompletionhandler-but-the-completion-handler but so far I didn’t find solution to solve it.