Description of the problem:
While on Android the registration callback returns the FCM token, on iOS it returns the APNs token. I understand why, but it is really confusing since I just followed the instructions in a post meant to integrate Capacitor Push Notifications with FCM for both iOS and Android. In this scenario, a common use case is to send the FCM token to server so we can send personalized notifications to users, but nowhere in the tutorial is said that you need a third-party plugin to get the FCM token in iOS, which is by no means expected.
I am not asking for this feature to be integrated in core, since I have seen some issues closed for this reason saying that this should be handled by a third-party plugin, but if this issue is not well explained in the official tutorial, it can be very misleading for people trying to use FCM as push notification server for all platforms.
I am talking about this official tutorial, which is part of the docs: https://capacitor.ionicframework.com/docs/guides/push-notifications-firebase
Thanks.
Affected platform
Agreed! That guide is pretty misleading, or at best incomplete. I had some issues with another plugin I had to use, so I avoided the FCM one (notifications have pretty consistently been a hassle for me) - I ended up with an admittedly VERY hacky solution. I'm planning on moving over to the plugin soon, though!
Not officially supporting FCM on iOS is totally understandable, but the guide should provide the proper steps to do so, or not have an iOS section (which at that point would be pretty pointless because then its just the Push Notification plugin on Android...).
Agreed! Use capacitor-fcm in the while
Thanks @adrm for logging this. I also tripped up on this. The tutorial linked specifically mentions that it is also for iOS, and it does work (insofar as it registers the device with Firebase, which can then be targeted when bulk sending to devices). However, it would be nice to add something to the docs to the effect of "Firebase/Messaging' pod currently does not return the FCM token without use of an additional plugin".
Thanks @ludobit for recommending capacitor-fcm. This appears to work well.
This is still an issue. @ludobit I will try capacitor-fcm, thanks for the heads up.
My solution also makes it all work without having to make @capacitor/ios include the firebase messaging pod so I hope it can be merged.
What is confusing that example is sending messages from FCM.
Another fix required is that getDeliveredNotifications is not implemented in Android
wondering if you were able to fix it?
Curious what's your hacky solution? Use another call to get the registered token by given the APN token?
wondering if you were able to fix it?
Curious what's your hacky solution? Use another call to get the registered token by given the APN token?
I am using capacitor-fcm plugin just to get ios token
closing since https://github.com/ionic-team/capacitor/pull/2078 updated the docs
Most helpful comment
Agreed! That guide is pretty misleading, or at best incomplete. I had some issues with another plugin I had to use, so I avoided the FCM one (notifications have pretty consistently been a hassle for me) - I ended up with an admittedly VERY hacky solution. I'm planning on moving over to the plugin soon, though!
Not officially supporting FCM on iOS is totally understandable, but the guide should provide the proper steps to do so, or not have an iOS section (which at that point would be pretty pointless because then its just the Push Notification plugin on Android...).