title: APNS device token not set before retrieving FCM Token for Sender ID - React Native Firebase
body: <p>I have been following <a href="https://www.youtube.com/watch?v=zeW8DO5KZ8Q" rel="noreferrer">this</a> tutorial to set-up Remote Push notifications on my react-native application using react-native-firebase Version 5.2.0. After I configured everything and ran the application I get an error as: </p>
  
  <blockquote>
    <p><strong>APNS device token not set before retrieving FCM Token for Sender ID ''. Notifications to this FCM Token will not be delievered over APNS. Be sure to re-retrieve the FCM token once the APNS token is set.</strong></p>
  </blockquote>
  
  <p>Been trying to figure out how to solve this issue but wasn't quite successful.
  Running on react-native : 0.61.2, react-native-firebase: 5.2.0</p>
  
  <p>Following is my AppDelegate.m</p>
  
  <pre><code>#import "AppDelegate.h"
  
  #import &lt;React/RCTBridge.h&gt;
  #import &lt;React/RCTBundleURLProvider.h&gt;
  #import &lt;React/RCTRootView.h&gt;
  #import &lt;RNCPushNotificationIOS.h&gt;
  #import &lt;UserNotifications/UserNotifications.h&gt;
  #import &lt;Firebase.h&gt;
  
  @import Firebase;
  @implementation AppDelegate
  
  - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
  {
    [FIRApp configure];
    RCTBridge *bridge = [[RCTBridge alloc] initWithDelegate:self launchOptions:launchOptions];
    RCTRootView *rootView = [[RCTRootView alloc] initWithBridge:bridge
                                                     moduleName:@"helloworld"
                                              initialProperties:nil];
  
    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];
  
    // define UNUserNotificationCenter
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter];
    center.delegate = self;
  
    return YES;
  }
  
  - (NSURL *)sourceURLForBridge:(RCTBridge *)bridge
  {
  #if DEBUG
    return [[RCTBundleURLProvider sharedSettings] jsBundleURLForBundleRoot:@"index" fallbackResource:nil];
  #else
    return [[NSBundle mainBundle] URLForResource:@"main" withExtension:@"jsbundle"];
  #endif
  }
  
  // Required to register for notifications
  - (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
  {
    [RNCPushNotificationIOS didRegisterUserNotificationSettings:notificationSettings];
  }
  // Required for the register event.
  - (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
  {
    [RNCPushNotificationIOS didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
  }
  // Required for the notification event. You must call the completion handler after handling the remote notification.
  - (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
  fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
  {
    [RNCPushNotificationIOS didReceiveRemoteNotification:userInfo fetchCompletionHandler:completionHandler];
  }
  // Required for the registrationError event.
  - (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error
  {
    [RNCPushNotificationIOS didFailToRegisterForRemoteNotificationsWithError:error];
  }
  // Required for the localNotification event.
  - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
  {
    [RNCPushNotificationIOS didReceiveLocalNotification:notification];
  }
  
  //Called when a notification is delivered to a foreground app.
  -(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
  {
    NSLog(@"User Info : %@",notification.request.content.userInfo);
    completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);
  }
  
  
  @end
  </code></pre>
  
  <p>and token retrieval on my App.js:</p>
  
  <pre><code>const messaging = firebase.messaging();
  
  messaging.hasPermission()
    .then((enabled) =&gt; {
      if (enabled) {
        messaging.getToken()
          .then(token =&gt; { console.log("+++++ TOKEN ++++++" + token) })
          .catch(error =&gt; { console.log(" +++++ ERROR GT +++++ " + error) })
      } else {
        messaging.requestPermission()
          .then(() =&gt; { console.log("+++ PERMISSION REQUESTED +++++") })
          .catch(error =&gt; { console.log(" +++++ ERROR RP ++++ " + error) })
      }
  
    })
    .catch(error =&gt; { console.log(" +++++ ERROR +++++ " + error) });
  
  </code></pre>
  
  <p>Any help would be much appreciated! Thanks!</p>