Check permission Always return success
See original GitHub issueI 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:
- Created 6 years ago
- Reactions:4
- Comments:12 (1 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
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
orhasPermission: 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.
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.