Guest User

Untitled

a guest
Mar 21st, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.81 KB | None | 0 0
  1. import { Permissions } from 'expo'
  2.  
  3. export default async function verifyPushNotificationsPermissions() {
  4. const { status: existingStatus } = await Permissions.getAsync(Permissions.NOTIFICATIONS)
  5. let finalStatus = existingStatus
  6.  
  7. // only ask if permissions have not already been determined, because
  8. // iOS won't necessarily prompt the user a second time.
  9. if (existingStatus !== 'granted') {
  10. // Android remote notification permissions are granted during the app
  11. // install, so this will only ask on iOS
  12. const { status } = await Permissions.askAsync(Permissions.NOTIFICATIONS)
  13. finalStatus = status
  14. }
  15. if (finalStatus === 'undetermined') {
  16. console.log('Cannot use push notifications on simulator')
  17. }
  18. // Stop here if the user did not grant permissions
  19. if (finalStatus !== 'granted') {
  20. return
  21. }
  22. }
Add Comment
Please, Sign In to add comment