cordova.plugins.diagnostic 7.2.9 → 7.2.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,8 @@
1
1
  # CHANGELOG
2
2
 
3
+ **v7.2.10**
4
+ (ios) feat: support optional specification of desired location accuracy when requesting location accuracy permission.
5
+
3
6
  **v7.2.9**
4
7
  (ios) crashfix: Refactored local-network permission flow to use one deterministic start path with guarded callback handling:
5
8
  - Consolidated duplicated browse/publish start logic into a single helper used by both status and authorisation APIs.
package/README.md CHANGED
@@ -639,17 +639,17 @@ App can never ask for permission again.
639
639
  The only way around this is to instruct the user to manually change the permission in Settings.
640
640
  - `RESTRICTED` - Permission is unavailable and user cannot enable it.
641
641
  For example, when parental controls are in effect for the current user.
642
- - `GRANTED` - User granted access to this permission.
643
- For location permission, this indicates the user has granted access to the permission "always" (when app is both in foreground and background).
644
- - `GRANTED_WHEN_IN_USE` - Used only for location permission.
645
- Indicates the user has granted access to the permission "when in use" (only when the app is in the foreground).
646
-
647
- Addtionally, for notifications permissions:
648
- - `PROVISIONAL` - The app is provisionally authorized to post non-interruptive user notifications.
649
- - `EPHEMERAL` - The app is authorized to schedule or receive notifications for a limited amount of time.
650
-
651
- For cases where the platform cannot return a definitive answer, the plugin also exposes:
652
- - `UNKNOWN` (Android and iOS) - Returned when the underlying OS has not yet provided a concrete status (for example, if an iOS Local Network probe timed out). Treat this as a transient state and retry before surfacing a denial to the user.
642
+ - `GRANTED` - User granted access to this permission.
643
+ For location permission, this indicates the user has granted access to the permission "always" (when app is both in foreground and background).
644
+ - `GRANTED_WHEN_IN_USE` - Used only for location permission.
645
+ Indicates the user has granted access to the permission "when in use" (only when the app is in the foreground).
646
+
647
+ Addtionally, for notifications permissions:
648
+ - `PROVISIONAL` - The app is provisionally authorized to post non-interruptive user notifications.
649
+ - `EPHEMERAL` - The app is authorized to schedule or receive notifications for a limited amount of time.
650
+
651
+ For cases where the platform cannot return a definitive answer, the plugin also exposes:
652
+ - `UNKNOWN` (Android and iOS) - Returned when the underlying OS has not yet provided a concrete status (for example, if an iOS Local Network probe timed out). Treat this as a transient state and retry before surfacing a denial to the user.
653
653
 
654
654
  #### Example
655
655
 
@@ -1411,6 +1411,7 @@ Platforms: Android & iOS
1411
1411
 
1412
1412
  - Defines constants for the various location accuracy authorization states on iOS 14+ and Android 12+.
