question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Permissions.askAsync never resolves on iOS Standalone app

See original GitHub issue

With out recent app release, we have found an apparent bug in Expo in the standalone app which caused Apple to reject the submission. It turns out that the Pemissions.askAsync is often not resolving the promise when the user clicks “Allow” or “Don’t Allow” on the native dialog popup.

We were able to resolve this in two ways:

  • Change the screen automatically in the background and don’t wait for a resolved response.
  • Use a timeout around the permissions dialog (calling Permissions.getAsync to attempt to get the response).

Ensure the promise resolved with a timeout:

Note: You should probably not let the UI wait for this response.

    askNotificationPermissions_withTimeout = () => {
        // NOTE: Permissions.askAsync seems to never resolve sometimes, so using a timeout to check status

        return new Promise((resolve, reject) => {
            const timeoutId = setTimeout(async () => {
                const { status } = await Permissions.getAsync(
                    Permissions.NOTIFICATIONS
                );
                resolve(status === 'granted');
            }, 5000);

            const promise = Permissions.askAsync(
                Permissions.NOTIFICATIONS
            );

            promise.then(r => {
                clearTimeout(timeoutId);

                const { status } = r;
                resolve(status === 'granted');
            });
        });

    };

Context

  • Expo SDK 24.0.0
  • iOS Standalone

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:37 (9 by maintainers)

github_iconTop GitHub Comments

10reactions
ramshamushtaqcommented, Apr 8, 2018

Hi, we just ran into the same issue with the latest version of Expo. Here are the steps to reproduce the issue:

  1. Ask the user for notifications permissions using askAsync
  2. Allow notification permissions
  3. Go to Expo settings and turn off notifications permissions
  4. Ask the user for notifications permissions again using askAsync

At that point, the app hangs waiting for the promise askAsync returns to resolve.

5reactions
joraniedemagitcommented, Aug 16, 2019

@brentvatne @bbarthec just to note: this issue was re-introduced in 'expo-permissions' (at least 6.0.0).

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo 29.0 on iOS is no longer resolving Permissions.askAsync ...
In Expo 29.0 SDK it appears that the NOTIFICATIONS permission does not ... The above code never resolves in a stand alone iOS...
Read more >
Permissions.askAsync(Permissions.CAMERA) always denied ...
I have encountered a similar problem with the expo-av microphone permissions. In the expo client the permissions work flawlessly but when I ...
Read more >
How to use the expo-permissions.NOTIFICATIONS function in ...
To help you get started, we've selected a few expo-permissions. ... Android remote notification permissions are granted during the app // install, ...
Read more >
Expo SDK 41 - DEV Community ‍ ‍
If you built a standalone app previously, remember that you'll need to create a new build in order to update the SDK version....
Read more >
react-native-permissions - npm
An unified permissions API for React Native on iOS, Android and Windows ... If your company uses it in a production app, consider...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found