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.

Check permission Always return success

See original GitHub issue

I used checkPermission method but its always returning success even when permission is not granted. Here’s my code:

CheckPermissions(data) { this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then( success => { console.log('Permission already granted'); this.playVideo(data); }, err => console.log('Cannot check for permission')); }

What am i missing?

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:4
  • Comments:12 (1 by maintainers)

github_iconTop GitHub Comments

8reactions
brentmitchcommented, Aug 24, 2017

You aren’t checking the result in the success callback.

The success callback of the checkPermission() method returns an object that looks like: hasPermission: true or hasPermission: false

Try changing your code like this:

CheckPermissions(data) { this.androidPermissions.checkPermission(this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE).then( success => { if (success.hasPermission){ console.log('Permission already granted'); this.playVideo(data); } else { console.log('Permission not already granted'); } }, err => console.log('Cannot check for permission')); }

You might also want to rename the ‘success’ variable to something like ‘result’ or ‘data’ to make the code a bit easier to read.

1reaction
denys-glucommented, Aug 25, 2017

what is your target SDK in config.xml? if it is 23, then popup window, will never show up, but permissions will granted, and if you will change to 24 and up, the popup window should appear.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android M - check runtime permission - how to determine if the ...
shouldShowRequestPermissionRationale(String) method. This method returns true if the app has requested this permission previously and the user ...
Read more >
Request app permissions - Android Developers
... Tag expressions · Language settings · Always-on in Watch Face Studio ... Activity state changes · Test your app's activities · Tasks...
Read more >
[Android] Permission Request resolves immediately · Issue #71
The promise when requesting the permission status / request always immediately resolves without waiting for the user input.
Read more >
PermissionsAndroid - React Native
Returns a promise resolving to a boolean value as to whether the specified permissions has been granted. Parameters: Name, Type, Required ...
Read more >
FeatureManagement.checkPermission not returning expected ...
debug always returns false. The full code of the class is below: global class BlockLargeDataExportEventConditionPERM implements TxnSecurity.
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