Jump to content
Mikinho

Unable to receive push notification on iOS with FCM

Recommended Posts

Hi there,

 

Im using FMX Delphi 12.2 with FireBase iOS SDK v. 6.28. I successfully retrieve the device token, but when i send a push notification via Insomnia or Firebase my I'Phone doesn't receive any push notification. Sometimes i get the following response from the request:

 

{
    "error": {
        "code": 401,
        "message": "Auth error from APNS or Web Push Service",
        "status": "UNAUTHENTICATED",
        "details": [
            {
                "@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
                "errorCode": "THIRD_PARTY_AUTH_ERROR"
            },
            {
                "@type": "type.googleapis.com/google.firebase.fcm.v1.ApnsError",
                "statusCode": 403,
                "reason": "InvalidProviderToken"
            }
        ]
    }
}

 

I followed the steps mentioned here: https://synaptica.info/en/2022/03/24/delphi-11-firebase-cloud-messaging-fcm-ios-app-push-notification-1/

My project includes the GoogleService-Info.plist in its resources, the UIBackgroundModes key has the remote-notification value assigned and my firebase project is configured with the APNS key.

 

Im obtaining the device token using the TPushService and TPushServiceConnection classes:

  PushService := TPushServiceManager.Instance.GetServiceByName(TPushService.TServiceNames.FCM);

 

What am i missing? Could this be related to apple ids, certificates or provisioning profiles config?

 

I'd greatly appreciate any help

Share this post


Link to post
5 hours ago, Mikinho said:

Sometimes i get the following response from the request:

"Sometimes" seems a bit odd. 

5 hours ago, Mikinho said:

Could this be related to apple ids, certificates or provisioning profiles config?

More than likely you do not have an APNs Key configured in Firebase Console. In the (poorly written) article you linked to, it mentions this at this point:

"In the settings section you have to upload the APN certificate that you previously generated on the apple portal in the “Keys” section"
 

Share this post


Link to post
2 hours ago, Dave Nottage said:

More than likely you do not have an APNs Key configured in Firebase Console. In the (poorly written) article you linked to, it mentions this at this point:

"In the settings section you have to upload the APN certificate that you previously generated on the apple portal in the “Keys” section"

Thanks for your response.

 

First of all, I did have the APNs key configured in the FB console, and I also verified that both the key and team ID were correct. Nevertheless, thanks to your observation, I double-checked and reviewed the .p8 file used to load the APNs Auth key and noticed that its name didn’t match the key ID configured in my Apple Developer account. I created a new APNs Auth key, loaded it again, and now I’m receiving push notifications.

 

As for the article, I know maybe it’s not the best and might be outdated, but there are only a few online resources or docs that describe the implementation of the Firebase iOS SDK in Delphi.

 

Thanks again for your support.

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×