Skip to content
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

39: Notifications.getExpoPushTokenAsync hanging indefinitely in TestFlight #10369

Closed
hardcodet opened this issue Sep 24, 2020 · 12 comments · Fixed by #10845
Closed

39: Notifications.getExpoPushTokenAsync hanging indefinitely in TestFlight #10369

hardcodet opened this issue Sep 24, 2020 · 12 comments · Fixed by #10845
Labels
iOS needs validation Issue needs to be validated Notifications

Comments

@hardcodet
Copy link

hardcodet commented Sep 24, 2020

Expo 39, Managed App

This used to work on the previous build: Push notification token retrieval seems to be broken in iOS: My app simply is hanging without an error, and I traced it back to this call:

    try {
        ...
        rootStore.log += ".33";
        const tokenData = await Notifications.getExpoPushTokenAsync({experienceId});
        rootStore.log += ".34";
        ...
    } catch (e) {
        rootStore.log += ".36";
    } 

my log shows progress until the .33, and then nothing happens anymore. Any idea what's happening?

Btw, what i tried so far:

  • Pushing a new build to TestFlight
  • Uninstalling / reinstalling the app on the phone
@hardcodet hardcodet added the needs validation Issue needs to be validated label Sep 24, 2020
@hardcodet hardcodet changed the title Notifications.getExpoPushTokenAsync hanging indefinitely in TestFlight 39: Notifications.getExpoPushTokenAsync hanging indefinitely in TestFlight Sep 25, 2020
@brentvatne
Copy link
Member

what is experienceId? why are you passing it in? it defaults to the correct value if you leave it blank, if you are passing in an incorrect value this may have unexpected behavior

@hardcodet
Copy link
Author

@brentvatne I took a snipped from the docs as below. However, that one also caught my eye and I tried to invoke the method without passing it, but the result was the same:

        let experienceId = undefined;
        if (!Constants.manifest) {
            // Absence of the manifest means we're in bare workflow - hardcode the expo experience ID
            experienceId = "@hardcodet/pssn";
        }

@hardcodet
Copy link
Author

hardcodet commented Sep 26, 2020

To make things worse: This is not hanging on all devices. So the device in question:

  • works in the expo client of my phone
  • did work in testflight but does no longer, without any other changes to that device rather then deploying the new build.
  • as mentioned, uninstalling/reinstalling the app doesn't change anything

Another testflight install on another device works, also across restarts (for now)

It's probably nothing but: I did an ios build with the clear-provisioning-profile flag as I enabled universal links on a recent build.

@sjchmiela
Copy link
Contributor

Hey @hardcodet!

  1. I'm not sure if doing an iOS build with a new provisioning profile would affect this or not, sorry. 😕 If the new provisioning profile has push notifications enabled… it should work…

  2. Regarding Promise taking a long time to fulfil — from my experience and from Internet's experience:

    • it may take a long time if there are problems with Internet connection as per this SO answer

      iOS Note: If a cellular or Wi-Fi connection is not available, neither the application:didRegisterForRemoteNotificationsWithDeviceToken: method nor the application:didFailToRegisterForRemoteNotificationsWithError: method is called. For Wi-Fi connections, this sometimes occurs when the device cannot connect with APNs over port 5223. If this happens, the user can move to another Wi-Fi network that isn’t blocking this port or, on an iPhone or iPad, wait until the cellular data service becomes available. In either case, the device should be able to make the connection, and then one of the delegation methods is called.

    • sometimes APNS is down and the callbacks (and thus Promise) are not called, as per this Developer Forums thread

    • sometimes this may be a problem with Internet connection being shared with a computer, according to this SO answer

    • here's a detailed technical description on how to debug why aren't the callbacks called

    • according to this SO answer it may fail if provisioning profile doesn't have push notifications capability enabled

    • there's a tip to restart the device when moving between sandbox and production APNS

    • here's a recommendation to setup the device with a SIM card if it hasn't been done.

I hope any of the tips may end up helpful to you. 🤗

@hardcodet
Copy link
Author

Hi there Stanislaw

Thanks for taking the time to put all this together! The device in question at some point started working again after a few releases (no code changes around the push notification tokens though), and I haven't seen the issue again. It can't have been a temporary connectivity issue though, since it reliably failed over a long period of times (we're talking days here).

Since it's working now, I can't really help in diagnosing this, I'm afraid. The only thing that caught my eye was the (slightly mysterious ;) tip about the SIM card since the test device doesn't have one. But that still wouldn't explain why it resumed working at some point as if nothing ever happened.

Feel free to close this issue for now - I can post again if the issue creeps back in with a subsequent release.

Thanks again!

@sjchmiela
Copy link
Contributor

Hey, thank you for responding! I'm glad it's sorted out now! I'll let myself close this issue with a pull request adding information on different situations which may impact push token retrieval to a new docs section "Common gotchas / known issues" in a second! 🙂

PS. Yeah, I agree the SIM card tip is a bit mysterious. 😃

sjchmiela added a commit that referenced this issue Nov 9, 2020
…mises taking a long time to finish (#10845)

# Why

Maybe could have preveted, fixes #10369, fixes does not #10831.

# How

Added a draft of a "gotcha" section on why do `get*PushTokenAsync` take a long time to fulfil.

# Test Plan

None.
@devcoderbuzz
Copy link

The below single line is creating a problem.

token = (await Notifications.getExpoPushTokenAsync()).data; with the below.
I am using expo 44:
Exception is :: [Error: No experienceId or projectId found. If one or the other can't be inferred from the manifest (eg. in bare workflow), you have to pass one in yourself.]

@pors
Copy link

pors commented Aug 22, 2022

The below single line is creating a problem.

token = (await Notifications.getExpoPushTokenAsync()).data; with the below. I am using expo 44: Exception is :: [Error: No experienceId or projectId found. If one or the other can't be inferred from the manifest (eg. in bare workflow), you have to pass one in yourself.]

I got the same error, using managed workflow. Did you find the cause @devcoderbuzz ?

@TheRealMikeD
Copy link

@devcoderbuzz and @pors, I am getting the same error. Searching for an explanation. Expo 46.

@pors
Copy link

pors commented Sep 2, 2022

@TheRealMikeD I'm also on SDK 46. I only have the problem with a development build, not with TestFlight. So I choose to ignore it. Notifications work fine on TF.

@TheRealMikeD
Copy link

@pors, thanks - that's good to know. I actually found a usable workaround for this issue in the dev environment, which I posted here: #18570 (comment)

@appsgenie
Copy link

same issue here with SDK 46 when trying out a development build..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
iOS needs validation Issue needs to be validated Notifications
Projects
None yet
8 participants