I’m not sure when it started, but sometime over the last month or two some fresh installs on iOS are hanging on getPushTokenAsync(). It looks like it’s because getAsync incorrectly returns “granted” when it’s not granted on a fresh installation.
This is happening on an iPad 2 I’m testing, both with a fresh standalone IPA installation and with a completely fresh install of the Expo client (so no permissions granted yet). Latest Expo client version today.
My app calls getPushTokenAsync() below. Somehow getAsync(Permissions.NOTIFICATIONS) returns “granted”! Then lower down the function, Notifications.getExpoPushTokenAsync() errors with “Error: This app does not have permission to show notifications”.
Anyone else seen this?
export default (async function getPushTokenAsync() {
// Remote notifications do not work in simulators, only on device
if (!Constants.isDevice) {
return null;
}
// Get current notification permissions status
const { status: existingStatus } = await Permissions.getAsync(
Permissions.NOTIFICATIONS
);
let finalStatus = existingStatus;
// only ask if permissions have not already been determined, because
// iOS won't necessarily prompt the user a second time.
if (existingStatus !== "granted") {
// Android remote notification permissions are granted during the app
// install, so this will only ask on iOS
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
}
// Stop here if the user did not grant permissions
if (finalStatus !== "granted") {
return null;
}
// Get the token that uniquely identifies this device
let token = await Notifications.getExpoPushTokenAsync();
// Return the token
return token;
});