Giter Site home page Giter Site logo

Comments (12)

brentmitch avatar brentmitch commented on July 20, 2024 8

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.

denys-glu avatar denys-glu commented on July 20, 2024 1

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.

prantikv avatar prantikv commented on July 20, 2024

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.

asadwaheed1 avatar asadwaheed1 commented on July 20, 2024

@brentmitch I already tried that hasPermission always returns success on android 6.0.1.

from cordova-plugin-android-permissions.

asadwaheed1 avatar asadwaheed1 commented on July 20, 2024

Permission popup does not even show

from cordova-plugin-android-permissions.

asadwaheed1 avatar asadwaheed1 commented on July 20, 2024

@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.

luchusnet avatar luchusnet commented on July 20, 2024

Same problem here!

from cordova-plugin-android-permissions.

marcelo-ribeiro avatar marcelo-ribeiro commented on July 20, 2024

Only the permissions that are listed in AndroidManifest.xml will be called.

from cordova-plugin-android-permissions.

xuantruong2k avatar xuantruong2k commented on July 20, 2024

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.

asadwaheed1 avatar asadwaheed1 commented on July 20, 2024

@xuantruong2k use cordova diagnostic plugin to request and check permissions for both ios and android

from cordova-plugin-android-permissions.

NeoLSN avatar NeoLSN commented on July 20, 2024

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.

CodeTectonics avatar CodeTectonics commented on July 20, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.