capacitor-community / fcm

Enable Firebase Cloud Messaging for Capacitor apps
https://capacitor.ionicframework.com/docs/
MIT License
238 stars 83 forks source link

iOS FCM token is NotRegistered after deleting and reinstalling APP #160

Open sagun-gautam opened 1 week ago

sagun-gautam commented 1 week ago

Describe the bug The token generated by FCM.getToken() after deleting and installing the app from store returns shows 'UnRegistered' in FCM Rest API response.

To Reproduce Steps to reproduce the behavior:

  1. Your app should have push notification enabled.
  2. Delete your app.
  3. Again Immediately, install the app from app store
  4. Enable push notification.
  5. Send push notification to that user FCM token.
  6. Push notification is not received & Firebase API returns 'NotRegistered'.

Expected behavior FCM token should be valid, I can see the FCM token is stored is valid & changed from last token.

Screenshots If applicable, add screenshots to help explain your problem.

Smartphone (please complete the following information):

Additional context Some time the token generated after reinstalling the app is same in iOS

ThiagoTesche commented 1 week ago

Exactly, the same problem here! waiting for solution

leonardoMoliveira commented 1 week ago

Same problem here 😢

sagun-gautam commented 5 days ago

Anyone got the solution?

leonardoMoliveira commented 5 days ago

@sagun-gautam A workaround for me was create and endpoint in our backend that validates the push token by sending a data-only push notification and verifying the status code !== 404, then it returns back to the app. If is an invalid token, app calls the function FCM.refreshToken(), it generates a new token (this token may be invalid too, but it works in most cases). It occurs always in the app opening, so the token is always verified. Its not a 100% solution, but it helped a lot. Still waiting for a definitive solution.