### switchToNotificationSettings usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Usage example for switchToNotificationSettings with success and error callbacks. ```javascript cordova.plugins.diagnostic.switchToNotificationSettings(function(){ console.log("Opened notification settings"); }, function(error){ console.error(error); }); ``` -------------------------------- ### switchToMobileDataSettings usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Usage example for switchToMobileDataSettings. ```javascript cordova.plugins.diagnostic.switchToMobileDataSettings(); ``` -------------------------------- ### isIgnoringBatteryOptimizations - Usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/device-state.md Example usage of isIgnoringBatteryOptimizations with success and error callbacks. ```javascript cordova.plugins.diagnostic.isIgnoringBatteryOptimizations(function(enabled){ console.log("Ignoring battery optimizations: " + enabled); }, function(error){ console.error(error); }); ``` -------------------------------- ### switchToWifiSettings usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/wifi.md Example usage of switchToWifiSettings to open the WiFi settings page. ```javascript cordova.plugins.diagnostic.wifi.switchToWifiSettings(); ``` -------------------------------- ### setWifiState usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/wifi.md Example usage of setWifiState to enable WiFi, with success and error callbacks. ```javascript cordova.plugins.diagnostic.wifi.setWifiState(function(enabled){ console.log("WiFi now enabled: " + enabled); }, function(error){ console.error(error); }, true); ``` -------------------------------- ### onLowPowerModeChange - Usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/device-state.md Example usage of onLowPowerModeChange, including de-registration with null. ```javascript cordova.plugins.diagnostic.onLowPowerModeChange(function(enabled){ console.log("Low power mode is now " + (enabled ? "on" : "off")); }); // later: de-register cordova.plugins.diagnostic.onLowPowerModeChange(null); ``` -------------------------------- ### isTouchExplorationEnabled - Usage Example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/device-state.md Example usage of isTouchExplorationEnabled with success and error callbacks. ```JavaScript cordova.plugins.diagnostic.isTouchExplorationEnabled(function(enabled){ console.log("Touch exploration: " + enabled); }, function(error){ console.error(error); }); ``` -------------------------------- ### getBackgroundRefreshStatus - Usage Example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/device-state.md Example usage of getBackgroundRefreshStatus with success and error callbacks. ```JavaScript cordova.plugins.diagnostic.getBackgroundRefreshStatus(function(status){ if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){ console.log("Background refresh authorized"); } }, function(error){ console.error(error); }); ``` -------------------------------- ### getBuildOSVersion - Usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example usage of the getBuildOSVersion method, logging the target API level to the console. ```javascript cordova.plugins.diagnostic.getBuildOSVersion(function(details){ console.log("Built against API " + details.targetApiLevel); }, function(error){ console.error(error); }); ``` -------------------------------- ### requestRemindersAuthorization() - Example usage Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example usage of requestRemindersAuthorization() with success and error callbacks. ```javascript cordova.plugins.diagnostic.requestRemindersAuthorization(function(status){ if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){ console.log("Reminders authorization allowed"); } }, function(error){ console.error(error); }); ``` -------------------------------- ### hasBluetoothLESupport: usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/bluetooth.md Example of checking BLE support. Logs whether the device supports BLE. ```javascript cordova.plugins.diagnostic.bluetooth.hasBluetoothLESupport(function(supported){ console.log("BLE support: " + supported); }, function(error){ console.error(error); }); ``` -------------------------------- ### switchToNFCSettings usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/nfc.md Example usage of switchToNFCSettings, which opens the NFC settings page. ```javascript cordova.plugins.diagnostic.nfc.switchToNFCSettings(); ``` -------------------------------- ### isGpsLocationAvailable usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/location.md Example usage of the isGpsLocationAvailable method, switching to location settings if GPS is not available. ```javascript cordova.plugins.diagnostic.location.isGpsLocationAvailable(function(available){ if(!available){ cordova.plugins.diagnostic.location.switchToLocationSettings(); } }, function(error){ console.error(error); }); ``` -------------------------------- ### switchToWirelessSettings usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example of calling switchToWirelessSettings with no parameters. Opens the wireless settings page on Android. ```javascript cordova.plugins.diagnostic.switchToWirelessSettings(); ``` -------------------------------- ### requestLocalNetworkAuthorization - usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/wifi.md Example of calling requestLocalNetworkAuthorization directly, logging the result or error. ```javascript cordova.plugins.diagnostic.wifi.requestLocalNetworkAuthorization(function(status){ console.log("Local network authorization: " + status); }, function(error){ console.error(error); }); ``` -------------------------------- ### isRequestingPermission usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/permissions.md Example usage checking if a permission request is in progress before requesting the CAMERA permission. ```js if(!cordova.plugins.diagnostic.isRequestingPermission()){ cordova.plugins.diagnostic.requestRuntimePermission(onSuccess, onError, cordova.plugins.diagnostic.permission.CAMERA); } ``` -------------------------------- ### getArchitecture usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example of calling getArchitecture to check if the device is ARMv8 (64-bit ARM). ```javascript cordova.plugins.diagnostic.getArchitecture(function(arch){ if(arch === cordova.plugins.diagnostic.cpuArchitecture.ARMv8){ console.log("64-bit ARM device"); } }, function(error){ console.error("Failed to query architecture: " + error); }); ``` -------------------------------- ### isNFCAvailable usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/nfc.md Example usage of isNFCAvailable, logging whether NFC is available or the error. ```javascript cordova.plugins.diagnostic.nfc.isNFCAvailable(function(available){ console.log("NFC available: " + available); }, function(error){ console.error(error); }); ``` -------------------------------- ### Usage example for requestExternalStorageAuthorization Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/external-storage.md Example usage of requestExternalStorageAuthorization, logging the resulting status or error to the console. ```javascript cordova.plugins.diagnostic.external_storage.requestExternalStorageAuthorization(function(status){ console.log("External storage authorization: " + status); }, function(error){ console.error(error); }); ``` -------------------------------- ### getMicrophoneAuthorizationStatus usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/microphone.md Example of calling getMicrophoneAuthorizationStatus and conditionally requesting authorization if not yet requested. ```javascript cordova.plugins.diagnostic.microphone.getMicrophoneAuthorizationStatus(function(status){ if(status === cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED){ cordova.plugins.diagnostic.microphone.requestMicrophoneAuthorization(onGranted, onError); } }, function(error){ console.error(error); }); ``` -------------------------------- ### registerPermissionRequestCompleteHandler usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/permissions.md Example registering a callback that logs the permission statuses and de-registers after a single call. ```js cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(function(statuses){ console.log("Permission request completed: " + JSON.stringify(statuses)); cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(null); // de-register after single call }); ``` -------------------------------- ### isWifiEnabled (iOS) - usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/wifi.md Example usage of the isWifiEnabled function. Logs whether the WiFi setting is on. ```javascript cordova.plugins.diagnostic.wifi.isWifiEnabled(function(enabled){ console.log("WiFi setting: " + enabled); }, function(error){ console.error(error); }); ``` -------------------------------- ### isWifiAvailable (iOS) - usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/wifi.md Example usage of the isWifiAvailable function. Logs whether the device is connected by WiFi. ```javascript cordova.plugins.diagnostic.wifi.isWifiAvailable(function(connected){ console.log("Connected by WiFi: " + connected); }, function(error){ console.error(error); }); ``` -------------------------------- ### getRemindersAuthorizationStatus - Usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/reminders.md Example call to get the reminders authorization status. ```javascript cordova.plugins.diagnostic.reminders.getRemindersAuthorizationStatus(function(status){ console.log("Reminders status: " + status); }, function(error){ console.error(error); }); ``` -------------------------------- ### Get location mode example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example of using cordova.plugins.diagnostic.getLocationMode() to retrieve the current location mode and handle each possible value. ```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); }); ``` -------------------------------- ### Cold restart usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example of performing a cold restart by passing `true` as the `cold` parameter, causing the app to fully exit and restart. ```javascript // Cold restart: the app fully exits and restarts cordova.plugins.diagnostic.restart(function(error){ console.error("Restart failed: " + error); }, true); ``` -------------------------------- ### Get current battery level Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Returns the current battery level as a percentage. The successCallback receives an integer percentage. The example logs the battery level to the console. ```javascript cordova.plugins.diagnostic.getCurrentBatteryLevel(function(level){ console.log(`Current battery level is ${level}%`); }); ``` -------------------------------- ### getMicrophoneAuthorizationStatus() - Get microphone authorization status Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Returns the microphone authorization status for the application. On Android 6 / API 23 and above, returns a permissionStatus constant; on Android 5.1 / API 22 and below, always returns GRANTED because permissions are granted at installation time. ```javascript cordova.plugins.diagnostic.getMicrophoneAuthorizationStatus(successCallback, errorCallback); ``` -------------------------------- ### Warm restart usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example of performing a warm restart by passing `false` as the `cold` parameter. The error callback logs any failure. ```javascript cordova.plugins.diagnostic.restart(function(error){ console.error("Restart failed: " + error); }, false); // warm restart ``` -------------------------------- ### presentLimitedLibraryPicker - Usage Example (JavaScript) Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/camera.md Example usage of presentLimitedLibraryPicker. The success callback logs the selected identifiers as JSON, and the error callback logs any error. ```javascript cordova.plugins.diagnostic.camera.presentLimitedLibraryPicker(function(identifiers){ console.log("Selected: " + JSON.stringify(identifiers || [])); }, function(error){ console.error(error); }); ``` -------------------------------- ### getLocationMode usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/location.md Example usage of getLocationMode. The success callback receives the current location mode; the example checks for LOCATION_OFF and logs a message. The error callback logs any failure. ```javascript cordova.plugins.diagnostic.location.getLocationMode(function(mode){ if(mode === cordova.plugins.diagnostic.locationMode.LOCATION_OFF){ console.log("Location services disabled on device"); } }, function(error){ console.error(error); }); ``` -------------------------------- ### getDeviceOSVersion - Usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example usage of the getDeviceOSVersion method, logging the OS version, API level, and API name to the console. ```javascript cordova.plugins.diagnostic.getDeviceOSVersion(function(details){ console.log("OS " + details.version + " / API " + details.apiLevel + " (" + details.apiName + ")"); }, function(error){ console.error(error); }); ``` -------------------------------- ### getRemindersAuthorizationStatus() - Example usage Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example usage of getRemindersAuthorizationStatus() with success and error callbacks. ```javascript cordova.plugins.diagnostic.getRemindersAuthorizationStatus(function(status){ if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){ console.log("Reminders authorization allowed"); } }, function(error){ console.error("The following error occurred: "+error); }); ``` -------------------------------- ### isRemindersAuthorized() - Example usage Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example usage of isRemindersAuthorized() with success and error callbacks. ```javascript cordova.plugins.diagnostic.isRemindersAuthorized(function(authorized){ console.log("App is " + (authorized ? "authorized" : "denied") + " access to reminders"); }, function(error){ console.error("The following error occurred: "+error); }); ``` -------------------------------- ### setWifiState() usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Enables or disables WiFi on Android. Requires ACCESS_WIFI_STATE and CHANGE_WIFI_STATE permissions. The example enables WiFi by passing true as the state. ```javascript cordova.plugins.diagnostic.setWifiState(function(){ console.log("Wifi was enabled"); }, function(error){ console.error("The following error occurred: "+error); }, true); ``` -------------------------------- ### switchToBluetoothSettings - Usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/bluetooth.md Calls the plugin's switchToBluetoothSettings method to open the Bluetooth settings page. ```javascript cordova.plugins.diagnostic.bluetooth.switchToBluetoothSettings(); ``` -------------------------------- ### isWifiAvailable usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/wifi.md Example usage of isWifiAvailable to check if WiFi is enabled and switch to WiFi settings if not. Includes error handling via console.error. ```javascript cordova.plugins.diagnostic.wifi.isWifiAvailable(function(enabled){ if(!enabled){ cordova.plugins.diagnostic.wifi.switchToWifiSettings(); } }, function(error){ console.error(error); }); ``` -------------------------------- ### switchToSettings usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example of calling switchToSettings with success and error callbacks. Logs a message when the settings page opens or an error occurs. ```javascript cordova.plugins.diagnostic.switchToSettings(function(){ console.log("Settings page opened"); }, function(error){ console.error("Failed to open settings: " + error); }); ``` -------------------------------- ### getExternalStorageAuthorizationStatus usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/external-storage.md Example of calling getExternalStorageAuthorizationStatus and requesting authorization if not requested. ```js cordova.plugins.diagnostic.external_storage.getExternalStorageAuthorizationStatus(function(status){ if(status === cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED){ cordova.plugins.diagnostic.external_storage.requestExternalStorageAuthorization(onResult, onError); } }, function(error){ console.error(error); }); ``` -------------------------------- ### Install plugin with AndroidX version overrides Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Command to install the plugin while overriding both the legacy and appcompat AndroidX library versions using the ANDROIDX_VERSION and ANDROIDX_APPCOMPAT_VERSION variables. ```shell $ cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0 --variable ANDROIDX_APPCOMPAT_VERSION=1.3.1 ``` -------------------------------- ### isExternalStorageAuthorized usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/external-storage.md Example of calling isExternalStorageAuthorized via the cordova plugin. ```js cordova.plugins.diagnostic.external_storage.isExternalStorageAuthorized(function(authorized){ console.log("External storage authorized: " + authorized); }, function(error){ console.error(error); }); ``` -------------------------------- ### Single permission request example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/permissions.md Example of requesting a single runtime permission (CAMERA) using the plugin's API. The success callback receives the permission status, and the error callback logs any error. ```javascript cordova.plugins.diagnostic.requestRuntimePermission(function(status){ console.log("Result: " + status); }, function(error){ console.error(error); }, cordova.plugins.diagnostic.permission.CAMERA); ``` -------------------------------- ### isRemindersAuthorized - Usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/reminders.md Example call to check reminders authorization status. ```javascript cordova.plugins.diagnostic.reminders.isRemindersAuthorized(function(authorized){ console.log("Reminders authorized: " + authorized); }, function(error){ console.error(error); }); ``` -------------------------------- ### isBluetoothEnabled example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example usage of cordova.plugins.diagnostic.isBluetoothEnabled to check if Bluetooth is enabled and log the result. ```javascript cordova.plugins.diagnostic.isBluetoothEnabled(function(enabled){ console.log("Bluetooth is " + (enabled ? "enabled" : "disabled")); }, function(error){ console.error("The following error occurred: "+error); }); ``` -------------------------------- ### isBluetoothAvailable example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example usage of cordova.plugins.diagnostic.isBluetoothAvailable to check if Bluetooth is available and log the result. ```javascript cordova.plugins.diagnostic.isBluetoothAvailable(function(available){ console.log("Bluetooth is " + (available ? "available" : "not available")); }, function(error){ console.error("The following error occurred: "+error); }); ``` -------------------------------- ### isDeviceRooted - usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example usage of isDeviceRooted. Calls the method with success and error callbacks to log the device root status. ```javascript cordova.plugins.diagnostic.isDeviceRooted(function(rooted){ console.log("Device rooted: " + rooted); }, function(error){ console.error(error); }); ``` -------------------------------- ### Usage example for isMotionAvailable Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/motion.md Example of calling isMotionAvailable with success and error callbacks. Logs whether motion tracking is available or an error. ```javascript cordova.plugins.diagnostic.motion.isMotionAvailable(function(available){ console.log("Motion tracking available: " + available); }, function(error){ console.error(error); }); ``` -------------------------------- ### isDebugBuild usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/core.md Example of calling isDebugBuild to check if the app is a debug build. ```javascript cordova.plugins.diagnostic.isDebugBuild(function(isDebug){ console.log("Debug build: " + isDebug); }, function(error){ console.error(error); }); ``` -------------------------------- ### requestMicrophoneAuthorization() - Example usage Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example usage of requestMicrophoneAuthorization() with success and error callbacks. The success callback receives either GRANTED or DENIED_ALWAYS; the error callback receives an error message string. ```javascript cordova.plugins.diagnostic.requestMicrophoneAuthorization(function(status){ if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){ console.log("Microphone use is authorized"); } }, function(error){ console.error(error); }); ``` -------------------------------- ### Restart the application (warm and cold restart) Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Restarts the application. By default, a warm restart is performed, but setting the 'cold' parameter to true performs a cold restart. The errorCallback is required since there is no success callback. The example shows both warm and cold restart usage. ```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); ``` -------------------------------- ### requestRemindersAuthorization - Usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/reminders.md Example call to request reminders authorization and handle the result. ```javascript cordova.plugins.diagnostic.reminders.requestRemindersAuthorization(function(status){ console.log("Reminders authorization: " + status); }, function(error){ console.error(error); }); ``` -------------------------------- ### isContactsAuthorized usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/contacts.md Example usage of cordova.plugins.diagnostic.contacts.isContactsAuthorized to log the authorization status or error. ```javascript cordova.plugins.diagnostic.contacts.isContactsAuthorized(function(authorized){ console.log("Contacts authorized: " + authorized); }, function(error){ console.error(error); }); ``` -------------------------------- ### switchToLocationSettings - usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/location.md Call this method to open the device location settings page. No parameters are required. ```javascript cordova.plugins.diagnostic.location.switchToLocationSettings(); ``` -------------------------------- ### hasBluetoothSupport example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example usage of cordova.plugins.diagnostic.hasBluetoothSupport to check if the device has Bluetooth capabilities and log the result. ```javascript cordova.plugins.diagnostic.hasBluetoothSupport(function(supported){ console.log("Bluetooth is " + (supported ? "supported" : "unsupported")); }, function(error){ console.error("The following error occurred: "+error); }); ``` -------------------------------- ### Basic usage example for requestCameraAuthorization Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/camera.md Example of requesting camera authorization with success and error callbacks. The success callback receives the authorization status, and the error callback logs any errors. This is the standard usage without storage permissions. ```javascript cordova.plugins.diagnostic.camera.requestCameraAuthorization({ successCallback: function(status){ console.log("Camera authorization: " + status); }, errorCallback: function(error){ console.error(error); } }); ``` -------------------------------- ### getBluetoothState example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example usage of cordova.plugins.diagnostic.getBluetoothState to check the current Bluetooth state and act when powered on. ```javascript cordova.plugins.diagnostic.getBluetoothState(function(state){ if(state === cordova.plugins.diagnostic.bluetoothState.POWERED_ON){ // Do something with Bluetooth } }, function(error){ console.error(error); }); ``` -------------------------------- ### Request location authorization example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/README.md Example of using cordova.plugins.diagnostic.requestLocationAuthorization() with the WHEN_IN_USE location authorization mode. ```javascript cordova.plugins.diagnostic.requestLocationAuthorization(function(status){ console.log(status); }, function(error){ console.error(error); }, cordova.plugins.diagnostic.locationAuthorizationMode.WHEN_IN_USE); ``` -------------------------------- ### switchToWifiSettings Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/wifi.md Displays the WiFi page in the Settings app. No callbacks are invoked. ```APIDOC ## switchToWifiSettings ### Description Displays the WiFi page in the Settings app. No callbacks are invoked. ### Method GET ### Endpoint cordova.plugins.diagnostic.wifi.switchToWifiSettings ### Parameters None ### Request Example ```js cordova.plugins.diagnostic.wifi.switchToWifiSettings(); ``` ### Response #### Success Response (200) No response data. #### Response Example ```json {} ``` ### Error Handling No error handling. ``` -------------------------------- ### requestIgnoreBatteryOptimizations usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/device-state.md Example usage of requestIgnoreBatteryOptimizations. The success callback logs a message when the prompt is displayed, and the error callback logs any native failure. ```javascript cordova.plugins.diagnostic.requestIgnoreBatteryOptimizations(function(){ console.log("Prompt displayed"); }, function(error){ console.error(error); }); ``` -------------------------------- ### isLocationEnabled usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/location.md Example usage of the isLocationEnabled method, logging the enabled state or an error. ```javascript cordova.plugins.diagnostic.location.isLocationEnabled(function(enabled){ console.log("Location setting: " + enabled); }, function(error){ console.error(error); }); ``` -------------------------------- ### registerBluetoothStateChangeHandler: usage example Source: https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/_autodocs/api-reference/bluetooth.md Example of registering a change handler that logs the new Bluetooth state. ```javascript cordova.plugins.diagnostic.bluetooth.registerBluetoothStateChangeHandler(function(state){ console.log("Bluetooth state: " + state); }); ```