I implemented push notifications using Firebase FCM, Ionic V4 and Capacitor. I built the app for both Android and iOS.
Everything is working fine, I'm able to get and handle push notifications, except for when the iOS app is first launched after installation, at that time, the registration and registrationError are not being fired, this is how it's implemented on my project:
const {
PushNotifications,
} = Plugins;
...
// On success, we should be able to receive notifications
PushNotifications.addListener(
'registration',
(token: PushNotificationToken) => {
this.storageService.setCookie('IID_TOKEN', token.value);
}
);
// Some issue with our setup and push will not work
PushNotifications.addListener('registrationError', (error: any) => {
console.log('Error on registration: ' + JSON.stringify(error));
});
They are called with no problems the second and all the following times the iOS app is launched, on Android works every time (including the first one).
My only guess is that when I ask the user for permissions to receive push notifications, those listeners are blocked in that execution.