From 4cd1bc02966cf203ccf5c802e5b36c8dfb694bec Mon Sep 17 00:00:00 2001 From: Flavien VACCARETTI Date: Mon, 8 Jun 2020 02:33:38 +0200 Subject: [PATCH 1/4] ADD Microphone permission --- .../com/getcapacitor/plugin/Permissions.java | 6 ++++++ core/src/core-plugin-definitions.ts | 3 ++- .../Capacitor/Plugins/Permissions.swift | 20 +++++++++++++++++++ 3 files changed, 28 insertions(+), 1 deletion(-) diff --git a/android/capacitor/src/main/java/com/getcapacitor/plugin/Permissions.java b/android/capacitor/src/main/java/com/getcapacitor/plugin/Permissions.java index 59ae8e20e..61583c8e6 100644 --- a/android/capacitor/src/main/java/com/getcapacitor/plugin/Permissions.java +++ b/android/capacitor/src/main/java/com/getcapacitor/plugin/Permissions.java @@ -37,6 +37,8 @@ public void query(PluginCall call) { case "clipboard-read": case "clipboard-write": checkClipboard(call); + case "microphone": + checkMicrophone(call); break; default: call.reject("Unknown permission type"); @@ -80,4 +82,8 @@ private void checkClipboard(PluginCall call) { call.resolve(ret); } + private void checkMicrophone(PluginCall call) { + checkPerm(Manifest.permission.RECORD_AUDIO, call); + } + } diff --git a/core/src/core-plugin-definitions.ts b/core/src/core-plugin-definitions.ts index 94907eab6..115383460 100644 --- a/core/src/core-plugin-definitions.ts +++ b/core/src/core-plugin-definitions.ts @@ -1348,7 +1348,8 @@ export enum PermissionType { Geolocation = 'geolocation', Notifications = 'notifications', ClipboardRead = 'clipboard-read', - ClipboardWrite = 'clipboard-write' + ClipboardWrite = 'clipboard-write', + Microphone = 'microphone' } export interface PermissionsOptions { diff --git a/ios/Capacitor/Capacitor/Plugins/Permissions.swift b/ios/Capacitor/Capacitor/Plugins/Permissions.swift index 5ab819fe7..1e789b735 100644 --- a/ios/Capacitor/Capacitor/Plugins/Permissions.swift +++ b/ios/Capacitor/Capacitor/Plugins/Permissions.swift @@ -25,6 +25,8 @@ public class CAPPermissionsPlugin: CAPPlugin { return checkClipboard(call) case "photos": return checkPhotos(call) + case "microphone": + return checkMicrophone(call) default: return call.reject("Unknown permission type") } @@ -108,4 +110,22 @@ public class CAPPermissionsPlugin: CAPPlugin { "state": "granted" ]) } + + func checkMicrophone(_ call: CAPPluginCall) { + let microStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeAudio) + + var ret = "prompt" + switch (microStatus) { + case .Authorized: + ret = "granted" + case .Denied .Restricted: + ret = "denied" + case .NotDetermined: + ret = "prompt" + } + + call.resolve([ + "state": ret + ]) + } } From f5fe0a0c1a569ac6776b285ccf4a1031ad7fc40a Mon Sep 17 00:00:00 2001 From: Flavien VACCARETTI Date: Mon, 8 Jun 2020 02:42:16 +0200 Subject: [PATCH 2/4] ADD doc microphone permission --- site/src/assets/docs-content/apis/permissions/api.html | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/site/src/assets/docs-content/apis/permissions/api.html b/site/src/assets/docs-content/apis/permissions/api.html index dc5267a80..5fee38b58 100644 --- a/site/src/assets/docs-content/apis/permissions/api.html +++ b/site/src/assets/docs-content/apis/permissions/api.html @@ -126,5 +126,12 @@

PermissionType

"photos" + +
+
+
Microphone: + "microphone" +
+
} \ No newline at end of file From 4a6fbe34650e8a0cf04cf5dbccaac02602bc3e10 Mon Sep 17 00:00:00 2001 From: Flavien VACCARETTI Date: Mon, 8 Jun 2020 04:17:16 +0200 Subject: [PATCH 3/4] FIX ios Microphone permission --- ios/Capacitor/Capacitor/Plugins/Permissions.swift | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/ios/Capacitor/Capacitor/Plugins/Permissions.swift b/ios/Capacitor/Capacitor/Plugins/Permissions.swift index 1e789b735..97b3ef419 100644 --- a/ios/Capacitor/Capacitor/Plugins/Permissions.swift +++ b/ios/Capacitor/Capacitor/Plugins/Permissions.swift @@ -112,16 +112,16 @@ public class CAPPermissionsPlugin: CAPPlugin { } func checkMicrophone(_ call: CAPPluginCall) { - let microStatus = AVCaptureDevice.authorizationStatusForMediaType(AVMediaTypeAudio) + let microStatus = AVCaptureDevice.authorizationStatus(for: .audio) var ret = "prompt" switch (microStatus) { - case .Authorized: - ret = "granted" - case .Denied .Restricted: - ret = "denied" - case .NotDetermined: - ret = "prompt" + case .authorized: + ret = "granted" + case .denied, .restricted: + ret = "denied" + case .notDetermined: + ret = "prompt" } call.resolve([ From c65d19fe3d62fd62ced02fe22e29196f5cf5980b Mon Sep 17 00:00:00 2001 From: Flavien VACCARETTI Date: Mon, 8 Jun 2020 14:45:20 +0200 Subject: [PATCH 4/4] Revert "ADD doc microphone permission" This reverts commit f5fe0a0c1a569ac6776b285ccf4a1031ad7fc40a. --- site/src/assets/docs-content/apis/permissions/api.html | 7 ------- 1 file changed, 7 deletions(-) diff --git a/site/src/assets/docs-content/apis/permissions/api.html b/site/src/assets/docs-content/apis/permissions/api.html index 5fee38b58..dc5267a80 100644 --- a/site/src/assets/docs-content/apis/permissions/api.html +++ b/site/src/assets/docs-content/apis/permissions/api.html @@ -126,12 +126,5 @@

PermissionType

"photos" - -
-
-
Microphone: - "microphone" -
-
} \ No newline at end of file