Push Notifications not working on iOS outside of Expo

Hey,
I build my app with Expo Push Notifications and they work both on android and iOS when running in Expo App. But when I am in production it only works on android. I tried deleting all profiles and identifiers and keys and rebuild them with Expo. I tried creating my own p8 and csr, everything i found on the internet. But still no push notifications, and also not with the PushNotif-Tool.

What else can I try?

When you send a push notification to the Expo’s api (or use https://expo.io/dashboard/notifications and check it in Network), the api will return a message id like this “6c5eeb27-e7c5-433e-87b5-361b615f3cb8”.
The next step is send another request to
https://exp.host/--/api/v2/push/getReceipts:


You will receive the error message and try to fix that.
In my case, I used p12 certificate instead of p8 key, that’s why it couldn’t send push notification.

2 Likes

Thank you, I got that result:
{“data”:{“ab969f69-3ab0-4bcb-b69f-9e4d5ec064f2”:{“status”:“error”,“message”:“The Apple Push Notification service failed to send the notification (reason: InvalidProviderToken, status code: 403). Read Apple’s docs about “Communicating with APNs” to learn what this error means.”,“details”:{“apns”:{“reason”:“InvalidProviderToken”,“statusCode”:403},“error”:“InvalidCredentials”,“sentAt”:1567495589},"__debug":{}}}}

If I search for “InvalidProviderToken” I only find “create an Apple Push Notification Authentication Key (Sandbox & Production)” but I already have one. What should I do now?

Maybe you need to verify:

  1. Is p8 file correct? (It’s a text content file, not certificate, check here: https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/establishing_a_token-based_connection_to_apns)
  2. Token key. Make sure it was created by your application not expo client.
  3. bundleIdentifier
  1. I made my .p8 in exactly that way
  2. Yes
  3. Is the same everywhere

If I delete all certificates, profiles and identifiers. What do I have to do step by step to get all right? (including expo build etc.) Just to make sure.

You’ll want to run build:ios and then let Expo generate them for you again. You won’t actually have to submit the new build or anything, you’ll just need to ensure the credentials were properly generated.

Okay but still how do I create all of them properly?

Okay now I’m getting:
{“data”:{“223b9627-2705-4182-accf-b8595976aa47”:{“status”:“error”,“message”:“The Apple Push Notification service failed to send the notification (reason: BadDeviceToken, status code: 400). Read Apple’s docs about “Communicating with APNs” to learn what this error means.”,“details”:{“apns”:{“reason”:“BadDeviceToken”,“statusCode”:400},“sentAt”:1567589947},"__debug":{}}}}

The error indicates the token is invalid. Can you try testing sending a notification to said token with our testing tool: https://expo.io/dashboard/notifications

1 Like
1 Like

@adamjnav Thats what I did
@ffelip I have already tried that but I will try again tomorrow, thanks.

When you start your App on iOS Standalone, have you been asked for notification permissions?
How does the scheme of your Token looks like in the Database for this specific user?

I had problems too but due to an implementation error not following the EXPO docs correctly.

1 Like

Yes I get asked right away. The token looks like: ExponentPushToken[XXX-uOJKYybxotGGSHF5jo]

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.