Can't get IOS notifications push token
See original GitHub issueSummary
When calling getDevicePushTokenAsync or getExpoPushTokenAsync on an ios device, The promise never resolved and never throw.
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
bare
What platform(s) does this occur on?
iOS
SDK Version (managed workflow only)
42
Environment
expo-env-info 1.0.2 environment info: System: OS: macOS 11.5.2 Shell: 5.8 - /bin/zsh Binaries: Node: 14.18.1 - ~/.nvm/versions/node/v14.18.1/bin/node Yarn: 1.22.11 - /opt/homebrew/bin/yarn npm: 6.14.15 - ~/.nvm/versions/node/v14.18.1/bin/npm Watchman: 2022.01.31.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.2 - /Users/thibaultfischer/.rbenv/shims/pod SDKs: iOS SDK: Platforms: iOS 15.0, DriverKit 20.4, macOS 11.3, tvOS 15.0, watchOS 8.0 Android SDK: API Levels: 30, 31 Build Tools: 28.0.3, 29.0.2, 31.0.0 System Images: android-31 | Google APIs ARM 64 v8a, android-32 | Google Play ARM 64 v8a IDEs: Android Studio: 2020.3 AI-203.7717.56.2031.7678000 Xcode: 13.0/13A233 - /usr/bin/xcodebuild npmPackages: babel-preset-expo: 8.3.0 => 8.3.0 expo: ^42.0.0 => 42.0.5 react: 16.13.1 => 16.13.1 react-dom: 16.13.1 => 16.13.1 react-native: 0.63.4 => 0.63.4 Expo Workflow: bare
Reproducible demo
export const registerForPushNotificationsAsync = async () => { try { if (Constants.isDevice) { const status = await getNotificationsPermissionStatus(); if (status !== Permissions.PermissionStatus.GRANTED) { return; } const token = await Notifications.getExpoPushTokenAsync(); return token.data; } } catch (err) {
Here we never go in the catch and we never reach the “return token.data” line
Issue Analytics
- State:
- Created 2 years ago
- Reactions:5
- Comments:6
Ok, found the problem : We are using Intercom react native library, and setting it up we added this line :
But now the didRegisterForRemoteNotificationsWithDeviceToken is not returning anything, so the expo getDevicePushTokenAsync never resolves…
The solution : If you are using a third party library that asks you to implement something in didRegisterForRemoteNotificationsWithDeviceToken method, make sure to return to keep expo notifications working :
return [super application:application didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
I got the same issue than @thibaultfischer: Intercom react library seems to have an issue with notification token. The fix proposed by @thibaultfischer is working fine: In the file
ios/MyApp/AppDelegate.m
, I replaced:By:
Then, I updated the
getExpoPushTokenAsync()
params to add theexperienceId
andapplicationId
: