Comments (12)
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.
from cordova-plugin-android-permissions.
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.
from cordova-plugin-android-permissions.
Thanks for the info on the success object. But when I try this out on an Android 6.0.1 device I do not get any prompt when I use the .requestPermission method.
Any idea why is that?
from cordova-plugin-android-permissions.
@brentmitch I already tried that hasPermission always returns success on android 6.0.1.
from cordova-plugin-android-permissions.
Permission popup does not even show
from cordova-plugin-android-permissions.
@oggyman my target sdk version is 25 still no permission requesting popup shows up and it always returns success but when i check in settings permissions are not granted
from cordova-plugin-android-permissions.
Same problem here!
from cordova-plugin-android-permissions.
Only the permissions that are listed in AndroidManifest.xml will be called.
from cordova-plugin-android-permissions.
I get the same problem here. I always get the success callback, no popup is shown up on my test device (android 7.0).
@marcelo-ribeiro all permissions are listed in AndroidManifest.xml too but it doesn't work.
[UPDATE] Currently, I have to ignore the 'checkPersmission' function and using 'requestPermissions' directly,
from cordova-plugin-android-permissions.
@xuantruong2k use cordova diagnostic plugin to request and check permissions for both ios and android
from cordova-plugin-android-permissions.
Could you check which cordova-android version you are using?
The build tools in earlier cordova-android version maybe too old. It might can let you build an app and run on new platform, but some functions of that app might have compatible issues.
If you are asking 'normal' permissions, it will always returns you success.
https://developer.android.com/guide/topics/permissions/normal-permissions.html
At last,
this.androidPermissions.PERMISSION.READ_EXTERNAL_STORAGE
seems should be
this.androidPermissions.READ_EXTERNAL_STORAGE
Could you help me to check that?
from cordova-plugin-android-permissions.
I was able to get this to work with the following code (except, in my case, I was requesting permission to use the camera):
openCameraWithPermission = function(successCallback, failureCallback) {
var action = this.openCamera;
$ionicPlatform.ready(function() {
var cordovaPermissions = cordova.plugins.permissions;
var permission = cordovaPermissions.CAMERA;
cordovaPermissions.checkPermission(permission, function(status) {
if (status.hasPermission) {
action(successCallback, failureCallback);
}
else {
cordovaPermissions.requestPermission(
permission,
function(status) {
if(status.hasPermission) {
action(successCallback, failureCallback);
}
else {
failureCallback('This app does not have permission to access the camera. Please enable camera access via your device settings');
}
},
function() {
failureCallback('This app does not have permission to access the camera. Please enable camera access via your device settings');
});
}
});
});
};
I also needed to add the relevant permissions to platforms/android/AndroidManifest.xml.
from cordova-plugin-android-permissions.
Related Issues (20)
- Fix bug HOT 1
- NFC permissions Not Working HOT 1
- Cordova Permissions not working Quasar HOT 1
- Any way to "Predict" if User will be prompted for Permission? HOT 3
- How can i check `MANAGE_EXTERNAL_STORAGE`(all file access) in android? HOT 7
- BLUETOOTH_CONNECT permission missing in permissions.js HOT 2
- Background Location permission issue HOT 5
- BLUETOOTH_CONNECT + BLUETOOTH_SCAN missing for Android +10 HOT 4
- plugins/cordova-plug…w/permissions.js:38 Uncaught SyntaxError: Unexpected token ':' HOT 1
- Support Android 13 (API 33) HOT 5
- BLUETOOTH_SCAN doesn't show confirm dialog to the user HOT 4
- Android 13 SDK 33 - no dialog HOT 5
- uses-feature and camera request in Ionic 6 HOT 3
- POST_NOTIFICATION not working HOT 15
- Camera permission is not turned on?? HOT 1
- android build faild HOT 1
- Permissions not popping up HOT 8
- Storage permission not showing up HOT 2
- BSF Cordova Ecosystem Crowdfunding Plan HOT 2
- POST_NOTIFICATIONS don't work for Android 10 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cordova-plugin-android-permissions.