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.

Failed to grant permission ios 10.3.1

See original GitHub issue

i am trying to use this code in iOS 10.3.1 but gettint error of failed to grant permissions:

componentDidMount(){
 if(Platform.OS === 'ios'){
   FCM.requestPermissions({badge: false, sound: true, alert: true});
      try {
        console.log("[Push] requestPermissions");
        const values = await FCM.requestPermissions({badge: false, sound: true, alert: true});
        console.log(values);
      } catch(err){
        console.log("[Push] requestPermissions error: " + err);
        return;
      }
 }
}

simulator screen shot 04-sep-2017 12 52 01 pm

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:28 (12 by maintainers)

github_iconTop GitHub Comments

2reactions
jeroenbourgoiscommented, Sep 22, 2017

@natashache like @evollu says, the actual OS (on iOS) modal is only shown once, after that it returns the choice the user made; being acknowledged or rejected the notifications. In the code, you can dispatch the requestPermissions Promise. It will only resolve when the user accepted the permissions, it will reject if the user denied.

In our code, we handle it this way:

// on a specific 'why notifications' screen
FCM.requestPermissions()
      .then(e => dispatch(turnOnPushNotifications()))
      .catch(() => dispatch(turnOffPushNotifications()))
 
// in a 'notification controller' which listens to AppState changes and on ComponentDidMount
PushNotificationIOS.checkPermissions(
    (permissions: IOsPermissionState) => {
      if (permissions.alert === 1 || permissions.badge === 1 || permissions.sound === 1) {
        dispatch(turnOnPushNotifications())
      } else {
        dispatch(turnOffPushNotifications())
      }
    })

For now we only handle the iOS part since our Android app is not targeted for runtime notifications. This might change soon though… I hope this helps!

0reactions
natashachecommented, Sep 23, 2017

Thanks @evollu @jeroenbourgois. After adding the catch block the warning is no longer showing and the notifications (mysteriously) started coming in. Let’s hope it stays that way.

Read more comments on GitHub >

github_iconTop Results From Across the Web

iOS 10.3.2 Beta 1 won't allow me t… | Apple Developer Forums
iOS 10.3.2 Beta 1 won't allow me to connect to internet using safari, vpn, email, even the software update has an error itself....
Read more >
What's new in the iOS client | Microsoft Learn
This new feature fixes an issue in Windows 11 remote sessions that caused the screen to flicker, making the session unusable. Updates for ......
Read more >
Request Permission for Camera and Library in iOS 10 - Info.plist
If access is allowed, then the code onAccessHasBeenGranted will be run. · If access is not determined, then requestAuthorization(_:) will be called. ·...
Read more >
Known issue - Upload widget not working for videos in iOS 10.3
We tried different workarounds but were not able to read the video files because the access is always blocked to the WebView.
Read more >
Troubleshoot—ArcGIS Online Help | Documentation
If you have a public account, you can access Esri Community and ArcGIS Blog. ... My web map contains a layer that is...
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