From 941054480048dd5e2ffd7e0f9190ec00b32bb167 Mon Sep 17 00:00:00 2001 From: Dave Alden Date: Wed, 1 Feb 2017 19:34:58 +0000 Subject: [PATCH] Update with new methods for cordova.plugins.diagnostic@3.4 --- .../cordova.plugins.diagnostic-tests.ts | 52 +++++++++++ cordova.plugins.diagnostic/index.d.ts | 93 ++++++++++++++++++- 2 files changed, 142 insertions(+), 3 deletions(-) diff --git a/cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts b/cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts index 29451c4753..35c1e03d58 100644 --- a/cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts +++ b/cordova.plugins.diagnostic/cordova.plugins.diagnostic-tests.ts @@ -529,4 +529,56 @@ cordova.plugins.diagnostic.requestAndCheckMotionAuthorization(function(status){ console.log("Motion authorization is " +status); }, function(error){ console.error(error); +}); + +cordova.plugins.diagnostic.isExternalStorageAuthorized(function(authorized){ + console.log("Location authorization is " + (authorized ? "authorized" : "unauthorized")); +}, function(error){ + console.error("The following error occurred: "+error); +}); + +cordova.plugins.diagnostic.getExternalStorageAuthorizationStatus(function(status){ + if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){ + console.log("External storage authorization allowed"); + } +}, function(error){ + console.error("The following error occurred: "+error); +}); + +cordova.plugins.diagnostic.requestExternalStorageAuthorization(function(status){ + if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){ + console.log("External storage authorization allowed"); + } +}, function(error){ + console.error(error); +}); + +cordova.plugins.diagnostic.getExternalSdCardDetails(function(details){ + console.log("External SD card details: " + JSON.stringify(details)); +}, function(error){ + console.error(error); +}); + +cordova.plugins.diagnostic.isNFCPresent(function(present){ + console.log("NFC hardware is " + (present ? "present" : "absent")); +}, function(error){ + console.error("The following error occurred: "+error); +}); + +cordova.plugins.diagnostic.isNFCEnabled(function(enabled){ + console.log("NFC is " + (enabled ? "enabled" : "disabled")); +}, function(error){ + console.error("The following error occurred: "+error); +}); + +cordova.plugins.diagnostic.isNFCAvailable(function(available){ + console.log("NFC is " + (available ? "available" : "not available")); +}, function(error){ + console.error("The following error occurred: "+error); +}); + +cordova.plugins.diagnostic.registerNFCStateChangeHandler(function(state){ + if(state === cordova.plugins.diagnostic.NFCState.POWERED_ON){ + console.log("NFC is ready to use"); + } }); \ No newline at end of file diff --git a/cordova.plugins.diagnostic/index.d.ts b/cordova.plugins.diagnostic/index.d.ts index 381b61562e..c4d2daedd9 100644 --- a/cordova.plugins.diagnostic/index.d.ts +++ b/cordova.plugins.diagnostic/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for cordova.plugins.diagnostic v3.3.0 +// Type definitions for cordova.plugins.diagnostic v3.4.x // Project: https://github.com/dpa99c/cordova-diagnostic-plugin // Definitions by: Dave Alden // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -164,8 +164,8 @@ interface Diagnostic { /** * ANDROID and iOS ONLY - * Returns true if the device setting for location is on. - * On Android this returns true if Location Mode is switched on. + * Returns true if the device setting for location is on. + * On Android this returns true if Location Mode is switched on. * On iOS this returns true if Location Services is switched on. * @param successCallback * @param errorCallback @@ -567,6 +567,93 @@ interface Diagnostic { errorCallback: (error: string) => void ) => void; + /** + * ANDROID ONLY + * Checks if the application is authorized to use external storage. + * @param successCallback + * @param errorCallback + */ + isExternalStorageAuthorized?: ( + successCallback: (authorized: boolean) => void, + errorCallback: (error: string) => void + ) => void; + + /** + * ANDROID ONLY + * Returns the authorisation status for runtime permission to use the external storage. + * @param successCallback + * @param errorCallback + */ + getExternalStorageAuthorizationStatus?: ( + successCallback: (status: string) => void, + errorCallback: (error: string) => void + ) => void; + + /** + * ANDROID ONLY + * Requests authorisation for runtime permission to use the external storage. + * @param successCallback + * @param errorCallback + */ + requestExternalStorageAuthorization?: ( + successCallback: (status: string) => void, + errorCallback: (error: string) => void + ) => void; + + /** + * ANDROID ONLY + * Returns details of external SD card(s): absolute path, is writable, free space + * @param successCallback + * @param errorCallback + */ + getExternalSdCardDetails?: ( + successCallback: (status: any) => void, + errorCallback: (error: string) => void + ) => void; + + /** + * ANDROID ONLY + * Checks if NFC hardware is present on device. + * @param successCallback + * @param errorCallback + */ + isNFCPresent?: ( + successCallback: (present: boolean) => void, + errorCallback: (error: string) => void + ) => void; + + /** + * ANDROID ONLY + * Checks if the device setting for NFC is switched on. + * @param successCallback + * @param errorCallback + */ + isNFCEnabled?: ( + successCallback: (present: boolean) => void, + errorCallback: (error: string) => void + ) => void; + + /** + * ANDROID ONLY + * Checks if NFC is available to the app. + * @param successCallback + * @param errorCallback + */ + isNFCAvailable?: ( + successCallback: (present: boolean) => void, + errorCallback: (error: string) => void + ) => void; + + /** + * ANDROID ONLY + * Registers a function to be called when a change in NFC state occurs. + * Pass in a falsey value to de-register the currently registered function. + * @param successCallback + */ + registerNFCStateChangeHandler?: ( + successCallback: (state: string) => void + ) => void; + /** * iOS ONLY * Checks if the application is authorized to use the Camera Roll in Photos app.