npm package: @ns0m/cordova.plugins.diagnostic
Description: Cordova/Phonegap plugin to check the state of Location/WiFi/Camera/Bluetooth device settings.
Author: Dave Alden
Latest version: 6.2.5

Cordova diagnostic plugin [![Latest Stable Version](https://img.shields.io/npm/v/cordova.plugins.diagnostic.svg)](https://www.npmjs.com/package/cordova.plugins.diagnostic) [![Total Downloads](https://img.shields.io/npm/dt/cordova.plugins.diagnostic.svg)](https://npm-stat.com/charts.html?package=cordova.plugins.diagnostic)
=========================

<!-- doctoc README.md --maxlevel=3 -->
<!-- START doctoc generated TOC please keep comment here to allow auto update -->
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->


- [Overview](#overview)
  - [Important notes](#important-notes)
    - [Minimum supported versions](#minimum-supported-versions)
    - [Native environment required](#native-environment-required)
    - [Building for Android](#building-for-android)
- [Installation](#installation)
  - [Using the Cordova/Phonegap/Ionic CLI](#using-the-cordovaphonegapionic-cli)
  - [AndroidX Library](#androidx-library)
  - [Specifying modules](#specifying-modules)
    - [Available modules](#available-modules)
- [Reporting issues](#reporting-issues)
  - [Reporting a bug or problem](#reporting-a-bug-or-problem)
  - [Requesting a new feature](#requesting-a-new-feature)
- [Usage](#usage)
  - [Core module](#core-module)
    - [switchToSettings()](#switchtosettings)
      - [Parameters](#parameters)
      - [Example usage](#example-usage)
    - [switchToWirelessSettings()](#switchtowirelesssettings)
    - [switchToMobileDataSettings()](#switchtomobiledatasettings)
    - [permissionStatus constants](#permissionstatus-constants)
      - [Android](#android)
      - [iOS](#ios)
      - [Example](#example)
    - [getPermissionAuthorizationStatus()](#getpermissionauthorizationstatus)
      - [Parameters](#parameters-1)
      - [Example usage](#example-usage-1)
    - [getPermissionsAuthorizationStatus()](#getpermissionsauthorizationstatus)
      - [Parameters](#parameters-2)
      - [Example usage](#example-usage-2)
    - [requestRuntimePermission()](#requestruntimepermission)
      - [Parameters](#parameters-3)
      - [Example usage](#example-usage-3)
    - [requestRuntimePermissions()](#requestruntimepermissions)
      - [Parameters](#parameters-4)
      - [Example usage](#example-usage-4)
    - [isRequestingPermission()](#isrequestingpermission)
      - [Example usage](#example-usage-5)
    - [registerPermissionRequestCompleteHandler()](#registerpermissionrequestcompletehandler)
      - [Parameters](#parameters-5)
      - [Example usage](#example-usage-6)
    - [isDataRoamingEnabled()](#isdataroamingenabled)
      - [Parameters](#parameters-6)
      - [Example usage](#example-usage-7)
    - [isADBModeEnabled()](#isadbmodeenabled)
      - [Parameters](#parameters-7)
      - [Example usage](#example-usage-8)
    - [isDeviceRooted()](#isdevicerooted)
      - [Parameters](#parameters-8)
      - [Example usage](#example-usage-9)
    - [isBackgroundRefreshAuthorized()](#isbackgroundrefreshauthorized)
      - [Parameters](#parameters-9)
      - [Example usage](#example-usage-10)
    - [getBackgroundRefreshStatus()](#getbackgroundrefreshstatus)
      - [Parameters](#parameters-10)
      - [Example usage](#example-usage-11)
    - [cpuArchitecture constants](#cpuarchitecture-constants)
      - [Android](#android-1)
      - [iOS](#ios-1)
      - [Example usage](#example-usage-12)
    - [getArchitecture()](#getarchitecture)
      - [Parameters](#parameters-11)
      - [Example usage](#example-usage-13)
    - [restart()](#restart)
      - [Parameters](#parameters-12)
      - [Example usage](#example-usage-14)
    - [enableDebug()](#enabledebug)
      - [Parameters](#parameters-13)
      - [Example usage](#example-usage-15)
    - [getCurrentBatteryLevel()](#getcurrentbatterylevel)
      - [Parameters](#parameters-14)
      - [Example usage](#example-usage-16)
  - [Location module](#location-module)
    - [locationMode constants](#locationmode-constants)
      - [Values](#values)
      - [Example](#example-1)
    - [locationAuthorizationMode constants](#locationauthorizationmode-constants)
      - [Values](#values-1)
      - [Example](#example-2)
    - [locationAccuracyAuthorization constants](#locationaccuracyauthorization-constants)
      - [Values](#values-2)
      - [Example](#example-3)
    - [isLocationAvailable()](#islocationavailable)
      - [Parameters](#parameters-15)
      - [Example usage](#example-usage-17)
    - [isLocationEnabled()](#islocationenabled)
      - [Parameters](#parameters-16)
      - [Example usage](#example-usage-18)
    - [isGpsLocationAvailable()](#isgpslocationavailable)
      - [Parameters](#parameters-17)
      - [Example usage](#example-usage-19)
    - [isGpsLocationEnabled()](#isgpslocationenabled)
      - [Parameters](#parameters-18)
      - [Example usage](#example-usage-20)
    - [isNetworkLocationAvailable()](#isnetworklocationavailable)
      - [Parameters](#parameters-19)
      - [Example usage](#example-usage-21)
    - [isNetworkLocationEnabled()](#isnetworklocationenabled)
      - [Parameters](#parameters-20)
      - [Example usage](#example-usage-22)
    - [getLocationMode()](#getlocationmode)
      - [Parameters](#parameters-21)
      - [Example usage](#example-usage-23)
    - [isLocationAuthorized()](#islocationauthorized)
      - [Parameters](#parameters-22)
      - [Example usage](#example-usage-24)
    - [getLocationAuthorizationStatus()](#getlocationauthorizationstatus)
      - [Parameters](#parameters-23)
      - [Example iOS usage](#example-ios-usage)
      - [Example Android usage](#example-android-usage)
    - [requestLocationAuthorization()](#requestlocationauthorization)
      - [Parameters](#parameters-24)
      - [Example usage](#example-usage-25)
    - [registerLocationStateChangeHandler()](#registerlocationstatechangehandler)
      - [Parameters](#parameters-25)
      - [Example usage](#example-usage-26)
    - [getLocationAccuracyAuthorization()](#getlocationaccuracyauthorization)
      - [Parameters](#parameters-26)
      - [Example usage](#example-usage-27)
    - [requestTemporaryFullAccuracyAuthorization()](#requesttemporaryfullaccuracyauthorization)
      - [Parameters](#parameters-27)
      - [Example usage](#example-usage-28)
    - [registerLocationStateChangeHandler()](#registerlocationstatechangehandler-1)
      - [Parameters](#parameters-28)
      - [Example usage](#example-usage-29)
    - [switchToLocationSettings()](#switchtolocationsettings)
  - [Bluetooth module](#bluetooth-module)
    - [bluetoothState constants](#bluetoothstate-constants)
      - [Android](#android-2)
      - [iOS](#ios-2)
      - [Example](#example-4)
    - [isBluetoothAvailable()](#isbluetoothavailable)
      - [Parameters](#parameters-29)
      - [Example usage](#example-usage-30)
    - [isBluetoothEnabled()](#isbluetoothenabled)
      - [Parameters](#parameters-30)
      - [Example usage](#example-usage-31)
    - [hasBluetoothSupport()](#hasbluetoothsupport)
      - [Parameters](#parameters-31)
      - [Example usage](#example-usage-32)
    - [hasBluetoothLESupport()](#hasbluetoothlesupport)
      - [Parameters](#parameters-32)
      - [Example usage](#example-usage-33)
    - [hasBluetoothLEPeripheralSupport()](#hasbluetoothleperipheralsupport)
      - [Parameters](#parameters-33)
      - [Example usage](#example-usage-34)
    - [getBluetoothState()](#getbluetoothstate)
      - [Parameters](#parameters-34)
      - [Example usage](#example-usage-35)
    - [setBluetoothState()](#setbluetoothstate)
      - [Parameters](#parameters-35)
      - [Example usage](#example-usage-36)
    - [requestBluetoothAuthorization()](#requestbluetoothauthorization)
      - [Parameters](#parameters-36)
      - [Example usage](#example-usage-37)
    - [registerBluetoothStateChangeHandler()](#registerbluetoothstatechangehandler)
      - [Parameters](#parameters-37)
      - [Example usage](#example-usage-38)
    - [switchToBluetoothSettings()](#switchtobluetoothsettings)
  - [WiFi module](#wifi-module)
    - [isWifiAvailable()](#iswifiavailable)
      - [Parameters](#parameters-38)
      - [Example usage](#example-usage-39)
    - [isWifiEnabled()](#iswifienabled)
      - [Parameters](#parameters-39)
      - [Example usage](#example-usage-40)
    - [setWifiState()](#setwifistate)
      - [Parameters](#parameters-40)
      - [Example usage](#example-usage-41)
    - [switchToWifiSettings()](#switchtowifisettings)
  - [Camera module](#camera-module)
    - [isCameraPresent()](#iscamerapresent)
      - [Parameters](#parameters-41)
      - [Example usage](#example-usage-42)
    - [isCameraAvailable()](#iscameraavailable)
      - [Parameters](#parameters-42)
      - [Example usage](#example-usage-43)
    - [isCameraAuthorized()](#iscameraauthorized)
      - [Parameters](#parameters-43)
      - [Example usage](#example-usage-44)
    - [getCameraAuthorizationStatus()](#getcameraauthorizationstatus)
      - [Parameters](#parameters-44)
      - [Example usage](#example-usage-45)
    - [requestCameraAuthorization()](#requestcameraauthorization)
      - [Parameters](#parameters-45)
      - [Example usage](#example-usage-46)
    - [isCameraRollAuthorized()](#iscamerarollauthorized)
      - [Parameters](#parameters-46)
      - [Example usage](#example-usage-47)
    - [getCameraRollAuthorizationStatus()](#getcamerarollauthorizationstatus)
      - [Parameters](#parameters-47)
      - [Example usage](#example-usage-48)
    - [requestCameraRollAuthorization()](#requestcamerarollauthorization)
      - [Parameters](#parameters-48)
      - [Example usage](#example-usage-49)
  - [Notifications module](#notifications-module)
    - [remoteNotificationType constants](#remotenotificationtype-constants)
      - [Example](#example-5)
    - [isRemoteNotificationsEnabled()](#isremotenotificationsenabled)
      - [Parameters](#parameters-49)
      - [Example usage](#example-usage-50)
    - [isRegisteredForRemoteNotifications()](#isregisteredforremotenotifications)
      - [Parameters](#parameters-50)
      - [Example usage](#example-usage-51)
    - [getRemoteNotificationTypes()](#getremotenotificationtypes)
      - [Parameters](#parameters-51)
      - [Example usage](#example-usage-52)
    - [getRemoteNotificationsAuthorizationStatus()](#getremotenotificationsauthorizationstatus)
      - [Parameters](#parameters-52)
      - [Example usage](#example-usage-53)
    - [requestRemoteNotificationsAuthorization()](#requestremotenotificationsauthorization)
      - [Parameters](#parameters-53)
      - [Example usage](#example-usage-54)
    - [switchToNotificationSettings()](#switchtonotificationsettings)
  - [Microphone module](#microphone-module)
    - [isMicrophoneAuthorized()](#ismicrophoneauthorized)
      - [Parameters](#parameters-54)
      - [Example usage](#example-usage-55)
    - [getMicrophoneAuthorizationStatus()](#getmicrophoneauthorizationstatus)
      - [Parameters](#parameters-55)
      - [Example usage](#example-usage-56)
    - [requestMicrophoneAuthorization()](#requestmicrophoneauthorization)
      - [Parameters](#parameters-56)
      - [Example usage](#example-usage-57)
  - [Contacts module](#contacts-module)
    - [isContactsAuthorized()](#iscontactsauthorized)
      - [Parameters](#parameters-57)
      - [Example usage](#example-usage-58)
    - [getContactsAuthorizationStatus()](#getcontactsauthorizationstatus)
      - [Parameters](#parameters-58)
      - [Example usage](#example-usage-59)
    - [requestContactsAuthorization()](#requestcontactsauthorization)
      - [Parameters](#parameters-59)
      - [Example usage](#example-usage-60)
  - [Calendar module](#calendar-module)
    - [isCalendarAuthorized()](#iscalendarauthorized)
      - [Parameters](#parameters-60)
      - [Example usage](#example-usage-61)
    - [getCalendarAuthorizationStatus()](#getcalendarauthorizationstatus)
      - [Parameters](#parameters-61)
      - [Example usage](#example-usage-62)
    - [requestCalendarAuthorization()](#requestcalendarauthorization)
      - [Parameters](#parameters-62)
      - [Example usage](#example-usage-63)
  - [Reminders module](#reminders-module)
    - [isRemindersAuthorized()](#isremindersauthorized)
      - [Parameters](#parameters-63)
      - [Example usage](#example-usage-64)
    - [getRemindersAuthorizationStatus()](#getremindersauthorizationstatus)
      - [Parameters](#parameters-64)
      - [Example usage](#example-usage-65)
    - [requestRemindersAuthorization()](#requestremindersauthorization)
      - [Parameters](#parameters-65)
      - [Example usage](#example-usage-66)
  - [Motion module](#motion-module)
    - [motionStatus constants](#motionstatus-constants)
      - [Example](#example-6)
    - [isMotionAvailable()](#ismotionavailable)
      - [Parameters](#parameters-66)
      - [Example usage](#example-usage-67)
    - [isMotionRequestOutcomeAvailable()](#ismotionrequestoutcomeavailable)
      - [Parameters](#parameters-67)
      - [Example usage](#example-usage-68)
    - [requestMotionAuthorization()](#requestmotionauthorization)
      - [Parameters](#parameters-68)
      - [Example usage](#example-usage-69)
    - [getMotionAuthorizationStatus()](#getmotionauthorizationstatus)
      - [Parameters](#parameters-69)
      - [Example usage](#example-usage-70)
  - [NFC module](#nfc-module)
    - [NFCState constants](#nfcstate-constants)
      - [Values](#values-3)
      - [Example](#example-7)
    - [isNFCPresent()](#isnfcpresent)
      - [Parameters](#parameters-70)
      - [Example usage](#example-usage-71)
    - [isNFCEnabled()](#isnfcenabled)
      - [Parameters](#parameters-71)
      - [Example usage](#example-usage-72)
    - [isNFCAvailable()](#isnfcavailable)
      - [Parameters](#parameters-72)
      - [Example usage](#example-usage-73)
    - [registerNFCStateChangeHandler()](#registernfcstatechangehandler)
      - [Parameters](#parameters-73)
      - [Example usage](#example-usage-74)
    - [switchToNFCSettings()](#switchtonfcsettings)
  - [External storage module](#external-storage-module)
    - [isExternalStorageAuthorized()](#isexternalstorageauthorized)
      - [Parameters](#parameters-74)
      - [Example usage](#example-usage-75)
    - [getExternalStorageAuthorizationStatus()](#getexternalstorageauthorizationstatus)
      - [Parameters](#parameters-75)
      - [Example usage](#example-usage-76)
    - [requestExternalStorageAuthorization()](#requestexternalstorageauthorization)
      - [Parameters](#parameters-76)
      - [Example usage](#example-usage-77)
    - [getExternalSdCardDetails()](#getexternalsdcarddetails)
      - [Parameters](#parameters-77)
      - [Example usage](#example-usage-78)
- [Platform Notes](#platform-notes)
  - [Android](#android-3)
    - [Android permissions](#android-permissions)
      - [Android runtime permissions](#android-runtime-permissions)
        - ["Dangerous" runtime permissions](#dangerous-runtime-permissions)
        - [Runtime permission groups](#runtime-permission-groups)
        - [Runtime permissions example project](#runtime-permissions-example-project)
        - [Android Camera permissions](#android-camera-permissions)
    - [Android Auto Backup](#android-auto-backup)
  - [Windows](#windows)
    - [Supported Windows versions](#supported-windows-versions)
    - [Windows 10 UWP permissions](#windows-10-uwp-permissions)
  - [iOS](#ios-3)
    - [iOS usage description messages](#ios-usage-description-messages)
- [Example project](#example-project)
  - [Screenshots](#screenshots)
    - [Android](#android-4)
    - [iOS](#ios-4)
- [Release notes](#release-notes)
- [Credits](#credits)
- [License](#license)

<!-- END doctoc generated TOC please keep comment here to allow auto update -->


# Overview

This Cordova/Phonegap plugin for iOS, Android and Windows 10 UWP is used to manage device settings such as Location,  Bluetooth and WiFi. It enables management of run-time permissions, device hardware and core OS features.

The plugin is registered in on [npm](https://www.npmjs.com/package/cordova.plugins.diagnostic) as `cordova.plugins.diagnostic`

<!-- DONATE -->
[![donate](https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG_global.gif)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=ZRD3W47HQ3EMJ)

I dedicate a considerable amount of my free time to developing and maintaining this Cordova plugin, along with my other Open Source software.
To help ensure this plugin is kept updated, new features are added and bugfixes are implemented quickly, please donate a couple of dollars (or a little more if you can stretch) as this will help me to afford to dedicate time to its maintenance. Please consider donating if you're using this plugin in an app that makes you money, if you're being paid to make the app, if you're asking for new features or priority bug fixes.
<!-- END DONATE -->


## Important notes

### Minimum supported versions
- Cordova CLI: `cordova@9.0.0`
- Android platform: `cordova-android@8.0.0` (recommended version `cordova-android@9.0.0`)
    - Android version: Android 5.0 (API 21)
- iOS platform: `cordova-ios@5.0.0`
    - iOS 10.0

Note: If you need to support older OS versions, please use an older version of this plugin.

### Native environment required
Note that this plugin is intended for use in a **native** mobile environment.
It will **NOT** work in a browser-emulated Cordova environment, for example by running `cordova serve` or using the [Ripple emulator](https://github.com/ripple-emulator/ripple).
### Building for Android

In order to avoid build problems with Android, please make sure you have the latest versions of the following Android SDK components installed:

- Android SDK Tools
- Android SDK Platform-tools
- Android SDK Build-tools
- Target SDK Platform - e.g. Android 10.0 (API 29)
- Google Repository

* Make sure you have a [supported version](#minimum-supported-versions) of the `cordova-android` platform installed.
    * You can check if the Android platform in your Cordova project is up-to-date using `cordova platform check android` and if it's not, update it using `cordova platform rm android && cordova platform add android@latest`. 
    * Since `cordova.plugins.diagnostic@6` the recommended Cordova Android platform version is `cordova-android@9.0.0` (which includes AndroidX support).
    * To use this plugin with `cordova-android@8`, install [cordova-plugin-androidx](https://github.com/dpa99c/cordova-plugin-androidx) and [cordova-plugin-androidx-adapter](https://github.com/dpa99c/cordova-plugin-androidx-adapter).    
* Phonegap Build uses should use the latest available CLI version ([listed here](https://build.phonegap.com/current-support)) by specifying using the `phonegap-version` tag in your `config.xml`.

# Installation

## Using the Cordova/Phonegap/Ionic CLI

    $ 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

## AndroidX Library
This plugin uses/depends on the [AndroidX (Jetpack) libraries](https://developer.android.com/jetpack/androidx) (these supersede the [Android Support Library](https://developer.android.com/topic/libraries/support-library/index.html) which is no longer used by this plugin since `cordova.plugins.diagnostic@6`).

This plugin pins default versions of the legacy and appcompat versions of the library  in [its `plugin.xml`](https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/plugin.xml) however you can override these to specify different versions using the `ANDROIDX_VERSION` (legacy) and `ANDROIDX_APPCOMPAT_VERSION` variables at plugin installation time, for example:

    $ cordova plugin add cordova.plugins.diagnostic --variable ANDROIDX_VERSION=1.0.0 --variable ANDROIDX_APPCOMPAT_VERSION=1.3.1


## Specifying modules
Since `cordova.plugins.diagnostic@4` the plugin is split into optional functional modules. 
The reason for this is so you can choose to install only those parts of the plugin you'll use and therefore not install redundant code/components/frameworks.

By default, all the modules will be added to your project when you install the plugin.

You can specify which modules are installed by adding a `<preference>` to your `config.xml` which specifies the modules you wish to add as a space-separated list.
Module names should be capitalised.

The preference takes the form:

    <preference name="cordova.plugins.diagnostic.modules" value="[list of modules]" />
    
For example, to explicitly include all optional modules:

    <preference name="cordova.plugins.diagnostic.modules" value="LOCATION BLUETOOTH WIFI CAMERA NOTIFICATIONS MICROPHONE CONTACTS CALENDAR REMINDERS MOTION NFC EXTERNAL_STORAGE" />
    
To install only the core module and no optional modules, leave the preference value blank:

    <preference name="cordova.plugins.diagnostic.modules" value="" />
    
### Available modules

The following optional modules are currently supported by the plugin:

- [LOCATION](#location-module) - Android, iOS, Windows 10 UWP
- [BLUETOOTH](#bluetooth-module) - Android, iOS, Windows 10 UWP
- [WIFI](#wifi-module) - Android, iOS, Windows 10 UWP
- [CAMERA](#camera-module) - Android, iOS, Windows 10 UWP
- [NOTIFICATIONS](#notifications-module) - Android, iOS
- [MICROPHONE](#microphone-module) - Android, iOS
- [CONTACTS](#contacts-module) - Android, iOS
- [CALENDAR](#calendar-module) - Android, iOS
- [REMINDERS](#reminders-module) - iOS
- [MOTION](#motion-module) - iOS
- [NFC](#nfc-module) - Android
- [EXTERNAL_STORAGE](#external-storage-module) - Android
    
**IMPORTANT:** It's vital that the preference be added to your `config.xml` **before** you install the plugin, otherwise the preference will not be applied and all modules will be added.
This is because, due to limitations of the Cordova CLI hooks, this plugin must use the `npm install` process to apply the module preferences and this runs before the Cordova CLI when installing a plugin.
If you change the modules specified in the preference, you'll need to uninstall then re-install the plugin to your project to apply the changes.    

# Reporting issues
**IMPORTANT:** Please read the following carefully. 
Failure to follow the issue template guidelines below will result in the issue being immediately closed.

## Reporting a bug or problem
Before [opening a bug issue](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/new?assignees=&labels=&template=bug_report.md&title=), please do the following:
- *DO NOT* open issues asking for support in using/integrating the plugin into your project
    - Only open issues for suspected bugs/issues with the plugin that are generic and will affect other users
    - I don't have time to offer free technical support: this is free open-source software
    - Ask for help on StackOverflow, Ionic Forums, etc.
    - Use the [example project](https://github.com/dpa99c/cordova-diagnostic-plugin-example) as a known working reference
    - Any issues requesting support will be closed immediately.
- *DO NOT* open issues related to the  [Ionic Typescript wrapper for this plugin](https://github.com/ionic-team/ionic-native/blob/master/src/%40ionic-native/plugins/diagnostic/index.ts)
    - This is owned/maintained by [Ionic](https://github.com/ionic-team) and is not part of this plugin
    - Please raise such issues/PRs against [Ionic Native](https://github.com/ionic-team/ionic-native/) instead.
	- To verify an if an issue is caused by this plugin or its Typescript wrapper, please re-test using the vanilla Javascript plugin interface (without the Ionic Native wrapper).
	- Any issue opened here which is obviously an Ionic Typescript wrapper issue will be closed immediately.
- Read the above documentation thoroughly
- Check the [CHANGELOG](https://github.com/dpa99c/cordova-diagnostic-plugin/blob/master/CHANGELOG.md) for any breaking changes that may be causing your issue.
- Check a similar issue (open or closed) does not already exist against this plugin.
	- Duplicates or near-duplicates will be closed immediately.
- When [creating a new issue](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/new/choose)
    - Choose the "Bug report" template
    - Fill out the relevant sections of the template and delete irrelevant sections
    - *WARNING:* Failure to complete the issue template will result in the issue being closed immediately. 
- Reproduce the issue using the [example project](https://github.com/dpa99c/cordova-diagnostic-plugin-example)
	- This will eliminate bugs in your code or conflicts with other code as possible causes of the issue
	- This will also validate your development environment using a known working codebase
	- If reproducing the issue using the example project is not possible, create an isolated test project that you are able to share
- Include full verbose console output when reporting build issues
    - If the full console output is too large to insert directly into the Github issue, then post it on an external site such as [Pastebin](https://pastebin.com/) and link to it from the issue 
    - Often the details of an error causing a build failure is hidden away when building with the CLI
        - To get the full detailed console output, append the `--verbose` flag to CLI build commands
        - e.g. `cordova build ios --verbose`
    - Failure to include the full console output will result in the issue being closed immediately
- If the issue relates to the plugin documentation (and not the code), please of a [documentation issue](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/new?assignees=&labels=&template=documentation-issue.md&title=)

## Requesting a new feature
Before [opening a feature request issue](https://github.com/dpa99c/cordova-diagnostic-plugin/issues/new?assignees=&labels=&template=feature_request.md&title=), please do the following:
- Check the above documentation to ensure the feature you are requesting doesn't already exist
- Check the list if open/closed issues to check if there's a reason that feature hasn't been included already
- Ensure the feature you are requesting is actually possible to implement and generically useful to other users than yourself
- Where possible, post a link to the documentation related to the feature you are requesting
- Include other relevant links, e.g.
    - Stack Overflow post illustrating a solution
    - Code within another Github repo that illustrates a solution 


# Usage

The core plugin module is exposed via the global `cordova.plugins.diagnostic` object and it aliases all functions and properties of the other optional modules.
If a function is called on the core module for an optional module which is not installed, a JS error will be raised by the core module.

## Core module

Purpose: Generic and miscellaneous functionality.

Platforms: Android, iOS and Windows 10 UWP

Configuration name: N/A - always installed, regardless of whether the module preference key is present in `config.xml`.

### switchToSettings()

Platforms: Android and iOS

Opens settings page for this app.

On Android, this opens the "App Info" page in the Settings app.

On iOS, this opens the app settings page in the Settings app.

    cordova.plugins.diagnostic.switchToSettings(successCallback, errorCallback);

#### Parameters

- {Function} successCallback - The callback which will be called when switch to settings is successful.
- {Function} errorCallback - The callback which will be called when switch to settings encounters an error. The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.switchToSettings(function(){
        console.log("Successfully switched to Settings app");
    }, function(error){
        console.error("The following error occurred: "+error);
    });
    
### switchToWirelessSettings()

Platforms: Android

Switches to the wireless settings page in the Settings app.
Allows configuration of wireless controls such as Wi-Fi, Bluetooth and Mobile networks.

    cordova.plugins.diagnostic.switchToWirelessSettings();
        
### switchToMobileDataSettings()

Platforms: Android and Windows 10 UWP

Displays mobile settings to allow user to enable mobile data.

    cordova.plugins.diagnostic.switchToMobileDataSettings();
    
    
### permissionStatus constants

Platforms: Android and iOS

Both Android and iOS define constants for requesting and reporting the various permission states.

    cordova.plugins.diagnostic.permissionStatus

#### Android

The following permission states are defined for Android:

- `NOT_REQUESTED` - App has not yet requested access to this permission.
App can request permission and user will be prompted to allow/deny.
- `DENIED_ONCE` - User denied access to this permission (without checking "Never Ask Again" box).
App can request permission again and user will be prompted again to allow/deny again.
- `DENIED_ALWAYS` - User denied access to this permission and checked "Never Ask Again" box.
App can never ask for permission again.
The only way around this is to instruct the user to manually change the permission on the app permissions page in Settings.
- `GRANTED` - User granted access to this permission or the device is running Android 5.x or below.

⚠ Since it's impossible to distinguish between NOT_REQUESTED and DENIED_ALWAYS using the native Android runtime permissions API (they both return the same constant value), this plugin attempts to distinguish the difference by using HTML5 local storage to keep track of which permissions have been requested since the app was first installed. On requesting a permission for the first time, an entry is put into local storage against the permission name. If the user then selects DENY_ALWAYS, the plugin uses the flag in local storage to distinguish this from NOT_REQUESTED.

Some things to watch out for:

 - Clearing local storage will result in this data being lost and will result in NOT_REQUESTED being returned even if the user previously chose to always deny permission.
 - If the relevant `<uses-permission>` tag is missing from the Android manifest, then the native API will return the NOT_REQUESTED/DENIED_ALWAYS constant value. Since the plugin is unable to make the native permissions request in order to show the native dialog, the plugin will always return NOT_REQUESTED.

If [Android Autobackup](https://developer.android.com/guide/topics/data/backup.html#Choosing) is enabled (which it is by default ), Android does not backup app permissions after uninstall but does backup HTML5 local storage. This may lead to a permission being reported by the plugin as DENIED_ALWAYS when the actual status is NOT_REQUESTED.
To avoid this you may want to disable Android Autobackup. You can do this using the [cordova-custom-config plugin](https://github.com/dpa99c/cordova-custom-config), for example: 

```
<platform name="android">
    <plugin name="cordova-custom-config" version="*"/>
    <custom-preference name="android-manifest/application/@android:allowBackup" value="false" />
    <custom-preference name="android-manifest/application/@android:fullBackupContent" value="false" />
</platform>
```

#### iOS

The following permission states are defined for iOS:

- `NOT_REQUESTED` - App has not yet requested access to this permission.
App can request permission and user will be prompted to allow/deny.
- `DENIED_ALWAYS` - User denied access to this permission.
App can never ask for permission again.
The only way around this is to instruct the user to manually change the permission in Settings.
- `RESTRICTED` - Permission is unavailable and user cannot enable it.
For example, when parental controls are in effect for the current user.
- `GRANTED` - User granted access to this permission.
For location permission, this indicates the user has granted access to the permission "always" (when app is both in foreground and background).
- `GRANTED_WHEN_IN_USE` - Used only for location permission.
Indicates the user has granted access to the permission "when in use" (only when the app is in the foreground).

#### Example

    if(somePermissionStatus === cordova.plugins.diagnostic.permissionStatus.GRANTED){
        // Do something
    }

### getPermissionAuthorizationStatus()

Platforms: Android

Returns the current authorisation status for a given permission.

Note: this is intended for Android 6 / API 23 and above. Calling on Android 5.1 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.

#### Parameters

- {Function} successCallback - function to call on successful retrieval of status.
The function is passed a single string parameter which defines the current [permission status](#permissionstatus-constants)
- {Function} errorCallback - function to call on failure to retrieve authorisation status.
The function is passed a single string parameter containing the error message.
- {String} permission - permission to request authorisation status for, defined as a [runtime permission constant](#dangerous-runtime-permissions).

#### Example usage

    cordova.plugins.diagnostic.getPermissionAuthorizationStatus(function(status){
        switch(status){
            case cordova.plugins.diagnostic.permissionStatus.GRANTED:
                console.log("Permission granted to use the camera");
                break;
            case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
                console.log("Permission to use the camera has not been requested yet");
                break;
            case cordova.plugins.diagnostic.permissionStatus.DENIED_ONCE:
                console.log("Permission denied to use the camera - ask again?");
                break;
            case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
                console.log("Permission permanently denied to use the camera - guess we won't be using it then!");
                break;
        }
    }, function(error){
        console.error("The following error occurred: "+error);
    }, cordova.plugins.diagnostic.permission.CAMERA);

### getPermissionsAuthorizationStatus()

Platforms: Android

Returns the current authorisation status for multiple permissions.

Note: this is intended for Android 6 / API 23 and above. Calling on Android 5.1 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.

#### Parameters

- {Function} successCallback - function to call on successful retrieval of status.
The function is passed a single object parameter which defines a key/value map, where the key is the requested [runtime permission](#dangerous-runtime-permissions), and the value is the current [permission status](#permissionstatus-constants).
- {Function} errorCallback - function to call on failure to retrieve authorisation status.
The function is passed a single string parameter containing the error message.
- {Array} permissions - list of permissions to request authorisation statuses for, defined as [runtime permission constants](#dangerous-runtime-permissions).

#### Example usage

    cordova.plugins.diagnostic.getPermissionsAuthorizationStatus(function(statuses){
        for (var permission in statuses){
            switch(statuses[permission]){
                case cordova.plugins.diagnostic.permissionStatus.GRANTED:
                    console.log("Permission granted to use "+permission);
                    break;
                case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
                    console.log("Permission to use "+permission+" has not been requested yet");
                    break;
                case cordova.plugins.diagnostic.permissionStatus.DENIED_ONCE:
                    console.log("Permission denied to use "+permission+" - ask again?");
                    break;
                case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
                    console.log("Permission permanently denied to use "+permission+" - guess we won't be using it then!");
                    break;
            }
        }
    }, function(error){
        console.error("The following error occurred: "+error);
    },[
        cordova.plugins.diagnostic.permission.ACCESS_FINE_LOCATION,
        cordova.plugins.diagnostic.permission.ACCESS_COARSE_LOCATION
    ]);

### requestRuntimePermission()

Platforms: Android

Requests app to be granted authorisation for a runtime permission.

Note: this is intended for Android 6 / API 23 and above. Calling on Android 5.1 / API 22 and below will have no effect as the permissions are already granted at installation time.

#### Parameters

- {Function} successCallback - function to call on successful request for runtime permission.
The function is passed a single string parameter which defines the resulting [permission status](#permissionstatus-constants)
- {Function} errorCallback - function to call on failure to request authorisation.
The function is passed a single string parameter containing the error message.
- {String} permission - permission to request authorisation for, defined as a [runtime permission constant](#dangerous-runtime-permissions).

#### Example usage

    cordova.plugins.diagnostic.requestRuntimePermission(function(status){
        switch(status){
            case cordova.plugins.diagnostic.permissionStatus.GRANTED:
                console.log("Permission granted to use the camera");
                break;
            case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
                console.log("Permission to use the camera has not been requested yet");
                break;
            case cordova.plugins.diagnostic.permissionStatus.DENIED_ONCe:
                console.log("Permission denied to use the camera - ask again?");
                break;
            case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
                console.log("Permission permanently denied to use the camera - guess we won't be using it then!");
                break;
        }
    }, function(error){
        console.error("The following error occurred: "+error);
    }, cordova.plugins.diagnostic.permission.CAMERA);

### requestRuntimePermissions()

Platforms: Android

Requests app to be granted authorisation for multiple runtime permissions.

Note: this is intended for Android 6 / API 23 and above. Calling on Android 5.1 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.

#### Parameters

- {Function} successCallback - function to call on successful request for runtime permissions.
The function is passed a single object parameter which defines a key/value map, where the key is the [runtime permission](#dangerous-runtime-permissions) to request, and the value is the current [permission status](#permissionstatus-constants).
- {Function} errorCallback - function to call on failure to request authorisation.
The function is passed a single string parameter containing the error message.
- {Array} permissions - list of permissions to request authorisation for, defined as [runtime permission constants](#dangerous-runtime-permissions).

#### Example usage

    cordova.plugins.diagnostic.requestRuntimePermissions(function(statuses){
        for (var permission in statuses){
            switch(statuses[permission]){
                case cordova.plugins.diagnostic.permissionStatus.GRANTED:
                    console.log("Permission granted to use "+permission);
                    break;
                case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
                    console.log("Permission to use "+permission+" has not been requested yet");
                    break;
                case cordova.plugins.diagnostic.permissionStatus.DENIED_ONCE:
                    console.log("Permission denied to use "+permission+" - ask again?");
                    break;
                case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
                    console.log("Permission permanently denied to use "+permission+" - guess we won't be using it then!");
                    break;
            }
        }
    }, function(error){
        console.error("The following error occurred: "+error);
    },[
        cordova.plugins.diagnostic.permission.ACCESS_FINE_LOCATION,
        cordova.plugins.diagnostic.permission.ACCESS_COARSE_LOCATION
    ]);

### isRequestingPermission()

Platforms: Android

Indicates if the plugin is currently requesting a runtime permission via the native API.
Note that only one request can be made concurrently because the native API cannot handle concurrent requests,
so the plugin will invoke the error callback if attempting to make more than one simultaneous request.
Multiple permission requests should be grouped into a single call since the native API is setup to handle batch requests of multiple permission groups.

    var isRequesting = cordova.plugins.diagnostic.isRequestingPermission();

#### Example usage

    var isRequesting = cordova.plugins.diagnostic.isRequestingPermission();
    if(!isRequesting){
        requestSomePermissions();
    }else{
        cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(function(statuses){
            cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(null); // de-register handler after single call
            requestSomePermissions();
        });
    }

### registerPermissionRequestCompleteHandler()

Platforms: Android

Registers a function to be called when a runtime permission request has completed.
Pass in a falsey value to de-register the currently registered function.

    cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(successCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when a runtime permission request has completed.
The function is passed a single object parameter which defines a key/value map, where the key is the permission requested (defined as a value in cordova.plugins.diagnostic.permission) and the value is the resulting authorisation status of that permission as a value in cordova.plugins.diagnostic.permissionStatus.

#### Example usage

    function onPermissionRequestComplete(statuses){
        console.info("Permission request complete");
        for (var permission in statuses){
            switch(statuses[permission]){
                case cordova.plugins.diagnostic.permissionStatus.GRANTED:
                    console.log("Permission granted to use "+permission);
                    break;
                case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
                    console.log("Permission to use "+permission+" has not been requested yet");
                    break;
                case cordova.plugins.diagnostic.permissionStatus.DENIED_ONCE:
                    console.log("Permission denied to use "+permission);
                    break;
                case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
                    console.log("Permission permanently denied to use "+permission);
                    break;
            }
        }
        cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(null); // de-register handler
    }
    cordova.plugins.diagnostic.registerPermissionRequestCompleteHandler(onPermissionRequestComplete);

### isDataRoamingEnabled()

Platforms: Android

Checks if the device data roaming setting is enabled.
Returns true if data roaming is enabled.

    cordova.plugins.diagnostic.isDataRoamingEnabled(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when the operation is successful.
The function is passed a single boolean parameter which is TRUE if data roaming is enabled.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isDataRoamingEnabled(function(enabled){
        console.log("Data roaming is " + (enabled ? "enabled" : "disabled"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });
        

### isADBModeEnabled()

Platforms: Android

Checks if the device setting for ADB(debug) is switched on.
Returns true if ADB(debug) setting is switched on.

    cordova.plugins.diagnostic.isADBModeEnabled(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if ADB mode(debug mode) is switched on.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isADBModeEnabled(function(enabled){
        console.log("ADB mode(debug mode) is " + (enabled ? "enabled" : "disabled"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });

### isDeviceRooted()

Platforms: Android

Checks if the device is rooted.
Returns true if the device is rooted.

    cordova.plugins.diagnostic.isDeviceRooted(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if the device is rooted.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isDeviceRooted(function(rooted){
        console.log("device is " + (rooted ? "rooted" : "not rooted"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });
    

### isBackgroundRefreshAuthorized()

Platforms: iOS

Checks if the application is authorized for background refresh.

    cordova.plugins.diagnostic.isBackgroundRefreshAuthorized(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if background refresh access is authorized for use.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isBackgroundRefreshAuthorized(function(authorized){
        console.log("App is " + (authorized ? "authorized" : "not authorized") + " to perform background refresh");
    }, function(error){
        console.error("The following error occurred: "+error);
    });

### getBackgroundRefreshStatus()

Platforms: iOS

Returns the background refresh authorization status for the application.

    cordova.plugins.diagnostic.getBackgroundRefreshStatus(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single string parameter which indicates the authorization status as a [permissionStatus constant](#permissionstatus-constants).
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.

#### Example usage

    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);
    });

### cpuArchitecture constants

Platforms: Android and iOS

Defines constants for the various CPU architectures of the current hardware returned by [getArchitecture()](#getarchitecture).

        cordova.plugins.diagnostic.cpuArchitecture

#### Android

- `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)

#### 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)

#### Example usage

See [getArchitecture()](#getarchitecture).
    

### getArchitecture()

Platforms: Android and iOS

Returns the CPU architecture of the current device.

    cordova.plugins.diagnostic.getArchitecture(successCallback, errorCallback);
    
#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which indicates the location authorization status as a [cpuArchitecture constant](#cpuarchitecture-constants).
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.

#### Example usage

    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);
    });
    

### restart()

Platforms: Android

Restarts the application.
By default, a "warm" restart will be performed in which the main Cordova activity is immediately restarted, causing the Webview instance to be recreated.

However, if the `cold` parameter is set to true, then the application will be "cold" restarted, meaning a system exit will be performed, causing the entire application to be restarted.
This is useful if you want to fully reset the native application state but will cause the application to briefly disappear and re-appear.

Note: There is no `successCallback()` since if the operation is successful, the application will restart immediately before any success callback can be applied.

    cordova.plugins.diagnostic.restart(errorCallback, cold);

#### Parameters

- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.
- {Boolean} cold - if true the application will be cold restarted. Defaults to false.


#### Example usage

    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);
    

### enableDebug()

Platforms: Android and iOS

Enables debug mode, which logs native debug messages to the native and JS consoles.
- For Android, log messages will appear in the native logcat output and in the JS console if Chrome Developer Tools is connected to the app Webview.
- For iOS, log messages will appear in the native Xcode console output and in the JS console if Safari Web Inspector is connected to the app Webview.
- Debug mode is initially disabled on plugin initialisation.


    cordova.plugins.diagnostic.enableDebug(successCallback);
    
#### Parameters

- {Function} successCallback - The callback which will be called when debug has been enabled.

#### Example usage

    cordova.plugins.diagnostic.enableDebug(function(){
        console.log("Debug is enabled"));
    });

### getCurrentBatteryLevel()

Platforms: Android and iOS

Returns the current battery level of the device as a percentage.


    cordova.plugins.diagnostic.getCurrentBatteryLevel(successCallback, successCallback);
    
#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single `int` parameter which indicates the current battery level percentage.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single `string` parameter containing the error message.

#### Example usage

    cordova.plugins.diagnostic.getCurrentBatteryLevel(function(level){
        console.log(`Current battery level is ${level}%`);
    });    


## Location module

Purpose: Location/GPS functionality

Platforms: Android, iOS and Windows 10 UWP

Configuration name: `LOCATION`

### locationMode constants

Platforms: Android

Defines constants for the various location modes on Android.

    cordova.plugins.diagnostic.locationMode

#### Values

- `HIGH_ACCURACY` - GPS hardware, network triangulation and Wifi network IDs (high and low accuracy)
- `BATTERY_SAVING` - Network triangulation and Wifi network IDs (low accuracy)
- `DEVICE_ONLY` -  GPS hardware (high accuracy)
- `LOCATION_OFF` - Location services disabled (no accuracy)

#### Example

    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);
    });

### locationAuthorizationMode constants

Platforms: Android & iOS

Defines constants for the various location authorization modes on iOS and Android >= 10.

    cordova.plugins.diagnostic.locationAuthorizationMode

#### Values

- `ALWAYS` - Requires constant access to location in order to track position, even when the screen is off or the app is in the background.
- `WHEN_IN_USE` - Requires access to location when the screen is on and the app is displayed.

#### Example

    cordova.plugins.diagnostic.requestLocationAuthorization(function(status){
        console.log(status);
    }, function(error){
        console.error(error);
    }, cordova.plugins.diagnostic.locationAuthorizationMode.ALWAYS);
    
### locationAccuracyAuthorization constants

Platforms: iOS

- Defines constants for the various location accuracy authorization states on iOS 14+.
- See [CLAccuracyAuthorization](https://developer.apple.com/documentation/corelocation/claccuracyauthorization).


    cordova.plugins.diagnostic.locationAccuracyAuthorization

#### Values

- `FULL` - The user authorized the app to access location data with full accuracy.
- `REDUCED` - The user authorized the app to access location data with [reduced accuracy](https://developer.apple.com/documentation/corelocation/kcllocationaccuracyreduced) (~1-20 km).

#### Example

    cordova.plugins.diagnostic.locationAccuracyAuthorization(function(accuracy){
        console.log(accuracy);
    }, function(error){
        console.error(error);
    });


### isLocationAvailable()

Platforms: Android, iOS and Windows 10 UWP

Checks if app is able to access device location.

    cordova.plugins.diagnostic.isLocationAvailable(successCallback, errorCallback);

On iOS and Windows 10 UWP this returns true if both the device setting is enabled AND the application is authorized to use location.
When location is enabled, the locations returned are by a mixture GPS hardware, network triangulation and Wifi network IDs.

On Android, this returns true if Location mode is enabled and any mode is selected (e.g. Battery saving, Device only, High accuracy)
AND if the app is authorised to use location.
When location is enabled, the locations returned are dependent on the location mode:

* Battery saving = network triangulation and Wifi network IDs (low accuracy)
* Device only = GPS hardware only (high accuracy)
* High accuracy = GPS hardware, network triangulation and Wifi network IDs (high and low accuracy)

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if location is available for use.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isLocationAvailable(function(available){
        console.log("Location is " + (available ? "available" : "not available"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });

### isLocationEnabled()

Platforms: Android and iOS

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.

    cordova.plugins.diagnostic.isLocationEnabled(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if location setting is enabled.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isLocationEnabled(function(enabled){
        console.log("Location setting is " + (enabled ? "enabled" : "disabled"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });
    
### isGpsLocationAvailable()

Platforms: Android

Checks if high-accuracy locations are available to the app from GPS hardware.
Returns true if Location mode is enabled and is set to "Device only" or "High accuracy" AND if the app is authorised to use location.

    cordova.plugins.diagnostic.isGpsLocationAvailable(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if high-accuracy GPS-based location is available.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isGpsLocationAvailable(function(available){
        console.log("GPS location is " + (available ? "available" : "not available"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });

### isGpsLocationEnabled()

Platforms: Android

Checks if the device location setting is set to return high-accuracy locations from GPS hardware.
Returns true if Location mode is enabled and is set to either:

- Device only = GPS hardware only (high accuracy)
- High accuracy = GPS hardware, network triangulation and Wifi network IDs (high and low accuracy)


    cordova.plugins.diagnostic.isGpsLocationEnabled(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if device setting is set to return high-accuracy GPS-based location.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isGpsLocationEnabled(function(enabled){
        console.log("GPS location is " + (enabled ? "enabled" : "disabled"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });

### isNetworkLocationAvailable()

Platforms: Android

Checks if low-accuracy locations are available to the app from network triangulation/WiFi access points.
Returns true if Location mode is enabled and is set to "Battery saving" or "High accuracy"
AND if the app is authorised to use location.

    cordova.plugins.diagnostic.isNetworkLocationAvailable(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if low-accuracy network-based location is available.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isNetworkLocationAvailable(function(available){
        console.log("Network location is " + (available ? "available" : "not available"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });

### isNetworkLocationEnabled()

Platforms: Android

Checks if location mode is set to return low-accuracy locations from network triangulation/WiFi access points
Returns true if Location mode is enabled and is set to either:

- Battery saving = network triangulation and Wifi network IDs (low accuracy)
- High accuracy = GPS hardware, network triangulation and Wifi network IDs (high and low accuracy)


    cordova.plugins.diagnostic.isNetworkLocationEnabled(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single boolean parameter which is TRUE if device setting is set to return low-accuracy network-based location.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    cordova.plugins.diagnostic.isNetworkLocationEnabled(function(enabled){
        console.log("Network location is " + (enabled ? "enabled" : "disabled"));
    }, function(error){
        console.error("The following error occurred: "+error);
    });
    

### getLocationMode()

Platforms: Android

Returns the current location mode setting for the device.

    cordova.plugins.diagnostic.getLocationMode(successCallback, errorCallback);

#### Parameters

- {Function} successCallback -  The callback which will be called when operation is successful.
The function is passed a single string parameter indicating the current location mode
as a constant in `cordova.plugins.diagnostic.locationMode`.
- {Function} errorCallback -  The callback which will be called when operation encounters an error.
The function is passed a single string parameter containing the error message.


#### Example usage

    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);
    });

### isLocationAuthorized()

Platforms: Android and iOS

Checks if the application is authorized to use location.

Notes for Android:

- This is intended for Android 6 / API 23 and above.
Calling on Android 5.1 / API 22 and below will always return GRANTED status as permissions are already granted at installation time.

    `cordova.plugins.diagnostic.isLocationAuthorized(successCallback, errorCallback);`

#### Parame