Ask for permissions on demand

Insted of ask for notification and geolocalization permissions after the app starts, ask for permission on demand.

By doing this I can explain to user why my app need this feature, increasing permission acceptance.

Yes please this is what I mentioned a while back. but now that I think about it, perhaps each API that needs OS permission should have a requestPermission method that returns a resolved promise if request is allowed and rejects if denied:

var GeoLocation = require('GeoLocation');

GeoLocation.requestPermission().then(function() {
  // do something
});

and then let’s say in some other context if this happens:

var GeoLocation = require('GeoLocation');

// this will throw with some error saying something about the permission was denied, and if permission was granted then it'll resolve.
GeoLocation.getLocation().then(function() {
  // do something
}).catch(function(err) {
 // handle err
});

After using some cordova plugins, I think we need a Init method instead of a requestPermission. That method will request the permission if it’s not granted yet.

And another method to check if we had the permission.

I think a requestPermission is better that way you have a way of handling the permission directly, if its not granted, and the other methods would reject if not granted.

Yea agree with the other method of checking.

GeoLocation.getPermissionStatus().then(function(status) {
    // status: ['granted', 'denied', 'pending']
});

Plus with init can’t tell what init means naming wise

This is different between iOS, Android and all the versions of them. With those methods it will only work cross platform in some cases. But I guess that is better than nothing. We are going to do some cleanup on the GeoLocation package so I will see what we can do when we get to it. I will link in this post to the ticket so feel free to keep the discussion going.

BTW the GeoLocation was only an example, we’re talking about for all APIs that request OS permission, like geolocation, camera, notifications etc

Yes, for all APIs. Camera, notification, geolocation etc.

Yes, we should probably make a general abstraction for those kind of apis.