-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[iOS] getExpoPushTokenAsync can't work on first time iOS . need restart ? #8084
Comments
+1, getting the error expo/packages/expo-notifications/ios/EXNotifications/PushToken/EXPushTokenModule.m Line 35 in bd469e4
|
+1 |
Hi, I am facing the same issue. Works perfectly on Android, but on ios it always returns this mesage. Is there any workaround? |
Confirming also that it works for Android, but not for iOS with the same error as above:
|
Same error after ejecting |
Hi all, I was able to fix it by passing the DevicePushToken as a parameter to getExpoPushTokenAsync function. |
I'm not sure if it's the same issue but I guess they are related. I have bare workflow, unimodules. Whole notifications flow works perfectly on Android(getting token, sending, receiving) but on iOS @raffaelst How did You fetch |
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 |
Hm, ok, so in general I've reread the documentation around configuring push notifications and the docs say:
which would explain why on the second call (after restarting the application) it may be quicker. In a Troubleshooting document one can find suggestions that:
Does it make sense? Is there anyone who could confirm that, probably, the issue is only reproducible while the device has not yet made connection to APNS for development environment or that is more likely to happen on an unreliable connection? When it comes to getting the
error, I'm worried I can't tell you anything apart from are you sure you're not calling The very first thing expo/packages/expo-notifications/src/getExpoPushTokenAsync.ts Lines 27 to 28 in 1d09954
so calling those two methods at the same time will definitely make one of them reject. If you want to fetch both device push token and Expo push token I would recommend calling them either in sequence const devicePushToken = await Notifications.getDevicePushTokenAsync();
const expoPushToken = await Notifications.getExpoPushTokenAsync(); or reuse the device push token as in const devicePushToken = await Notifications.getDevicePushTokenAsync();
const expoPushToken = await Notifications.getExpoPushTokenAsync({ devicePushToken }); which makes sense when you see the first line of the implementation of |
Notifications.getDevicePushTokenAsync() also gives same error
I tried withoutCalling
getDevicePushTokenAsync doesn't return keeps on waiting.
|
) # Why May make `get[Expo|Device]PushTokenAsync` more resilient by both: - letting those two methods share a single request to fetch device push token - handling Fast Refresh better by sharing the single request. Should fix #8084. # How Save the `Promise` that will resolve with device push token. # Test Plan - [x] added a new test case and verified that it passes as expected
) # Why May make `get[Expo|Device]PushTokenAsync` more resilient by both: - letting those two methods share a single request to fetch device push token - handling Fast Refresh better by sharing the single request. Should fix #8084. # How Save the `Promise` that will resolve with device push token. # Test Plan - [x] added a new test case and verified that it passes as expected
Thanks for fix. When it will get release? |
It should be available as |
We experience a similar behavior with a required restart before getExpoPushTokenAsync works but in the managed workflow. Any information on that? I guess the fix here is just for the bare workflow? |
Hello, I experience this error in build ios app. How can I fix it? |
I Face the same issue in a bare workflow app with SDK 42, any news about it ? |
Hello, I spent quite a lot of time trying to fix this issue with SDK 41. It was caused by two different version of FYI @tfisc @SeoungJinKim |
🐛 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
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
The text was updated successfully, but these errors were encountered: