Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import { Permissions } from 'expo'
- export default async function verifyPushNotificationsPermissions() {
- 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
- }
- if (finalStatus === 'undetermined') {
- console.log('Cannot use push notifications on simulator')
- }
- // Stop here if the user did not grant permissions
- if (finalStatus !== 'granted') {
- return
- }
- }
Add Comment
Please, Sign In to add comment