Push Notifications not working on iOS but work fine on Android

Please provide the following:

  1. SDK Version: 35.0.1
  2. Platforms(Android/iOS/web/all): iOS
  Expo CLI 3.11.7 environment info:
    System:
      OS: macOS 10.14.6
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 8.9.1 - /usr/local/bin/node
      npm: 6.13.6 - /usr/local/bin/npm
      Watchman: 4.9.0 - /usr/local/bin/watchman
    IDEs:
      Android Studio: 3.5 AI-191.8026.42.35.5900203
      Xcode: 11.3.1/11C504 - /usr/bin/xcodebuild
    npmPackages:
      expo: 35.0.1 => 35.0.1 
      react: 16.8.6 => 16.8.6 
      react-native: 0.59.9 => 0.59.9 
      react-navigation: 4.0.10 => 4.0.10 
    npmGlobalPackages:
      expo-cli: 3.11.7

Problem: Push Notifications work on Android devices. Do not work on iOS devices.


Testing

I have tested the following on multiple devices…

  1. When testing Push Notifications with the Expo Client and Push Notifications Tool everything works fine.
  • get a token [OK]
  • when app not running, notification visible [OK]
  • when app running, listener is fired [OK]
  1. When testing with my TestFlight app and Push Notifications Tool I never receive the Push Notifications.
  • get a token [OK]
  • when app not running, notification visible [FAIL]
  • when app running, listener is fired [FAIL]
  1. When testing with my TestFlight app and Curl I never receive the Push Notifications.
  • get a token [OK]
  • sending message with Curl
  • when app not running, notification visible [FAIL]
  • when app running, listener is fired [FAIL]

Send Message Request

curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/send" -d '{
  "to": "ExponentPushToken[EYS-rMHBeYoSngPQZ1K-ps]",
  "title":"hello",
  "body": "world"
}'

Send Message Response

{"data":{"status":"ok","id":"e87398f1-b7cc-4e3d-aa47-b42b29562388"}

Get Receipt Request

curl -H "Content-Type: application/json" -X POST "https://exp.host/--/api/v2/push/getReceipts" -d '{
   "ids": ["e87398f1-b7cc-4e3d-aa47-b42b29562388"]
}'

Get Receipt Response

{"data":{"e87398f1-b7cc-4e3d-aa47-b42b29562388":{"status":"ok"}}}

Attempts to Fix

(I have been working on this for days. Read hundreds of posts. Tried combinations of below steps many times.)

Deleted all Distribution Certificates
Deleted all Profiles
Deleted all Keys

Used the expo credentials manager to remove the certs/keys from both of my Expo apps.

expo credentials:manager

Subscribed to expo paid plan to make builds faster!! Works nice.

Rebuilt the app with the --clear-provisioning-profile option…

expo build:ios --clear-provisioning-profile --release-channel prod

Confirmed that the Developer Portal looks good.

Certificates
- Apple Push Services Certificate (expiration 2021/02/16)
- iOS Distribution (01/18/2021)

Identifiers
- App exists with correct bundle id
- Capabilities include Push Notifications with 1 Certificate (Apple Push Services Certificate -expiration 2021/02/16)

Devices
- None

Profiles
- App exists with correct bundle id (includes Push Notifications in Enabled Capabilities)

Keys
- NAME: Expo Push Notifications Key 20200119111947
- SERVICE ENABLED: 1
- Key ID: QF9T6HJ6P6
- Enabled Services NAME: Apple Push Notifications service (APNs)
- Enabled Services CONFIGURATION: <blank>

Downloaded and saved the certs…

expo fetch:ios:certs

Uploaded the binaries using expo.

expo upload:ios --apple-id <apple-id> --apple-id-password <apple-id-password> --app-name <slugname>

Downloaded to devices via TestFlight.

Ran tests. No joy :frowning:

At this point, I am really not sure what to try next. I am not getting any errors from expo. I just don’t receive the push notifications on my iOS devices.

Forgot to mention. I have tested on the following devices.

iPhone 8

  • iOS 13.3

iPhone 6

  • iOS 12.4.4

iPhone 5

  • iOS `0.2.4

A bit more information…

Another TestFlight user just tested the APP on iPhone 8 with 13.3 (17C54) and it worked.

So, some users work and some don’t?

@taxconcierge and I debugged this over Slack:

Turns out that the Expo Push Token wasn’t being updated on new app installs because @taxconcierge was storing it with SecureStore, which we never warn against in the docs so this was a perfectly reasonable choice!

however- values stored in SecureStore can persist across installs from the same developer on iOS (thanks to keychain services). This meant the Expo Push Token for the new app install wasn’t being saved. This can be resolved by checking if you don’t already have a push token stored in SecureStore OR if the push token stored is different from the one you are now getting, and if either of those is true then storing the new push token.

Or you could use other storage options like AsyncStorage, SQLite, etc.

@charliecruzan Things seems to be working great now. Thank you so much for your assistance. You’re the man!

@taxconcierge I added a note to the docs to make sure this doesn’t take anyone by surprise again in the future :+1: https://github.com/expo/expo/pull/6820

Thanks again for bringing this up!

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