react-native-fcm icon indicating copy to clipboard operation
react-native-fcm copied to clipboard

getFCMToken is returning undefined

Open cesar-alamilla opened this issue 6 years ago • 14 comments

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

cesar-alamilla avatar Sep 14 '17 05:09 cesar-alamilla

sounds like a FCM question. I have no clue. Check if refresh token is tirggered?

evollu avatar Sep 14 '17 14:09 evollu

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.

cesar-alamilla avatar Sep 14 '17 14:09 cesar-alamilla

Can you start receiving notification after delete and reinstall the app?

evollu avatar Sep 14 '17 15:09 evollu

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? 😕

cesar-alamilla avatar Sep 14 '17 18:09 cesar-alamilla

When you reinstall the app, do you get new firebase token now?

evollu avatar Sep 14 '17 19:09 evollu

No what I get from the request is just an 'undefined'

cesar-alamilla avatar Sep 14 '17 20:09 cesar-alamilla

then something is wrong getting token. Have you requestedPermission before you call getFCMToken?

evollu avatar Sep 15 '17 01:09 evollu

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 😕

cesar-alamilla avatar Sep 15 '17 02:09 cesar-alamilla

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

evollu avatar Sep 15 '17 03:09 evollu

That's right.

I will try that but in the case I get nil maybe is a configuration problem?

cesar-alamilla avatar Sep 15 '17 03:09 cesar-alamilla

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.

hosembafer avatar Apr 28 '18 18:04 hosembafer

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.

cesar-alamilla avatar Apr 30 '18 03:04 cesar-alamilla

+1 same , "react-native-fcm": "^16.0.0",

herarya avatar Jul 13 '18 07:07 herarya

have you got solution for it

manawaraquevix avatar Sep 01 '20 09:09 manawaraquevix