When a user visits the dashboard of my app I would like to show a prompt asking for permission for push notifications. I assumed the following code would do just that, what I find instead is that the dialog asking for permission never shows and the status is resolved as ‘granted’.
Is there some setting (maybe in app.json
) that I need to set to show the permission dialog?
if (existingStatus !== "granted") {
const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS);
finalStatus = status;
expoToken = await Notifications.getExpoPushTokenAsync();
user.pushNotificationTokens = user.pushNotificationTokens ? user.pushNotificationTokens : []
user.pushNotificationTokens = [...user.pushNotificationTokens, expoToken];
const savedUser = await this.saveAthlete(user)
}
Thank you for any insight.
Best,
Zach