Skip to content
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

feat: Permissions API #1828

Merged
merged 16 commits into from
Aug 7, 2019
Merged

feat: Permissions API #1828

merged 16 commits into from
Aug 7, 2019

Conversation

mlynch
Copy link
Contributor

@mlynch mlynch commented Jul 30, 2019

This adds a new API called Permissions that lets a developer check if certain permissions have been granted yet before requesting them.

It largely follows the Permissions API in the browser.

Examples:

  async checkCamera() {
    const has = await Plugins.Permissions.query({ name: PermissionType.Camera });
  }

  async checkPhotos() {
    const has = await Plugins.Permissions.query({ name: PermissionType.Photos });
  }

  async checkGeo() {
    const has = await Plugins.Permissions.query({ name: PermissionType.Geolocation });
  }

  async checkPush() {
    const has = await Plugins.Permissions.query({ name: PermissionType.PushNotifications });
  }

Also couldn't help myself and fixed bug in the Geolocation API for Android where calling requestPermissions would cause the requestPermissions call to return over and over again, which really should only happen when the requestPermission called happened on watchPosition. I don't think this method is really used anyways

Also fixed a bug in Camera where it was creating the image picker on a background thread

@mlynch mlynch requested a review from jcesarmobile July 30, 2019 20:46
Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added two suggestions, will apply them

site/docs-md/apis/permissions/index.md Outdated Show resolved Hide resolved
ios/Capacitor/Capacitor/Plugins/Permissions.swift Outdated Show resolved Hide resolved
Copy link
Member

@jcesarmobile jcesarmobile left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a few changes, but I'll make them

ios/Capacitor/Capacitor/Plugins/DefaultPlugins.m Outdated Show resolved Hide resolved
@@ -1,6 +1,6 @@
import { Component, NgZone } from '@angular/core';
import { DomSanitizer, SafeResourceUrl } from '@angular/platform-browser';
import { IonicPage, NavController, NavParams } from 'ionic-angular';
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
import { IonicPage, NavController, NavParams, AlertController } from 'ionic-angular';
import { IonicPage, NavController, NavParams } from 'ionic-angular';

remove unused AlertController

constructor(public navCtrl: NavController,
public navParams: NavParams,
private zone: NgZone,
private sanitizer: DomSanitizer,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private sanitizer: DomSanitizer,

public navParams: NavParams,
private zone: NgZone,
private sanitizer: DomSanitizer,
private alertCtrl: AlertController) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
private alertCtrl: AlertController) {

@jcesarmobile jcesarmobile changed the title Permissions API feat: Permissions API Aug 1, 2019
@ionic-team ionic-team deleted a comment Aug 7, 2019
@mlynch mlynch merged commit ee8f63a into master Aug 7, 2019
@mlynch mlynch deleted the permissions-api branch August 7, 2019 17:12
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

Successfully merging this pull request may close these issues.

2 participants