# Ask for permissions on demand

**URL:** <https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807>\
**Category:** Feature Suggestions\
**Created:** [July 19, 2016, 2:04am UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807 "2016-07-19T02:04:27Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![raphael.godoi](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/raphael.godoi/32/312_2.png) [@raphael.godoi](https://forums.fusetools.com/u/raphael.godoi)\
**Post date:** [July 19, 2016, 2:04am UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807/1 "2016-07-19T02:04:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Edwin\_Reynoso](https://avatars.discourse-cdn.com/v4/letter/e/e99b99/32.png) [@Edwin\_Reynoso](https://forums.fusetools.com/u/Edwin_Reynoso)\
**Post date:** [July 19, 2016, 5:42am UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807/2 "2016-07-19T05:42:51Z")

</div>

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:

```javascript
var GeoLocation = require('GeoLocation');

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

```

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

```javascript
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
});

```

---

<div class="post-metadata">

**Author:** ![raphael.godoi](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/raphael.godoi/32/312_2.png) [@raphael.godoi](https://forums.fusetools.com/u/raphael.godoi)\
**Post date:** [July 19, 2016, 12:36pm UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807/3 "2016-07-19T12:36:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Edwin\_Reynoso](https://avatars.discourse-cdn.com/v4/letter/e/e99b99/32.png) [@Edwin\_Reynoso](https://forums.fusetools.com/u/Edwin_Reynoso)\
**Post date:** [July 19, 2016, 6:44pm UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807/4 "2016-07-19T18:44:33Z")

</div>

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.

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

```

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

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [July 20, 2016, 10:06am UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807/5 "2016-07-20T10:06:47Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Edwin\_Reynoso](https://avatars.discourse-cdn.com/v4/letter/e/e99b99/32.png) [@Edwin\_Reynoso](https://forums.fusetools.com/u/Edwin_Reynoso)\
**Post date:** [July 20, 2016, 2:06pm UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807/6 "2016-07-20T14:06:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![raphael.godoi](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/raphael.godoi/32/312_2.png) [@raphael.godoi](https://forums.fusetools.com/u/raphael.godoi)\
**Post date:** [July 21, 2016, 12:07am UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807/7 "2016-07-21T00:07:44Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Anders\_Bondehagen](https://yyz1.discourse-cdn.com/flex035/user_avatar/forums.fusetools.com/anders_bondehagen/32/98_2.png) [@Anders\_Bondehagen](https://forums.fusetools.com/u/Anders_Bondehagen)\
**Post date:** [July 26, 2016, 8:28am UTC](https://forums.fusetools.com/t/ask-for-permissions-on-demand/5807/8 "2016-07-26T08:28:00Z")

</div>

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