Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Issue with receiving push notifications on iOS using Capacitor and Firebase

I am facing a problem with receiving push notifications on iOS using Capacitor and Firebase Cloud Messaging. Here are the details:

  • I'm using @capacitor/push-notifications, and followed the setup steps provided in the plugin documentation for iOS.
  • Android devices receive notifications successfully, but iOS devices do not.
  • PushNotifications.register() runs successfully and the FCM token is obtained from iOS device.
  • Notification permission is asked at first startup. I also checked the app settings. Notifications are enabled.
  • I have downloaded GoogleService-Info.plist from FCM and pasted it into the root of my IOS project.
  • I have uploaded the APNs Certificates for both Development and Production modes in FCM dashboard.
  • Im using "@capacitor/core": "^5.0.0", "@capacitor/push-notifications": "^5.0.4" and "@capacitor/ios": "^5.0.5".
  • I have tried sending a test notification directly to that device from FCM dashboard (using device FCM token), but no notification is received.
  • I have tried this scenario on a real device and an emulator. still no luck.

Despite these steps, notifications are not received on iOS devices/emulators. I would appreciate any guidance. Thank you in advance.

like image 871
Ghonche Yqr Avatar asked Nov 01 '25 06:11

Ghonche Yqr


2 Answers

I used @capacitor-firebase/messaging plugin instead of @capacitor/push-notifications and that worked for me.

( This guide helped me ,Thanks to RGe )

like image 177
Ghonche Yqr Avatar answered Nov 02 '25 22:11

Ghonche Yqr


I encountered the same issue. I simply followed this guide: https://capacitorjs.com/docs/apis/push-notifications. However, the problem is that many steps are missing from this guide. You don't need to replace the npm package @capacitor/push-notifications as suggested in the accepted answer.

In addition, follow this guide and the problem will be resolved: https://capacitorjs.com/docs/guides/push-notifications-firebase#prerequisites


Background: Without the Firebase initialization code mentioned in the prerequisites, the push token has an incorrect format.

Without the prerequisites, the push token you receive from the looks like this: 3B7CA1BCAE6B0C972CCE9D9D10B98E88160185A8D65C08294F4EFBA509D5E539

After completing all the steps successfully, the token has a different format with colons and dashes, and it becomes significantly longer. I hope this helps!

Token format after including the prerequisites: fAs7FPRhTGqH9gXMYX3vHy:APA81bF9gCc99u-Q2IuylC9Nctn1nAmlVgCu3U8dCvSHvWIX3MHFG1t5BoXFS6CCkSETiB9iqxz-CgyNtfn2DJYFF3vod_puQOW2xsh-a_I7XfURFAJqSmrQDBo9RCc55XX-3N47Bq54

like image 30
mleister Avatar answered Nov 02 '25 22:11

mleister



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!