Comments (10)
@kristopolous , I am using this plugin and when I select the "Deny" option, the app just gets closed/crashed.
Am I missing anything?
from cordova-plugin-android-permissions.
I'm not here for solution but, isn't it natural to have success callback if requestPermission has been called successfully?
If you want to check whether the permission had been granted, we have hasPermission (as you already know).
from cordova-plugin-android-permissions.
Is the value of p.hasPermission
false if a user decided not to grant the permission?
from cordova-plugin-android-permissions.
Quoting: https://developer.android.com/training/permissions/requesting.html
When the system asks the user to grant a permission, the user has the option of telling the system not to ask for that permission again. In that case, any time an app uses requestPermissions() to ask for that permission again, the system immediately denies the request. The system calls your onRequestPermissionsResult() callback method and passes PERMISSION_DENIED, the same way it would if the user had explicitly rejected your request again. This means that when you call requestPermissions(), you cannot assume that any direct interaction with the user has taken place.
What this means is that this use-case could be valid under those conditions. I however, believe it's happening in more than just this instance ... let me get back with a confirmation soon.
from cordova-plugin-android-permissions.
Also, this doesn't preclude including things in the manifest in addition to asking explicitly. Quoting the same link above:
On all versions of Android, your app needs to declare both the normal and the dangerous permissions it needs in its app manifest, as described in Declaring Permissions
from cordova-plugin-android-permissions.
So for me at least, after manually adding this line to my AndroidManifest.xml
(for in this case camera, since this seems to be the big pain point)
<uses-permission android:name="android.permission.CAMERA" />
And then rebuilding, I can
- request the permission multiple times
- get the fail case if I tick "never ask again".
This appears to be the right result. This is with
<plugin name="cordova-plugin-camera" spec="~2.3.0" />
There is a PR that is outstanding that will do this: apache/cordova-plugin-camera#228 ... once that closes this probably doesn't need to be done any more.
Until then it looks like this is needed. Bummer...
from cordova-plugin-android-permissions.
As far as detecting if the user had done the "never ask again" option probably the only feasible way to do it (since android doesn't tell you) would be something heuristic like this:
var beforeRequest = new Date();
window.cordova.plugins.permissions.requestPermission(
window.cordova.plugins.permissions.CAMERA, function(m) {
if(!m.hasPermission && (new Date() - beforeRequest) < 350) {
// 350 ms is pretty fast for a user to tap on a deny ... and even if they did
// this is probably a user error and we should pretend like they didn't see it.
// either way this should be handling as if the dialog never appeared.
// In *my* user testing on a moto 3g 2015, I couldn't tap this dialog with a value
// less than 554 -and that was with a sincere effort to dismiss it as soon as possible
// as if it was a game. This implicates there's likely a significant overhead baked in
// before the dialog even appears
...
}
}, null);
from cordova-plugin-android-permissions.
@NeoLSN - "Is the value of p.hasPermission false if a user decided not to grant the permission?"
Yes it is false even when the dialog is ignored.
from cordova-plugin-android-permissions.
When user clicks Deny
my app just crashes.
from cordova-plugin-android-permissions.
cordova plugin does not fire a failure or success callback when requestPermission() is called on the very first install of the apk via USB cable or on emulator or from installing an APK build from disk. It does pop the dialog to request geo permissions fine, I grant it, but it never fires a callback. (?)
When i close the app and reopen, geolocation works, because i previously granted. But on very first install, callbacks for requestPermission() does nothing, so app is at standstill. Does anyone know what it could be? Tried on several phones, all identical behavior.
USING window.cordova.plugins:
requestCordovaPermissions() {
var self = this;
window.cordova.plugins.permissions.requestPermission(
window.cordova.plugins.permissions.ACCESS_FINE_LOCATION,
function(status) {// <-------never fired
if (status.hasPermission) {
alert("permission granted") _ //never seen, even if i granted_
} else {
alert("unable to get geo location permissions")
}
},
function(e) {//<------ never fired
alert("Error : " + e)
}
)
}
Snippet from AndroidManifest.xml:
`
<supports-screens android:anyDensity="true" android:largeScreens="true" android:normalScreens="true" android:resizeable="true" android:smallScreens="true" android:xlargeScreens="true" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_LOCATION_EXTRA_COMMANDS" />
<uses-permission android:name="android.permission.ACCESS_MOCK_LOCATION" />
<uses-sdk android:minSdkVersion="16" android:targetSdkVersion="25" />
<application android:hardwareAccelerated="true" android:icon="@mipmap/icon" android:label="@string/app_name" android:supportsRtl="true">
<activity android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale" android:label="@string/activity_name" android:launchMode="singleTop" android:name="MainActivity" android:screenOrientation="portrait" android:theme="@android:style/Theme.DeviceDefault.NoActionBar" android:windowSoftInputMode="adjustResize">
<intent-filter android:label="@string/launcher_name">
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
`
config.xml:
`
<feature name="Geolocation">
<param name="android-package" value="org.apache.cordova.GeoBroker" />
</feature>
<engine name="android" spec="^6.3.0" />
<plugin name="cordova-plugin-android-permissions" spec="^1.0.0" />
<plugin name="cordova-plugin-exclude-files" spec="^0.4.2" />
<plugin name="cordova-plugin-fullscreen" spec="^1.2.0" />
<plugin name="cordova-plugin-geolocation" spec="^4.0.1" />
<plugin name="cordova-plugin-whitelist" spec="^1.3.3" />
`
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.