react-native-fcm
react-native-fcm copied to clipboard
getFCMToken is returning undefined
I have a curious problem
I can configure the iOS push notifications correctly. But after a few days the users start to say they can't get the notifications. I think the issue are with the certificates so I change either the develop and the production certificates but no luck.
Then I try to generate an APN auth key but the result was the same.
All I can get in the log is this (I use the push controller of the example):
'TOKEN (getFCMToken)', undefined 'APNS TOKEN (getFCMToken)', ''
I think maybe need to wait to ask to Firebase for the token so I put a delay of a minute to request for the token but nothing changes.
My RN version is 0.48.1 and react-native-fcm: 9.1.0 ? The problem is only on iOS on Android the notifications seems to work fine
sounds like a FCM question. I have no clue. Check if refresh token is tirggered?
Is not, I try putting in another component or in another part of the code but no luck. The refresh token event is never triggered.
Can you start receiving notification after delete and reinstall the app?
Nope even if I delete and reinstall the app the users can't get their notifications. The curious thing is, in the Firebase Console I can see the notification is sending correctly but the users can get any data. Any suggest? 😕
When you reinstall the app, do you get new firebase token now?
No what I get from the request is just an 'undefined'
then something is wrong getting token. Have you requestedPermission before you call getFCMToken?
I don't think so. I request for permissions in the constructor and in the PushController component. Also I put a delay of 1 minute on the constructor to call again for the token but it's still getting an undefined object.
I think maybe the object that is returning is not a token string as expected and is some kind of object don't recognized by javascript or maybe a compound object and I need to access their props like token.someString. I don't know, I don't understand why at the beginning I can reach the notifications and suddenly I can't 😕
When you request permission you see a prompt to let user allow right?
You can debug native code in xcode and see what FCM returns, but I don't think it will be anything other than nil
That's right.
I will try that but in the case I get nil maybe is a configuration problem?
The same issue, can't get token, and can't request permission. Thay only return undefined.
But I have not implemented Shared steps.
So my question, I wasn't handling my remote notifications by app. I need only send the notification to iPhone's bar, so in this case, am I need to implement Shared steps? Because my app crashes when I changing AppDelegate.h and AppDelegate.m how provided in Shared steps.
Everything works fine on Android.
Yes you need to implement the Shared Steps anyways. The Shared Steps is to configure the fcm library in the app and to handle local or remote notifications, so you need it. Maybe is a typo in your code the reason of the crash.
+1 same , "react-native-fcm": "^16.0.0",
have you got solution for it