expo: [iOS] getExpoPushTokenAsync can't work on first time iOS . need restart ?
š Bug Report
I have install expo-notification to use on my Bare workflow app . On android it work as expected . How ever , on iOS (xcode 11) . the getExpoPushTokenAsync just hang on the first time opening app ( notification is allowed ) . The only way to get it work is restart the app ( kill app then re open ) . Any one know the root cause . Please share
Environment
Expo CLI 3.19.2 environment info:
System:
OS: macOS 10.15.3
Shell: 3.2.57 - /bin/bash
Binaries:
Node: 13.13.0 - /usr/local/bin/node
Yarn: 1.22.4 - /usr/local/bin/yarn
npm: 6.14.4 - /usr/local/bin/npm
Watchman: 4.9.0 - /usr/local/bin/watchman
IDEs:
Android Studio: 3.6 AI-192.7142.36.36.6392135
Xcode: 11.4/11E146 - /usr/bin/xcodebuild
npmPackages:
expo: ^37.0.8 => 37.0.8
react: 16.9.0 => 16.9.0
react-native: 0.61.4 => 0.61.4
react-navigation: ^4.2.2 => 4.2.2
npmGlobalPackages:
expo-cli: 3.19.2
Steps to Reproduce
Open the app in iOS , log or show the push token . First time open app , request for notification allowed . No pushtoken . Debug show that getExpoPushTokenAsync hang .
Kill app then reopen . getExpoPushTokenAsync can get the push token and show as expected
Expected Behavior
Push token must be granted for the first time open app
RegisterPushToken code
import * as Notifications from "expo-notifications";
import Constants from "expo-constants";
export default async () => {
await Notifications.requestPermissionsAsync();
let experienceId;
if (!Constants.manifest) {
// Absence of the manifest means we're in bare workflow
experienceId = "@redclouds/TappoMerchant";
}
const expoPushToken = await Notifications.getExpoPushTokenAsync({
experienceId
});
console.log("expoPushToken.data", expoPushToken.data);
__DEV__ && console.warn("ExponentPushToken", expoPushToken.data);
return Promise.resolve(expoPushToken.data);
};
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Comments: 17 (3 by maintainers)
Commits related to this issue
- [expo-notifications] Allow simultaneous calls to push token fetch (#8608) # Why May make `get[Expo|Device]PushTokenAsync` more resilient by both: - letting those two methods share a single reques... — committed to expo/expo by sjchmiela 4 years ago
- [expo-notifications] Allow simultaneous calls to push token fetch (#8608) # Why May make `get[Expo|Device]PushTokenAsync` more resilient by both: - letting those two methods share a single reques... — committed to expo/expo by sjchmiela 4 years ago
+1, getting the error
Another async call to this method is in progress. Await the first Promise.
:https://github.com/expo/expo/blob/bd469e421856f348d539b1b57325890147935dbc/packages/expo-notifications/ios/EXNotifications/PushToken/EXPushTokenModule.m#L35
Thank you all for reports of this problem. Frankly speaking the being run forever makes the most senseāthere is no way another Promise would be run if you didnāt run it. Iāll take a look at it as soon as possible, Iāve also heard @tsapeta has reproduced itāthe Promise didnāt resolve immediately and only after a long while the system permissions dialog showed upāmaybe itās some kind of iOS bug? Iāll let you know when I find out!
Thanks for the update @sjchmiela, in my case the issue is that
Notifications.getDevicePushTokenAsync
does not throw any error at all(which is obviously there) so no chance to figure out the reason of fail, so please check that it throws when something goes wrongā¦