From a4151abebf8922304da196bd62e02bc7fb8035d2 Mon Sep 17 00:00:00 2001 From: Dave Alden Date: Tue, 9 May 2017 22:30:11 +0100 Subject: [PATCH] feat(diagnostic): update to support latest signatures (#1458) * refactor(diagnostic plugin): update camera API function signatures to support cordova.plugins.diagnostic@3.6.0. See https://github.com/dpa99c/cordova-diagnostic-plugin/commit/515317e89a874447812de0c720367c3fc68c0872 * fix(diagnostic plugin): fix whitespace linting errors in previous commit * * fix(diagnostic plugin): add callback indices to Cordova decorator in camera API so externalStorage parameter can be optionally omitted. See https://github.com/driftyco/ionic-native/pull/1458#issuecomment-299030833 * fix(diagnostic plugin): fix incorrect return type on getCameraRollAuthorizationStatus() --- src/@ionic-native/plugins/diagnostic/index.ts | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/src/@ionic-native/plugins/diagnostic/index.ts b/src/@ionic-native/plugins/diagnostic/index.ts index fb9b0119f..017913d83 100644 --- a/src/@ionic-native/plugins/diagnostic/index.ts +++ b/src/@ionic-native/plugins/diagnostic/index.ts @@ -144,10 +144,12 @@ export class Diagnostic extends IonicNativePlugin { /** * Checks if the device has a camera. On Android this returns true if the device has a camera. On iOS this returns true if both the device has a camera AND the application is authorized to use it. On Windows 10 Mobile this returns true if both the device has a rear-facing camera AND the * application is authorized to use it. + * @param {boolean} [externalStorage] Android only: If true, checks permission for READ_EXTERNAL_STORAGE in addition to CAMERA run-time permission. + * cordova-plugin-camera@2.2+ requires both of these permissions. Defaults to true. * @returns {Promise} */ - @Cordova() - isCameraAvailable(): Promise { return; } + @Cordova({ successIndex: 1, errorIndex: 2 }) + isCameraAvailable( externalStorage?: boolean ): Promise { return; } /** * Checks if the device has Bluetooth capabilities and if so that Bluetooth is switched on (same on Android, iOS and Windows 10 Mobile) @@ -251,24 +253,30 @@ export class Diagnostic extends IonicNativePlugin { /** * Checks if the application is authorized to use the camera. * Note for Android: this is intended for Android 6 / API 23 and above. Calling on Android 5 / API 22 and below will always return TRUE as permissions are already granted at installation time. + * @param {boolean} [externalStorage] Android only: If true, checks permission for READ_EXTERNAL_STORAGE in addition to CAMERA run-time permission. + * cordova-plugin-camera@2.2+ requires both of these permissions. Defaults to true. * @returns {Promise} */ - @Cordova({ platforms: ['Android', 'iOS'] }) - isCameraAuthorized(): Promise { return; } + @Cordova({ platforms: ['Android', 'iOS'], successIndex: 1, errorIndex: 2 }) + isCameraAuthorized( externalStorage?: boolean ): Promise { return; } /** * Returns the camera authorization status for the application. + * @param {boolean} [externalStorage] Android only: If true, checks permission for READ_EXTERNAL_STORAGE in addition to CAMERA run-time permission. + * cordova-plugin-camera@2.2+ requires both of these permissions. Defaults to true. * @returns {Promise} */ - @Cordova({ platforms: ['Android', 'iOS'] }) - getCameraAuthorizationStatus(): Promise { return; } + @Cordova({ platforms: ['Android', 'iOS'], successIndex: 1, errorIndex: 2 }) + getCameraAuthorizationStatus( externalStorage?: boolean ): Promise { return; } /** * Requests camera authorization for the application. + * @param {boolean} [externalStorage] Android only: If true, requests permission for READ_EXTERNAL_STORAGE in addition to CAMERA run-time permission. + * cordova-plugin-camera@2.2+ requires both of these permissions. Defaults to true. * @returns {Promise} */ - @Cordova({ platforms: ['Android', 'iOS'] }) - requestCameraAuthorization(): Promise { return; } + @Cordova({ platforms: ['Android', 'iOS'], successIndex: 1, errorIndex: 2 }) + requestCameraAuthorization( externalStorage?: boolean ): Promise { return; } /** * Checks if the application is authorized to use the microphone. @@ -614,10 +622,10 @@ export class Diagnostic extends IonicNativePlugin { /** * Returns the authorization status for the application to use the Camera Roll in Photos app. - * @returns {Promise} + * @returns {Promise} */ @Cordova({ platforms: ['iOS'] }) - getCameraRollAuthorizationStatus(): Promise { return; } + getCameraRollAuthorizationStatus(): Promise { return; } /** * Requests camera roll authorization for the application.