1
votes

I am using firebase for push notifications and developing a mobile app using ionic/capacitor. I register the push notifications and get back a token like this...

PushNotifications.requestPermission().then( result => {
  if (result.granted) {
    PushNotifications.register();
  }
});

PushNotifications.addListener('registration',
  (token: PushNotificationToken) => {
    alert('Push registration success, token: ' + token.value);
    console.log(token.value);
  }
);

In the firebase console I can successfully send and receive notifications when targeting my app in the user segment but when I try to target a single device by copying and pasting in the token using send test message I do not receive the push notification. Note: this works fine for me on Android.

Token looks like this... BAAEF129E8F596F1305D0FEA2F50E21B2768FEFCA83CF19602CA0183077E441D

1
How does your token look like?jcesarmobile
BAAEF129E8F596F1305D0FEA2F50E21B2768FEFCA83CF19602CA0183077E441DMark Letters

1 Answers

2
votes

Capacitor uses APNS for push, that token you got is a APNS token and those don't work on FCM. Not sure how did you integrate FCM into Capacitor, but you should convert the APNS token to FCM token.

It's something like this

    func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
        Messaging.messaging().apnsToken = deviceToken
        InstanceID.instanceID().instanceID { (result, error) in
            if let error = error {
                NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidFailToRegisterForRemoteNotificationsWithError.name()), object: error)
            } else if let result = result {
                NotificationCenter.default.post(name: Notification.Name(CAPNotifications.DidRegisterForRemoteNotificationsWithDeviceToken.name()), object: result.token)
            }
        }
    }

For more information you can check this guide about how to integrate FCM into Capacitor.