### Specify AndroidX Versions during Installation
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Example of installing the cordova.plugins.diagnostic plugin while specifying custom versions for AndroidX legacy and appcompat libraries using variables.
```bash
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0 --variable ANDROIDX_APPCOMPAT_VERSION=1.3.1
```
--------------------------------
### Install Cordova Diagnostic Plugin
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Commands to install the cordova.plugins.diagnostic plugin using Cordova, Phonegap, or Ionic CLI. It also shows how to specify AndroidX versions during installation.
```bash
cordova plugin add cordova.plugins.diagnostic
cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0
phonegap plugin add cordova.plugins.diagnostic
ionic cordova plugin add cordova.plugins.diagnostic
```
--------------------------------
### Install Cordova Diagnostic Plugin using CLI
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
This command installs the cordova-diagnostic-plugin using the Cordova/Phonegap/Ionic CLI. Ensure you have the CLI installed and configured for your project.
```bash
ionic cordova plugin add cordova.plugins.diagnostic
# or
phonegap plugin add cordova.plugins.diagnostic
# or
cordova plugin add cordova.plugins.diagnostic
```
--------------------------------
### Switch to App Settings
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Navigates the user to the application's settings page in the device system settings. This is useful for guiding users to enable permissions or configure app-specific settings.
```javascript
cordova.plugins.diagnostic.switchToSettings()
.then(function() {
// User has been taken to the app settings
}).catch(function(error) {
// Error occurred
console.error("The following error occurred: " + error);
});
```
--------------------------------
### Get Build OS Version
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves the OS version used during the build process. This can differ from the device's current OS version.
```javascript
cordova.plugins.diagnostic.getBuildOSVersion(function(version) {
console.log("Build OS Version: " + version);
}, function(error) {
console.error("The following error occurred: " + error);
});
```
--------------------------------
### Location Mode Constants and Example - JavaScript
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Defines constants for Android location modes (HIGH_ACCURACY, BATTERY_SAVING, DEVICE_ONLY, LOCATION_OFF) and provides an example of how to get the current location mode and log it. This functionality is specific to the Android platform.
```javascript
cordova.plugins.diagnostic.getLocationMode(function(locationMode){
switch(locationMode){
case cordova.plugins.diagnostic.locationMode.HIGH_ACCURACY:
console.log("High accuracy");
break;
case cordova.plugins.diagnostic.locationMode.BATTERY_SAVING:
console.log("Battery saving");
break;
case cordova.plugins.diagnostic.locationMode.DEVICE_ONLY:
console.log("Device only");
break;
case cordova.plugins.diagnostic.locationMode.LOCATION_OFF:
console.log("Location off");
break;
}
},function(error){
console.error("The following error occurred: "+error);
});
```
--------------------------------
### Get Device OS Version Details (Android & iOS)
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Returns details of the OS of the device on which the app is currently running, including version, API level, and API name. The success callback receives an object with these details.
```javascript
cordova.plugins.diagnostic.getDeviceOSVersion(successCallback, errorCallback);
// Example usage:
cordova.plugins.diagnostic.getDeviceOSVersion(function(details){
console.log(`Version: ${details.version}`); // "13.0"
console.log(`API level: ${details.apiLevel}`); // 33
console.log(`API name: ${details.apiName}`); // "TIRAMISU"
});
```
--------------------------------
### Get Device OS Version
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves the version of the device's operating system. This is useful for checking compatibility or implementing OS-specific features.
```javascript
cordova.plugins.diagnostic.getDeviceOSVersion(function(version) {
console.log("Device OS Version: " + version);
}, function(error) {
console.error("The following error occurred: " + error);
});
```
--------------------------------
### Get CPU Architecture on Android and iOS
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves the CPU architecture of the current device on Android and iOS platforms. It takes success and error callbacks, with the success callback receiving a cpuArchitecture constant.
```javascript
cordova.plugins.diagnostic.getArchitecture(function(arch){
if(arch ===cordova.plugins.diagnostic.cpuArchitecture.X86
|| arch === cordova.plugins.diagnostic.cpuArchitecture.X86_64){
console.log("Intel inside");
}
}, function(error){
console.error(error);
});
```
--------------------------------
### Get Background Refresh Status on iOS with Cordova Diagnostic Plugin
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
This example demonstrates how to retrieve the background refresh authorization status for an iOS application using the Cordova Diagnostic Plugin. The success callback receives a status constant, and the error callback handles errors. This allows for more granular control and user feedback regarding background refresh capabilities.
```javascript
cordova.plugins.diagnostic.getBackgroundRefreshStatus(function(status){
if(status ===cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Background refresh is allowed");
}
}, function(error){
console.error("The following error occurred: "+error);
});
```
--------------------------------
### Get CPU Architecture
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves the CPU architecture of the device. This can be useful for performance optimizations or platform-specific code.
```javascript
cordova.plugins.diagnostic.getArchitecture(function(architecture) {
console.log("CPU Architecture: " + architecture);
}, function(error) {
console.error("The following error occurred: " + error);
});
```
--------------------------------
### Request Motion Authorization
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Requests motion tracking authorization for the application. The native dialog can only be invoked once per app installation. Subsequent calls after denial will result in an error, requiring manual user instruction via settings.
```APIDOC
## POST /requestMotionAuthorization
### Description
Requests motion tracking authorization for the application. The native dialog asking user's consent can only be invoked once after the app is installed. Once the user has either allowed or denied access, calling this function again will result in an error. It is not possible to re-invoke the dialog if the user denied permission in the native dialog, so in this case you will have to instruct the user how to change motion authorization manually via the Settings app.
When calling this function, the message contained in the `NSMotionUsageDescription` .plist key is displayed to the user; this plugin provides a default message, but you should override this with your specific reason for requesting access.
There's no direct way to determine if authorization was granted or denied, so the Pedometer API must be used to indirectly determine this: therefore, if the device supports motion tracking but not Pedometer Event Tracking, the outcome of requesting motion detection cannot be determined.
### Method
POST
### Endpoint
cordova.plugins.diagnostic.requestMotionAuthorization(successCallback, errorCallback)
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```javascript
cordova.plugins.diagnostic.requestMotionAuthorization(function(status){
if(status === cordova.plugins.motionStatus.permissionStatus.GRANTED){
console.log("Motion tracking authorized");
}
}, function(error){
console.error(error);
});
```
### Response
#### Success Response (200)
- **status** (string) - Indicates the result of the motion authorization request. Possible values include:
- `cordova.plugins.diagnostic.motionStatus.GRANTED`
- `cordova.plugins.diagnostic.motionStatus.DENIED_ALWAYS`
- `cordova.plugins.diagnostic.motionStatus.RESTRICTED`
- `cordova.plugins.diagnostic.motionStatus.NOT_AVAILABLE`
- `cordova.plugins.diagnostic.motionStatus.NOT_DETERMINED`
- `cordova.plugins.diagnostic.motionStatus.UNKNOWN`
#### Response Example
```json
{
"status": "cordova.plugins.diagnostic.motionStatus.GRANTED"
}
```
```
--------------------------------
### Get Build OS Version - JavaScript
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves details of the SDK levels used to build the app, including target and minimum API levels and their code names. This function is available on Android and iOS platforms. It accepts a success callback that receives an object with build details and an error callback for failure.
```javascript
cordova.plugins.diagnostic.getBuildOSVersion(function(details){
console.log(`Target API level: ${details.targetApiLevel}`); // 33
console.log(`Target API name: ${details.targetApiLevel}`); // "TIRAMISU"
console.log(`Minimum API level: ${details.targetApiLevel}`); // 21
console.log(`Target API name: ${details.targetApiLevel}`); // "LOLLIPOP"
});
```
--------------------------------
### Get Permission Authorization Status (Multiple Permissions)
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves the authorization status for multiple runtime permissions simultaneously. This is efficient for checking several permissions at once.
```javascript
cordova.plugins.diagnostic.getPermissionsAuthorizationStatus(permissions, successCallback, errorCallback);
// Example for LOCATION_WHEN_IN_USE and CAMERA permissions:
var successCallback = function(statuses) {
// statuses is an object where keys are permission types and values are their statuses
console.log(statuses.LOCATION_WHEN_IN_USE);
console.log(statuses.CAMERA);
};
var errorCallback = function(error) {
console.error("The following error occurred: " + error);
};
cordova.plugins.diagnostic.getPermissionsAuthorizationStatus([
cordova.plugins.diagnostic.permissionType.LOCATION_WHEN_IN_USE,
cordova.plugins.diagnostic.permissionType.CAMERA
], successCallback, errorCallback);
```
--------------------------------
### Android Permission Status Constants - XML/JavaScript
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Defines constants representing permission states on Android. The plugin uses local storage to differentiate between 'NOT_REQUESTED' and 'DENIED_ALWAYS' due to limitations in the native Android API. The example shows how to disable Android Autobackup to prevent potential discrepancies in permission reporting.
```javascript
// Accessing permission status constants:
cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED
cordova.plugins.diagnostic.permissionStatus.DENIED_ONCE
cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS
cordova.plugins.diagnostic.permissionStatus.GRANTED
```
```xml
```
--------------------------------
### Get Device OS Version and CPU Architecture with Cordova Diagnostic
Source: https://context7.com/dpa99c/cordova-diagnostic-plugin/llms.txt
Retrieves the device's operating system version, including API level and name, and its CPU architecture. Handles potential errors during these operations. Useful for tailoring application behavior based on device capabilities.
```javascript
// Get device OS version
cordova.plugins.diagnostic.getDeviceOSVersion(
function(details) {
console.log("OS Version: " + details.version);
console.log("API Level: " + details.apiLevel);
console.log("API Name: " + details.apiName);
// Example: Android 11, API 30, RED_VELVET_CAKE
if (details.apiLevel >= 30) {
console.log("Running on Android 11 or higher");
}
},
function(error) {
console.error("Error getting OS version: " + error);
}
);
// Get CPU architecture
cordova.plugins.diagnostic.getArchitecture(
function(arch) {
console.log("CPU Architecture: " + arch);
if (arch === cordova.plugins.diagnostic.cpuArchitecture.ARMv8) {
console.log("64-bit ARM processor");
} else if (arch === cordova.plugins.diagnostic.cpuArchitecture.ARMv7) {
console.log("32-bit ARM processor");
}
},
function(error) {
console.error("Error getting architecture: " + error);
}
);
```
--------------------------------
### Request Motion Tracking Authorization
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Requests motion tracking authorization from the user on iOS. This function can only be invoked once per app installation. The success callback receives a status indicating if authorization was granted, denied, restricted, or not available. Ensure you have configured the NSMotionUsageDescription key in your app's plist.
```javascript
cordova.plugins.diagnostic.requestMotionAuthorization(function(status){
// Handle success status: cordova.plugins.diagnostic.motionStatus.GRANTED, DENIED_ALWAYS, RESTRICTED, NOT_AVAILABLE, NOT_DETERMINED, UNKNOWN
if(status === cordova.plugins.motionStatus.permissionStatus.GRANTED){
console.log("Motion tracking authorized");
}
}, function(error){
console.error(error);
});
```
--------------------------------
### Manage Location Permission on Android (Cordova)
Source: https://context7.com/dpa99c/cordova-diagnostic-plugin/llms.txt
Checks the current location authorization status on Android and requests permission if it hasn't been requested yet. If granted, it starts location tracking. Handles cases where permission is permanently denied by prompting the user to go to settings. Supports `WHEN_IN_USE` authorization mode.
```javascript
// Check current authorization status
cordova.plugins.diagnostic.getLocationAuthorizationStatus(
function(status) {
console.log("Location authorization status: " + status);
switch(status) {
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
// First time - request permission
cordova.plugins.diagnostic.requestLocationAuthorization(
function(requestStatus) {
console.log("Permission request result: " + requestStatus);
if (requestStatus === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
startLocationTracking();
}
},
function(error) {
console.error("Error requesting location permission: " + error);
},
cordova.plugins.diagnostic.locationAuthorizationMode.WHEN_IN_USE
);
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
case cordova.plugins.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE:
startLocationTracking();
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
alert("Location permission denied. Please enable in Settings.");
break;
}
},
function(error) {
console.error("Error checking location status: " + error);
}
);
```
--------------------------------
### Navigate to System Settings using Cordova Diagnostic Plugin
Source: https://context7.com/dpa99c/cordova-diagnostic-plugin/llms.txt
Directs users to relevant system settings pages when permissions are denied. This function handles the logic for opening main app settings, location settings, Wi-Fi settings, Bluetooth settings, and notification settings. It uses the `cordova.plugins.diagnostic` API and provides callbacks for success and error handling.
```javascript
function handlePermissionDenied(permissionType) {
var message = "Permission denied. Please enable " + permissionType + " in Settings.";
if (confirm(message + " Open Settings now?")) {
// Open main app settings page
cordova.plugins.diagnostic.switchToSettings(
function() {
console.log("Opened app settings");
},
function(error) {
console.error("Error opening settings: " + error);
}
);
}
}
// Open specific settings pages (Android only)
function openLocationSettings() {
cordova.plugins.diagnostic.switchToLocationSettings();
}
function openWifiSettings() {
cordova.plugins.diagnostic.switchToWifiSettings();
}
function openBluetoothSettings() {
cordova.plugins.diagnostic.switchToBluetoothSettings();
}
function openNotificationSettings() {
cordova.plugins.diagnostic.switchToNotificationSettings(
function() { console.log("Opened notification settings"); },
function(error) { console.error("Error: " + error); }
);
}
```
--------------------------------
### switchToSettings()
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Opens the settings page for the application on Android or iOS.
```APIDOC
## switchToSettings()
### Description
Opens the settings page for the application. On Android, this navigates to the "App Info" page. On iOS, it opens the app's specific settings page.
### Method
`javascript`
cordova.plugins.diagnostic.switchToSettings(successCallback, errorCallback);
### Parameters
#### Path Parameters
* `successCallback` (Function) - The callback function to be executed when the settings page is successfully opened.
* `errorCallback` (Function) - The callback function to be executed if an error occurs. It receives a single string parameter with the error message.
### Request Example
```javascript
cordova.plugins.diagnostic.switchToSettings(function() {
console.log("Successfully switched to Settings app");
}, function(error) {
console.error("The following error occurred: " + error);
});
```
### Response
#### Success Response
* The `successCallback` is invoked upon successful opening of the settings page.
#### Response Example
N/A (Callback-based)
```
--------------------------------
### Motion Module
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
This module is mentioned but no specific methods are detailed in the provided text.
--------------------------------
### Contacts Authorization API
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
API endpoints for checking and getting contacts authorization status.
```APIDOC
## isContactsAuthorized()
### Description
Checks if the application is authorized to use contacts (address book). On Android, for API 22 and below, this always returns TRUE.
### Method
`isContactsAuthorized`
### Endpoint
`cordova.plugins.diagnostic.isContactsAuthorized(successCallback, errorCallback)`
### Parameters
#### Callback Parameters
- **successCallback** (Function) - Called on successful operation. Receives a boolean: TRUE if contacts are authorized.
- **errorCallback** (Function) - Called on error. Receives a string with the error message.
### Request Example
```javascript
cordova.plugins.diagnostic.isContactsAuthorized(function(authorized){
console.log("App is " + (authorized ? "authorized" : "denied") + " access to contacts");
}, function(error){
console.error("The following error occurred: "+error);
});
```
### Response
#### Success Response
- **authorized** (boolean) - TRUE if contacts are authorized, FALSE otherwise.
```
```APIDOC
## getContactsAuthorizationStatus()
### Description
Returns the contacts authorization status for the application. On Android, for API 22 and below, this always returns GRANTED status.
### Method
`getContactsAuthorizationStatus`
### Endpoint
`cordova.plugins.diagnostic.getContactsAuthorizationStatus(successCallback, errorCallback)`
### Parameters
#### Callback Parameters
- **successCallback** (Function) - Called on successful operation. Receives a string indicating the authorization status (a permissionStatus constant).
- **errorCallback** (Function) - Called on error. Receives a string with the error message.
### Request Example
```javascript
cordova.plugins.diagnostic.getContactsAuthorizationStatus(function(status){
if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
console.log("Contacts use is authorized");
}
}, function(error){
console.error("The following error occurred: "+error);
});
```
### Response
#### Success Response
- **status** (string) - The authorization status (e.g., `GRANTED`, `DENIED_ALWAYS`).
```
--------------------------------
### Get Current Battery Level
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves the current battery level of the device. This can be used for power-aware features in the application.
```javascript
cordova.plugins.diagnostic.getCurrentBatteryLevel(function(level) {
console.log("Current battery level: " + level + "%");
}, function(error) {
console.error("The following error occurred: " + error);
});
```
--------------------------------
### Get Background Refresh Status
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves the status of background app refresh. This provides more detailed information than just checking authorization.
```javascript
cordova.plugins.diagnostic.getBackgroundRefreshStatus(function(status) {
switch (status) {
case cordova.plugins.diagnostic.backgroundRefreshStatus.AVAILABLE:
console.log("Background app refresh is available.");
break;
case cordova.plugins.diagnostic.backgroundRefreshStatus.DENIED:
console.log("Background app refresh is denied.");
break;
case cordova.plugins.diagnostic.backgroundRefreshStatus.RESTRICTED:
console.log("Background app refresh is restricted.");
break;
}
}, function(error) {
console.error("The following error occurred: " + error);
});
```
--------------------------------
### getBuildOSVersion()
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves details about the SDK levels used to build the application for Android and iOS platforms.
```APIDOC
## GET /getBuildOSVersion
### Description
Returns details of the SDK levels used to build the app.
### Method
GET
### Endpoint
cordova.plugins.diagnostic.getBuildOSVersion
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```javascript
cordova.plugins.diagnostic.getBuildOSVersion(successCallback, errorCallback);
```
### Response
#### Success Response (200)
- **targetApiLevel** (integer) - API level of the target SDK.
- **targetApiName** (string) - Code name for the API level of the target SDK.
- **minApiLevel** (integer) - API level of the minimum SDK.
- **minApiName** (string) - Code name for the API level of the minimum SDK.
#### Response Example
```javascript
{
"targetApiLevel": 30,
"targetApiName": "FROYO",
"minApiLevel": 30,
"minApiName": "FROYO"
}
```
#### Error Response
- **error** (string) - Error message if the operation fails.
```
--------------------------------
### Restart Application on Android
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Restarts the application on Android. A 'warm' restart recreates the Webview, while a 'cold' restart performs a system exit for a full application reset. It takes an error callback and an optional boolean for cold restart.
```javascript
var onError = function(error){
console.error("The following error occurred: "+error);
}
// Warm restart
cordova.plugins.diagnostic.restart(onError, false);
// Cold restart
cordova.plugins.diagnostic.restart(onError, true);
```
--------------------------------
### Open App Settings Page - JavaScript
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Navigates the user to the application's settings page within the device's settings app. This function is available on both Android and iOS platforms. It takes success and error callback functions as parameters.
```javascript
cordova.plugins.diagnostic.switchToSettings(successCallback, errorCallback);
// Example usage:
cordova.plugins.diagnostic.switchToSettings(function(){
console.log("Successfully switched to Settings app");
}, function(error){
console.error("The following error occurred: "+error);
});
```
--------------------------------
### cpuArchitecture Constants
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Defines constants for the various CPU architectures of the current hardware returned by getArchitecture().
```APIDOC
## cpuArchitecture Constants
### Description
Defines constants for the various CPU architectures of the current hardware returned by [getArchitecture()](#getarchitecture).
### Available on
Platforms: Android and iOS
### Constants
`cordova.plugins.diagnostic.cpuArchitecture`
#### Android and iOS
- `UNKNOWN` - Unknown CPU architecture
- `ARMv6` - ARM v6 or below (32 bit)
- `ARMv7` - ARM v7 (32 bit)
- `ARMv8` - ARM v8 (64 bit)
- `X86` - Intel x86 (32 bit)
- `X86_64` - Intel x86 (64 bit)
- `MIPS` - MIPS (32 bit)
- `MIPS_64` - MIPS (64 bit)
### Example Usage
See [getArchitecture()](#getarchitecture).
```
--------------------------------
### Check Device Hardware Capabilities
Source: https://context7.com/dpa99c/cordova-diagnostic-plugin/llms.txt
Verifies if specific hardware features like the camera and Bluetooth LE are present on the device. It checks for hardware presence, authorization, and support for specific features. Input to callbacks is a boolean indicating presence or support. Output is logged to the console.
```javascript
// Check if camera hardware exists
cordova.plugins.diagnostic.isCameraPresent(
function(present) {
if (present) {
console.log("Camera hardware detected");
// Now check authorization
cordova.plugins.diagnostic.isCameraAuthorized(
function(authorized) {
if (authorized) {
console.log("Camera is authorized");
enableCameraFeatures();
} else {
console.log("Camera not authorized - requesting permission");
cordova.plugins.diagnostic.requestCameraAuthorization(
function(status) {
if (status === cordova.plugins.diagnostic.permissionStatus.GRANTED) {
enableCameraFeatures();
}
},
function(error) { console.error(error); }
);
}
},
function(error) { console.error(error); }
);
} else {
console.log("No camera hardware found");
disableCameraFeatures();
}
},
function(error) {
console.error("Error checking camera presence: " + error);
}
);
// Check Bluetooth capabilities
cordova.plugins.diagnostic.hasBluetoothLESupport(
function(supported) {
console.log("Bluetooth LE " + (supported ? "is" : "is not") + " supported");
},
function(error) {
console.error("Error checking Bluetooth LE support: " + error);
}
);
```
--------------------------------
### Get Permission Authorization Status (Single Permission)
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves the authorization status for a specific runtime permission. This is crucial for checking if the app has the necessary permissions before attempting an operation.
```javascript
cordova.plugins.diagnostic.getPermissionAuthorizationStatus(permission, successCallback, errorCallback);
// Example for LOCATION_WHEN_IN_USE permission:
var successCallback = function(status) {
switch (status) {
case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
// Permission has not been requested / is not available that way
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED:
// The permission is denied
break;
case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
// The permission is denied forever
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED:
// The permission is granted
break;
case cordova.plugins.diagnostic.permissionStatus.GRANTED_WHEN_IN_USE:
// The permission is granted only when the app is in use
break;
}
};
var errorCallback = function(error) {
console.error("The following error occurred: " + error);
};
cordova.plugins.diagnostic.getPermissionAuthorizationStatus(cordova.plugins.diagnostic.permissionType.LOCATION_WHEN_IN_USE, successCallback, errorCallback);
```
--------------------------------
### switchToWirelessSettings()
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Switches to the wireless settings page on Android devices.
```APIDOC
## switchToWirelessSettings()
### Description
Switches to the wireless settings page on Android devices, allowing configuration of Wi-Fi, Bluetooth, and Mobile networks.
### Method
`javascript`
cordova.plugins.diagnostic.switchToWirelessSettings();
### Parameters
* None
### Request Example
```javascript
cordova.plugins.diagnostic.switchToWirelessSettings();
```
### Response
#### Success Response
* Navigates the user to the wireless settings screen.
#### Response Example
N/A
```
--------------------------------
### Request External Storage Authorization
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Requests the `READ_EXTERNAL_STORAGE` runtime permission for Android 6 (API 23) and above. On older Android versions, this call has no effect as permissions are granted at installation.
```APIDOC
## POST /requestExternalStorageAuthorization
### Description
Requests external storage authorization for the application on Android.
### Method
POST
### Endpoint
cordova.plugins.diagnostic.requestExternalStorageAuthorization
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```javascript
cordova.plugins.diagnostic.requestExternalStorageAuthorization(successCallback, errorCallback);
```
### Response
#### Success Response (200)
- **status** (string) - Indicates whether access to external storage was granted (`cordova.plugins.diagnostic.permissionStatus.GRANTED`) or denied (`cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS`).
#### Response Example
```javascript
// successCallback
function(status) {
console.log("Authorization request for external storage use was " + (status == cordova.plugins.diagnostic.permissionStatus.GRANTED ? "granted" : "denied"));
}
```
#### Error Response
- **error** (string) - An error message if the operation encounters an issue.
```
--------------------------------
### Get External SD Card Details
Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md
Retrieves details of external SD card(s), including their absolute path, writability, and free space. This method focuses on removable external storage.
```APIDOC
## GET /getExternalSdCardDetails
### Description
Returns details of external SD card(s), including their absolute path, writability, and free space. This method is intended for removable external storage.
### Method
GET
### Endpoint
cordova.plugins.diagnostic.getExternalSdCardDetails
### Parameters
#### Path Parameters
None
#### Query Parameters
None
#### Request Body
None
### Request Example
```javascript
cordova.plugins.diagnostic.getExternalSdCardDetails(successCallback, errorCallback);
```
### Response
#### Success Response (200)
- **details** (Array