evollu / react-native-fcm

react native module for firebase cloud messaging and local notification
MIT License
1.73k stars 682 forks source link

Switching between APNs environments (dev/prod) #564

Open jkallunki opened 7 years ago

jkallunki commented 7 years ago

I'm not sure if this is related to this library (which is awesome btw) or directly to FCM, but I have run into some problems receiving iOS notifications when using different versions of my app on one device. For example, currently my iPhone receives notifications only when my app is installed with TestFlight, but not when I run the development build from XCode. When I released my app in AppStore and installed it to the same device, it doesn't receive notifications either, which is strange since it should be the exactly same binary that is in TestFlight.

I think I received notifications in the iOS XCode dev build as long as I hadn't installed it via TestFlight, but after the first TestFlight installation remote notifications stopped working in dev mode.

Has this something to do with the way FCM handles APNs tokens? I'm using a single APNs Authentication Key in Firebase console. Is there any way to force refresh/reset the FCM token?

I'm using react-native-fcm 8.0.0 with react-native 0.47.2

evollu commented 7 years ago

I don't need to reset FCM token when I switch to Auth Key. Can you check if you've updated refresh token? That thing changes pretty often. Also does your app id in firebase console match your apps all the way from dev to prod?

Just guessing the causes.

fmaceachen commented 7 years ago

@jkallunki The same is happening to me. Push notifications from FCM test form are only sent to devices when installed by TestFlight, they stopped working in development.

I'm using react-native-fcm 9.3.0 react 0.48

roberto-rodriguez commented 7 years ago

I found a solution. This was my scenario: I added Push Notifications to an existent app, tested by running using Xcode to my device and it worked well, but when when created the Archive and installed via iTunes, it didn't receive Push Notifications. This was the problem: When I added the permissions for push notifications in the Apple Developer Portal, my Provisioning Profile got obsolete (Invalid). Check your provisioning profile status in the Apple Dev Portal. Solution I generated a new Provisioning Profile, apply to my iTunes/phone, and now when I install the app it works well. I can receive the push notifications. I hope it helps. Thans to @evollu for this great lib!!