1413
1413
  - See [CLAccuracyAuthorization](https://developer.apple.com/documentation/corelocation/claccuracyauthorization) for iOS 14+ and [approximate location](https://developer.android.com/training/location/permissions#approximate-request) for Android 12+
1414
+ - On iOS, these values can also be passed to `requestLocationAuthorization()` to set the desired [CLLocationAccuracy](https://developer.apple.com/documentation/corelocation/cllocationaccuracy).
1414
1415
 
1415
1416
  ```
1416
1417
  cordova.plugins.diagnostic.locationAccuracyAuthorization
@@ -1418,8 +1419,14 @@ cordova.plugins.diagnostic.locationAccuracyAuthorization
1418
1419
 
1419
1420
  #### Values
1420
1421
 
1421
- - `FULL` - The user authorized the app to access location data with full accuracy.
1422
- - `REDUCED` - The user authorized the app to access location data with reduced accuracy.
1422
+ - `FULL` - The user authorized the app to access location data with full accuracy. Alias for `BEST`. On iOS, sets `kCLLocationAccuracyBest`.
1423
+ - `REDUCED` - The user authorized the app to access location data with reduced accuracy. On iOS, sets `kCLLocationAccuracyReduced` - approximate location preserving region/city, typically within 1-20km, no GPS hardware engagement.
1424
+ - `BEST` - On iOS, sets `kCLLocationAccuracyBest`. May engage GPS hardware.
1425
+ - `BEST_FOR_NAVIGATION` - On iOS, sets `kCLLocationAccuracyBestForNavigation`. Highest accuracy using additional sensor data.
1426
+ - `NEAREST_TEN_METERS` - On iOS, sets `kCLLocationAccuracyNearestTenMeters`.
1427
+ - `HUNDRED_METERS` - On iOS, sets `kCLLocationAccuracyHundredMeters`.
1428
+ - `KILOMETER` - On iOS, sets `kCLLocationAccuracyKilometer`.
1429
+ - `THREE_KILOMETERS` - On iOS, sets `kCLLocationAccuracyThreeKilometers`.
1423
1430
 
1424
1431
 
1425
1432
  ### isLocationAvailable()
@@ -1821,6 +1828,16 @@ Notes for Android:
1821
1828
  - When the plugin is running on/built with Android 12+ / API 31+, you can specify requested location accuracy using the `accuracy` parameter.
1822
1829
  - If the build SDK/device version is <= Android 11 / API 30, `FULL` accuracy is implicitly granted.
1823
1830
 
1831
+ On iOS, the `accuracy` parameter sets the `desiredAccuracy` of the internal `CLLocationManager` used by the plugin:
1832
+ - `FULL` / `BEST` (default) - sets `kCLLocationAccuracyBest`, which may engage GPS hardware.
1833
+ - `REDUCED` - sets `kCLLocationAccuracyReduced`, providing approximate location (typically within 1-20km) without engaging GPS hardware.
1834
+ - `BEST_FOR_NAVIGATION` - sets `kCLLocationAccuracyBestForNavigation`, the highest accuracy using additional sensor data.
1835
+ - `NEAREST_TEN_METERS` - sets `kCLLocationAccuracyNearestTenMeters`.
1836
+ - `HUNDRED_METERS` - sets `kCLLocationAccuracyHundredMeters`.
1837
+ - `KILOMETER` - sets `kCLLocationAccuracyKilometer`.
1838
+ - `THREE_KILOMETERS` - sets `kCLLocationAccuracyThreeKilometers`.
1839
+ - Apps that only need the location permission for non-location purposes (e.g. to access the Wi-Fi SSID) should use `REDUCED` to avoid unnecessary battery drain.
1840
+
1824
1841
  ```
1825
1842
  cordova.plugins.diagnostic.requestLocationAuthorization(successCallback, errorCallback, mode, accuracy);
1826
1843
  ```
@@ -1833,9 +1850,10 @@ cordova.plugins.diagnostic.requestLocationAuthorization(successCallback, errorCa
1833
1850
  - The function is passed a single string parameter containing the error message.
1834
1851
  - {String} mode - (optional / iOS & Android >= 10) location authorization mode specified as a [locationAuthorizationMode constant](#locationauthorizationmode-constants).
1835
1852
  - If not specified, defaults to `WHEN_IN_USE`.
1836
- - {String} accuracy - (optional / Android 12+) requested location accuracy as a constant in `cordova.plugins.diagnostic.locationAccuracyAuthorization`
1853
+ - {String} accuracy - (optional / iOS & Android 12+) requested location accuracy as a constant in `cordova.plugins.diagnostic.locationAccuracyAuthorization`
1837
1854
  - If not specified, defaults to `cordova.plugins.diagnostic.locationAccuracyAuthorization.FULL`
1838
- - On Android <12 & iOS, has no effect.
1855
+ - On iOS, sets the CLLocationManager's desiredAccuracy - see [locationAccuracyAuthorization constants](#locationaccuracyauthorization-constants) for the full list of available values.
1856
+ - On Android <12, has no effect.
1839
1857
 
1840
1858
  #### Example usage
1841
1859
 
@@ -2458,80 +2476,80 @@ The function is passed a single string parameter containing the error message.
2458
2476
 
2459
2477
  Platforms: iOS
2460
2478
 
2461
- Checks if the app is authorised to access devices on the local network (iOS 14+).
2462
- On iOS versions prior to 14 this will always return TRUE as no local network authorization is required.
2463
- An optional third argument allows you to override the fallback timeout (defaults to 2 seconds) by passing `{ timeoutMs: <number> }`.
2479
+ Checks if the app is authorised to access devices on the local network (iOS 14+).
2480
+ On iOS versions prior to 14 this will always return TRUE as no local network authorization is required.
2481
+ An optional third argument allows you to override the fallback timeout (defaults to 2 seconds) by passing `{ timeoutMs: <number> }`.
2464
2482
 
2465
2483
  cordova.plugins.diagnostic.isLocalNetworkAuthorized(successCallback, errorCallback);
2466
2484
 
2467
- #### Parameters
2468
-
2469
- - {Function} successCallback - The callback which will be called when operation is successful.
2470
- The function is passed a single boolean parameter which is TRUE if the app is authorised to use the Local Network.
2471
- - {Function} errorCallback - The callback which will be called when operation encounters an error.
2472
- The function is passed a single string parameter containing the error message.
2473
- - {Object} [options] - Optional timeout control object. Provide `timeoutMs` (milliseconds) to override the default 2000 ms timeout.
2485
+ #### Parameters
2486
+
2487
+ - {Function} successCallback - The callback which will be called when operation is successful.
2488
+ The function is passed a single boolean parameter which is TRUE if the app is authorised to use the Local Network.
2489
+ - {Function} errorCallback - The callback which will be called when operation encounters an error.
2490
+ The function is passed a single string parameter containing the error message.
2491
+ - {Object} [options] - Optional timeout control object. Provide `timeoutMs` (milliseconds) to override the default 2000 ms timeout.
2474
2492
 
2475
2493
 
2476
2494
  #### Example usage
2477
2495
 
2478
- cordova.plugins.diagnostic.isLocalNetworkAuthorized(function(authorized){
2479
- console.log("Local Network is " + (authorized ? "authorized" : "unauthorised"));
2480
- }, function(error){
2481
- console.error("The following error occurred: "+error);
2482
- });
2483
-
2484
- To wait longer before treating a slow response as indeterminate:
2485
-
2486
- ```
2487
- cordova.plugins.diagnostic.isLocalNetworkAuthorized(
2488
- function(authorized){
2489
- console.log("Local Network authorized? " + authorized);
2490
- },
2491
- console.error,
2492
- { timeoutMs: 8000 }
2493
- );
2494
- ```
2496
+ cordova.plugins.diagnostic.isLocalNetworkAuthorized(function(authorized){
2497
+ console.log("Local Network is " + (authorized ? "authorized" : "unauthorised"));
2498
+ }, function(error){
2499
+ console.error("The following error occurred: "+error);
2500
+ });
2501
+
2502
+ To wait longer before treating a slow response as indeterminate:
2503
+
2504
+ ```
2505
+ cordova.plugins.diagnostic.isLocalNetworkAuthorized(
2506
+ function(authorized){
2507
+ console.log("Local Network authorized? " + authorized);
2508
+ },
2509
+ console.error,
2510
+ { timeoutMs: 8000 }
2511
+ );
2512
+ ```
2495
2513
 
2496
2514
  ### getLocalNetworkAuthorizationStatus()
2497
2515
 
2498
2516
  Platforms: iOS
2499
2517
 
2500
- Returns the app's Local Network authorization status.
2501
- On iOS 14+ this returns one of the values in `cordova.plugins.diagnostic.permissionStatus`: `NOT_REQUESTED`, `GRANTED`, `DENIED_ALWAYS`, `UNKNOWN`.
2502
- `UNKNOWN` indicates that iOS did not return a definitive answer before the timeout elapsed, so the app can retry before warning the user.
2503
- On iOS versions prior to 14 this will always return `GRANTED` as no authorization is required.
2518
+ Returns the app's Local Network authorization status.
2519
+ On iOS 14+ this returns one of the values in `cordova.plugins.diagnostic.permissionStatus`: `NOT_REQUESTED`, `GRANTED`, `DENIED_ALWAYS`, `UNKNOWN`.
2520
+ `UNKNOWN` indicates that iOS did not return a definitive answer before the timeout elapsed, so the app can retry before warning the user.
2521
+ On iOS versions prior to 14 this will always return `GRANTED` as no authorization is required.
2504
2522
 
2505
2523
  cordova.plugins.diagnostic.getLocalNetworkAuthorizationStatus(successCallback, errorCallback);
2506
2524
 
2507
2525
  #### Parameters
2508
2526
 
2509
- - {Function} successCallback - The callback which will be called when operation is successful.
2510
- The function is passed a single string parameter which is one of the values in `cordova.plugins.diagnostic.permissionStatus`:
2511
- `NOT_REQUESTED`, `GRANTED`, `DENIED_ALWAYS`, `UNKNOWN`.
2512
- - {Function} errorCallback - The callback which will be called when operation encounters an error.
2513
- The function is passed a single string parameter containing the error message.
2514
- - {Object} [options] - Optional timeout override (defaults to 2 seconds). Provide `timeoutMs` (milliseconds) to customize the fallback duration.
2527
+ - {Function} successCallback - The callback which will be called when operation is successful.
2528
+ The function is passed a single string parameter which is one of the values in `cordova.plugins.diagnostic.permissionStatus`:
2529
+ `NOT_REQUESTED`, `GRANTED`, `DENIED_ALWAYS`, `UNKNOWN`.
2530
+ - {Function} errorCallback - The callback which will be called when operation encounters an error.
2531
+ The function is passed a single string parameter containing the error message.
2532
+ - {Object} [options] - Optional timeout override (defaults to 2 seconds). Provide `timeoutMs` (milliseconds) to customize the fallback duration.
2515
2533
 
2516
2534
 
2517
2535
  #### Example usage
2518
2536
 
2519
2537
  cordova.plugins.diagnostic.getLocalNetworkAuthorizationStatus(function(status){
2520
- switch(status){
2521
- case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
2522
- console.log("Local Network permission not requested");
2523
- break;
2524
- case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
2525
- console.log("Local Network permission denied");
2526
- break;
2527
- case cordova.plugins.diagnostic.permissionStatus.UNKNOWN:
2528
- console.log("Local Network permission could not be determined (retry recommended)");
2529
- break;
2530
- case cordova.plugins.diagnostic.permissionStatus.GRANTED:
2531
- console.log("Local Network permission granted");
2532
- break;
2533
- }
2534
- }, function(error){
2538
+ switch(status){
2539
+ case cordova.plugins.diagnostic.permissionStatus.NOT_REQUESTED:
2540
+ console.log("Local Network permission not requested");
2541
+ break;
2542
+ case cordova.plugins.diagnostic.permissionStatus.DENIED_ALWAYS:
2543
+ console.log("Local Network permission denied");
2544
+ break;
2545
+ case cordova.plugins.diagnostic.permissionStatus.UNKNOWN:
2546
+ console.log("Local Network permission could not be determined (retry recommended)");
2547
+ break;
2548
+ case cordova.plugins.diagnostic.permissionStatus.GRANTED:
2549
+ console.log("Local Network permission granted");
2550
+ break;
2551
+ }
2552
+ }, function(error){
2535
2553
  console.error("The following error occurred: "+error);
2536
2554
  });
2537
2555
 
@@ -2539,34 +2557,34 @@ On iOS versions prior to 14 this will always return `GRANTED` as no authorizatio
2539
2557
 
2540
2558
  Platforms: iOS
2541
2559
 
2542
- Requests the user to authorise the app to access devices on the local network (iOS 14+).
2543
- On iOS versions prior to 14 this does nothing and will return success as no authorization is required.
2544
- May return `UNKNOWN` if iOS does not respond before the native APIs time out, allowing the app to retry.
2560
+ Requests the user to authorise the app to access devices on the local network (iOS 14+).
2561
+ On iOS versions prior to 14 this does nothing and will return success as no authorization is required.
2562
+ May return `UNKNOWN` if iOS does not respond before the native APIs time out, allowing the app to retry.
2545
2563
 
2546
2564
  cordova.plugins.diagnostic.requestLocalNetworkAuthorization(successCallback, errorCallback);
2547
2565
 
2548
2566
  #### Parameters
2549
2567
 
2550
- - {Function} successCallback - The callback which will be called when operation is successful.
2551
- The function is passed a single string parameter which is one of the values in `cordova.plugins.diagnostic.permissionStatus`:
2552
- `NOT_REQUESTED`, `GRANTED`, `DENIED_ALWAYS`, `UNKNOWN`.
2568
+ - {Function} successCallback - The callback which will be called when operation is successful.
2569
+ The function is passed a single string parameter which is one of the values in `cordova.plugins.diagnostic.permissionStatus`:
2570
+ `NOT_REQUESTED`, `GRANTED`, `DENIED_ALWAYS`, `UNKNOWN`.
2553
2571
  - {Function} errorCallback - The callback which will be called when operation encounters an error.
2554
2572
  The function is passed a single string parameter containing the error message.
2555
2573
 
2556
2574
 
2557
2575
  #### Example usage
2558
2576
 
2559
- cordova.plugins.diagnostic.requestLocalNetworkAuthorization(function(status){
2560
- if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
2561
- console.log("Local Network access granted");
2562
- }else if(status === cordova.plugins.diagnostic.permissionStatus.UNKNOWN){
2563
- console.log("Local Network status could not be determined, retrying may succeed");
2564
- }else{
2565
- console.log("Local Network access not granted: " + status);
2566
- }
2567
- }, function(error){
2568
- console.error("The following error occurred: "+error);
2569
- });
2577
+ cordova.plugins.diagnostic.requestLocalNetworkAuthorization(function(status){
2578
+ if(status === cordova.plugins.diagnostic.permissionStatus.GRANTED){
2579
+ console.log("Local Network access granted");
2580
+ }else if(status === cordova.plugins.diagnostic.permissionStatus.UNKNOWN){
2581
+ console.log("Local Network status could not be determined, retrying may succeed");
2582
+ }else{
2583
+ console.log("Local Network access not granted: " + status);
2584
+ }
2585
+ }, function(error){
2586
+ console.error("The following error occurred: "+error);
2587
+ });
2570
2588
 
2571
2589
  ### setWifiState()
2572
2590
 
@@ -110,8 +110,22 @@ interface Diagnostic {
110
110
  * @type {Object}
111
111
  */
112
112
  locationAccuracyAuthorization: {
113
+ /** Alias for BEST. Sets kCLLocationAccuracyBest on iOS. */
113
114
  "FULL": "full";
115
+ /** Sets kCLLocationAccuracyReduced on iOS - approximate location, no GPS. */
114
116
  "REDUCED": "reduced";
117
+ /** Sets kCLLocationAccuracyBest on iOS - may engage GPS hardware. */
118
+ "BEST": "best";
119
+ /** Sets kCLLocationAccuracyBestForNavigation on iOS - highest accuracy with additional sensors. */
120
+ "BEST_FOR_NAVIGATION": "bestForNavigation";
121
+ /** Sets kCLLocationAccuracyNearestTenMeters on iOS. */
122
+ "NEAREST_TEN_METERS": "nearestTenMeters";
123
+ /** Sets kCLLocationAccuracyHundredMeters on iOS. */
124
+ "HUNDRED_METERS": "hundredMeters";
125
+ /** Sets kCLLocationAccuracyKilometer on iOS. */
126
+ "KILOMETER": "kilometer";
127
+ /** Sets kCLLocationAccuracyThreeKilometers on iOS. */
128
+ "THREE_KILOMETERS": "threeKilometers";
115
129
  };
116
130
 
117
131
 
@@ -464,7 +478,17 @@ interface Diagnostic {
464
478
  * @param successCallback
465
479
  * @param errorCallback
466
480
  * @param mode - (optional / iOS & Android >= 10) location authorization mode specified as a locationAuthorizationMode constant. If not specified, defaults to WHEN_IN_USE.
467
- * @param accuracy
481
+ * @param accuracy - (optional / iOS & Android 12+) desired location accuracy as a locationAccuracyAuthorization constant.
482
+ * If not specified, defaults to FULL.
483
+ * On iOS, this sets the CLLocationManager's desiredAccuracy:
484
+ * - FULL / BEST - kCLLocationAccuracyBest (may engage GPS hardware)
485
+ * - REDUCED - kCLLocationAccuracyReduced (approximate location, no GPS)
486
+ * - BEST_FOR_NAVIGATION - kCLLocationAccuracyBestForNavigation
487
+ * - NEAREST_TEN_METERS - kCLLocationAccuracyNearestTenMeters
488
+ * - HUNDRED_METERS - kCLLocationAccuracyHundredMeters
489
+ * - KILOMETER - kCLLocationAccuracyKilometer
490
+ * - THREE_KILOMETERS - kCLLocationAccuracyThreeKilometers
491
+ * On Android < 12, has no effect.
468
492
  */
469
493
  requestLocationAuthorization?: (
470
494
  successCallback: (status: string) => void,
package/package.json CHANGED
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": "7.2.9",
2
+ "version": "7.2.10",
3
3
  "name": "cordova.plugins.diagnostic",
4
4
  "cordova_name": "Diagnostic",
5
5
  "description": "Cordova/Phonegap plugin to check the state of Location/WiFi/Camera/Bluetooth device settings.",
package/plugin.xml CHANGED
@@ -2,7 +2,7 @@
2
2
  <plugin xmlns="http://www.phonegap.com/ns/plugins/1.0"
3
3
  xmlns:android="http://schemas.android.com/apk/res/android"
4
4
  id="cordova.plugins.diagnostic"
5
- version="7.2.9">
5
+ version="7.2.10">
6
6
 
7
7
  <name>Diagnostic</name>
8
8
  <description>Cordova/Phonegap plugin to check the state of Location/WiFi/Camera/Bluetooth device settings.</description>
@@ -78,6 +78,41 @@ static NSString*const LOG_TAG = @"Diagnostic_Location[native]";
78
78
  @try {
79
79
  if ([CLLocationManager instancesRespondToSelector:@selector(requestWhenInUseAuthorization)])
80
80
  {
81
+ // Apply desired accuracy if specified (argument at index 1).
82
+ // Maps string values to CLLocationAccuracy constants.
83
+ // If not specified or unrecognised, defaults to kCLLocationAccuracyBest to maintain backward
84
+ // compatibility. Apps that do not require precise location (e.g. only need the Wi-Fi SSID)
85
+ // should pass "reduced" to avoid engaging GPS hardware and unnecessary battery drain.
86
+ NSString* accuracy = [command argumentAtIndex:1 withDefault:nil];
87
+ if(accuracy != nil){
88
+ if([accuracy isEqualToString:@"reduced"]){
89
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyReduced;
90
+ [diagnostic logDebug:@"Setting location accuracy: reduced"];
91
+ }else if([accuracy isEqualToString:@"bestForNavigation"]){
92
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyBestForNavigation;
93
+ [diagnostic logDebug:@"Setting location accuracy: bestForNavigation"];
94
+ }else if([accuracy isEqualToString:@"nearestTenMeters"]){
95
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters;
96
+ [diagnostic logDebug:@"Setting location accuracy: nearestTenMeters"];
97
+ }else if([accuracy isEqualToString:@"hundredMeters"]){
98
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyHundredMeters;
99
+ [diagnostic logDebug:@"Setting location accuracy: hundredMeters"];
100
+ }else if([accuracy isEqualToString:@"kilometer"]){
101
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyKilometer;
102
+ [diagnostic logDebug:@"Setting location accuracy: kilometer"];
103
+ }else if([accuracy isEqualToString:@"threeKilometers"]){
104
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyThreeKilometers;
105
+ [diagnostic logDebug:@"Setting location accuracy: threeKilometers"];
106
+ }else{
107
+ // "full", "best", or any unrecognised value
108
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
109
+ [diagnostic logDebug:@"Setting location accuracy: best"];
110
+ }
111
+ }else{
112
+ self.locationManager.desiredAccuracy = kCLLocationAccuracyBest;
113
+ [diagnostic logDebug:@"Setting location accuracy: best (default)"];
114
+ }
115
+
81
116
  BOOL always = [[command argumentAtIndex:0] boolValue];
82
117
  if(always){
83
118
  NSAssert([[[NSBundle mainBundle] infoDictionary] valueForKey:@"NSLocationAlwaysAndWhenInUseUsageDescription"], @"Your app must have a value for NSLocationAlwaysAndWhenInUseUsageDescription in its Info.plist");
@@ -371,8 +371,18 @@ var Diagnostic = (function(){
371
371
  * This callback function is passed a single string parameter containing the error message.
372
372
  * @param {String} mode - (optional) location authorization mode as a constant in `cordova.plugins.diagnostic.locationAuthorizationMode`.
373
373
  * If not specified, defaults to `cordova.plugins.diagnostic.locationAuthorizationMode.WHEN_IN_USE`.
374
+ * @param {String} accuracy - (optional) desired location accuracy as a constant in `cordova.plugins.diagnostic.locationAccuracyAuthorization`.
375
+ * If not specified, defaults to `cordova.plugins.diagnostic.locationAccuracyAuthorization.FULL`.
376
+ * On iOS, this sets the CLLocationManager's desiredAccuracy:
377
+ * - `FULL` / `BEST` - kCLLocationAccuracyBest (may engage GPS hardware)
378
+ * - `REDUCED` - kCLLocationAccuracyReduced (approximate location, no GPS)
379
+ * - `BEST_FOR_NAVIGATION` - kCLLocationAccuracyBestForNavigation (highest accuracy with additional sensors)
380
+ * - `NEAREST_TEN_METERS` - kCLLocationAccuracyNearestTenMeters
381
+ * - `HUNDRED_METERS` - kCLLocationAccuracyHundredMeters
382
+ * - `KILOMETER` - kCLLocationAccuracyKilometer
383
+ * - `THREE_KILOMETERS` - kCLLocationAccuracyThreeKilometers
374
384
  */
375
- Diagnostic.requestLocationAuthorization = function(successCallback, errorCallback, mode) {
385
+ Diagnostic.requestLocationAuthorization = function(successCallback, errorCallback, mode, accuracy) {
376
386
  if(cordova.plugins.diagnostic.location){
377
387
  cordova.plugins.diagnostic.location.requestLocationAuthorization.apply(this, arguments);
378
388
  }else{
@@ -29,7 +29,13 @@ var Diagnostic_Location = (function(){
29
29
 
30
30
  Diagnostic.locationAccuracyAuthorization = Diagnostic_Location.locationAccuracyAuthorization = {
31
31
  "FULL": "full",
32
- "REDUCED": "reduced"
32
+ "REDUCED": "reduced",
33
+ "BEST": "best",
34
+ "BEST_FOR_NAVIGATION": "bestForNavigation",
35
+ "NEAREST_TEN_METERS": "nearestTenMeters",
36
+ "HUNDRED_METERS": "hundredMeters",
37
+ "KILOMETER": "kilometer",
38
+ "THREE_KILOMETERS": "threeKilometers"
33
39
  };
34
40
 
35
41
  /********************
@@ -161,13 +167,23 @@ var Diagnostic_Location = (function(){
161
167
  * This callback function is passed a single string parameter containing the error message.
162
168
  * @param {String} mode - (optional) location authorization mode as a constant in `cordova.plugins.diagnostic.locationAuthorizationMode`.
163
169
  * If not specified, defaults to `cordova.plugins.diagnostic.locationAuthorizationMode.WHEN_IN_USE`.
170
+ * @param {String} accuracy - (optional) desired location accuracy as a constant in `cordova.plugins.diagnostic.locationAccuracyAuthorization`.
171
+ * If not specified, defaults to `cordova.plugins.diagnostic.locationAccuracyAuthorization.FULL`.
172
+ * On iOS, this sets the CLLocationManager's desiredAccuracy:
173
+ * - `FULL` / `BEST` - kCLLocationAccuracyBest (may engage GPS hardware)
174
+ * - `REDUCED` - kCLLocationAccuracyReduced (approximate location, no GPS)
175
+ * - `BEST_FOR_NAVIGATION` - kCLLocationAccuracyBestForNavigation (highest accuracy with additional sensors)
176
+ * - `NEAREST_TEN_METERS` - kCLLocationAccuracyNearestTenMeters
177
+ * - `HUNDRED_METERS` - kCLLocationAccuracyHundredMeters
178
+ * - `KILOMETER` - kCLLocationAccuracyKilometer
179
+ * - `THREE_KILOMETERS` - kCLLocationAccuracyThreeKilometers
164
180
  */
165
- Diagnostic_Location.requestLocationAuthorization = function(successCallback, errorCallback, mode) {
181
+ Diagnostic_Location.requestLocationAuthorization = function(successCallback, errorCallback, mode, accuracy) {
166
182
  return cordova.exec(successCallback,
167
183
  errorCallback,
168
184
  'Diagnostic_Location',
169
185
  'requestLocationAuthorization',
170
- [mode && mode === Diagnostic_Location.locationAuthorizationMode.ALWAYS]);
186
+ [mode && mode === Diagnostic_Location.locationAuthorizationMode.ALWAYS, accuracy]);
171
187
  };
172
188
 
173
189
  /**