React-native-notifications: Not receiving notifications from firebase on IOS

Created on 14 Nov 2019  路  9Comments  路  Source: wix/react-native-notifications

I have an issue on IOS... I dont receive any notifications on IOS through firebase... Anyone can help me?

Info of my package:
"react-native": "0.61.3",
"react-native-firebase": "^5.5.5",
"react-native-notifications": "^2.0.6",

馃彋 stale

Most helpful comment

On IOS: I realized that deviceToken was invalid (it's not firebase token). So I solved this issue with steps as below:

  1. In Podfile, add:
pod  'Firebase/Messaging'
  1. In Appdelegate.m, add codes as below:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
//....
if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
//....
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  NSString *fcmToken = [FIRMessaging messaging].FCMToken; 
  NSLog(@"FCM registration token: %@", fcmToken); 
  [RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:fcmToken];
}
  1. Finally, pod install and run!

All 9 comments

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

The issue has been closed for inactivity.

Any update on this? facing same issue

I think I have found the issue. With IOS there is a APN (Apple Push Notifications) token and a FCM (Firebase Cloud Messaging) token.

Notifications.events().registerRemoteNotificationsRegistered((event: Registered) => {
    console.log( event.deviceToken);
});

This method will only return a APN token for me and never a FCM token (even on refresh), unlike on Android.
I can see no possible way to get the FCM within this package.

It took very long time to figure out this was the issue as with Firebase there are no errors when using the Firebase console to send notifications.

My fix has been to take the event.deviceToken and convert it to an FCM and then send this to firebase to make the notification request.

This can be done through a post request to https://iid.googleapis.com/iid/v1:batchImport

2 headers
Content-Type: application/json
Authorization: key=AA...MD

body in json
{"application": "org.reactjs.native.example.BMMPApp", "sandbox":true, "apns_tokens":[ "5518d...885" ]}

You can find the authorization key from going into firebase console, settings, cloud messaging and copying the server key.

This issue really needs to be opened and the README neesd to be updated to explain this package does not support FCM with iOS.

Hope this helps someone out.

@puremana are you seeing the notifications on your iOS device ? I don't see them on my side even after converting the APNS token to FCM token.

@puremana are you seeing the notifications on your iOS device ? I don't see them on my side even after converting the APNS token to FCM token.

Yes, I eventually did get everything to work. This article was a godsend in debugging my issue. https://firebase.googleblog.com/2017/01/debugging-firebase-cloud-messaging-on.html

Follow that step by step and you should figure it out, sorry I can't be of more help but it could be one of many issues.

Why is this closed ! what is the solution for this am still facing this issue!

On IOS: I realized that deviceToken was invalid (it's not firebase token). So I solved this issue with steps as below:

  1. In Podfile, add:
pod  'Firebase/Messaging'
  1. In Appdelegate.m, add codes as below:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
//....
if ([FIRApp defaultApp] == nil) {
    [FIRApp configure];
  }
//....
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
  NSString *fcmToken = [FIRMessaging messaging].FCMToken; 
  NSLog(@"FCM registration token: %@", fcmToken); 
  [RNNotifications didRegisterForRemoteNotificationsWithDeviceToken:fcmToken];
}
  1. Finally, pod install and run!

@hienpham2102

Would you mind showing some of your React Native implementation for getting the token and sending it to your BE notification service?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

josefheld picture josefheld  路  4Comments

moonjava2005 picture moonjava2005  路  5Comments

codoffer picture codoffer  路  5Comments

denissb picture denissb  路  5Comments

WhereBeTheDan picture WhereBeTheDan  路  5Comments