Skip to content

requestPermission fires error callback without any reason #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
vladoski opened this issue Jun 20, 2020 · 2 comments
Open

requestPermission fires error callback without any reason #86

vladoski opened this issue Jun 20, 2020 · 2 comments

Comments

@vladoski
Copy link

Hello guys, I'm tring to manage location permissions on my PhoneGap app using this plugin.
The problem is that I don't understand why error is being fired.

First, when I'm opening my app after my first install, requestPermission is being called so the grant location permission popup opens on the screen, the problem is that after some ms, the error callback is fired by the requestPermission and I don't know understand why error (and why there's no error message) should be fired before even denying nor granting the permission.
I've also tried to do what this guy suggested in #84 but didn't work.

error.error is 'Unknown error.'

This is what I'm doing:

function noPermissionGranted() {
	alert('This app requires your location to be used');
	navigator.app.exitApp();
}

document.addEventListener('deviceready', e => {
	cordova.plugins.permissions.checkPermission(cordova.plugins.permissions.ACCESS_FINE_LOCATION, checkStatus => {
		if (!checkStatus.hasPermission) {
			cordova.plugins.permissions.requestPermission(cordova.plugins.permissions.ACCESS_FINE_LOCATION, requestStatus => {
				console.log('hasPermission: ' + requestStatus.hasPermission);
				if (!requestStatus.hasPermission) {
					noPermissionGranted();
				} else {
					replace('/');
				}
			}, (error) => {
				console.log(error.error);
				console.log(error.message);
				noPermissionGranted();
			});
		}
	});
});

And this is my config.xml android:

<platform name="android">
    <access origin="*" />
    <allow-navigation href="*" />
    <allow-intent href="market:*" />
    <config-file after="uses-permission" parent="/manifest" target="AndroidManifest.xml">
        <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
    </config-file>
</platform>
@vladoski
Copy link
Author

I've tried the app using API level 28 and it works (29 doesn't).

@davidquon
Copy link

I'm having the same issue. I tried isolating it down just asking for one permission at a time but it seems to error regardless.
#88 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants