cordova-plugin-mserviceinterface-2.0 1.0.95 → 1.0.97

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cordova-plugin-mserviceinterface-2.0",
3
- "version": "1.0.95",
3
+ "version": "1.0.97",
4
4
  "description": "This plugin establishes the connection to the native interface and performs the requested task.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/plugin.xml CHANGED
@@ -1,6 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8"?>
2
2
  <plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
3
- xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.95">
3
+ xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.97">
4
4
  <name>mserviceinterface-2.0</name>
5
5
  <description>This plugin establishes the connection to the native interface and performs the requested task.</description>
6
6
  <author>selfservit@gmail.com</author>
@@ -2358,6 +2358,7 @@
2358
2358
  - (void)StartService:(CDVInvokedUrlCommand*)command
2359
2359
  {
2360
2360
  @try {
2361
+ [self KillTimers];
2361
2362
  [self ValidateAppStateInfo];
2362
2363
  self.QueueToServerTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
2363
2364
  target:self
@@ -2367,7 +2368,7 @@
2367
2368
  double locationInterval = 0.0;
2368
2369
  NSString * directory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
2369
2370
  NSFileManager *fileManager = [NSFileManager defaultManager];
2370
- NSString *locConfgFilePath = [NSString stringWithFormat:@"%@/%@/app_controller.json.txt", directory, [self GetAppName]];
2371
+ NSString *locConfgFilePath = [NSString stringWithFormat:@"%@/%@/app_controller.json", directory, [self GetAppName]];
2371
2372
  if([fileManager fileExistsAtPath:locConfgFilePath]){
2372
2373
  NSData *user_data = [NSData dataWithContentsOfFile:locConfgFilePath];
2373
2374
  NSError *jsonError = nil;
@@ -2381,25 +2382,32 @@
2381
2382
  NSLog(@"No location update should not be happnened..");
2382
2383
  } else {
2383
2384
  self.locationManager = [[CLLocationManager alloc] init];
2384
- [self.locationManager setDelegate:self];
2385
- [self.locationManager setDistanceFilter:kCLDistanceFilterNone];
2386
- [self.locationManager setHeadingFilter:kCLHeadingFilterNone];
2387
- [self.locationManager requestAlwaysAuthorization];
2388
- [self.locationManager requestWhenInUseAuthorization];
2385
+ self.locationManager.delegate = self;
2386
+ self.locationManager.distanceFilter = kCLDistanceFilterNone;
2387
+ self.locationManager.headingFilter = kCLHeadingFilterNone;
2388
+
2389
+ // Foreground-only: When In Use authorization
2389
2390
  CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
2390
- if (status == kCLAuthorizationStatusAuthorizedAlways) {
2391
- // Location permission is granted, enable background location updates
2392
- if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
2393
- _locationManager.allowsBackgroundLocationUpdates = YES;
2394
- }
2391
+
2392
+ if (status == kCLAuthorizationStatusNotDetermined) {
2393
+ // First time: ask for When In Use
2394
+ [self.locationManager requestWhenInUseAuthorization];
2395
+ } else if (status == kCLAuthorizationStatusAuthorizedWhenInUse ||
2396
+ status == kCLAuthorizationStatusAuthorizedAlways) {
2397
+ // Permission already granted
2398
+ [self.locationManager startUpdatingLocation];
2395
2399
  }
2396
- [self.locationManager startUpdatingLocation];
2397
- [self KillTimers];
2400
+
2401
+ // No allowsBackgroundLocationUpdates here
2402
+
2403
+
2398
2404
  self.LocationTimer = [NSTimer scheduledTimerWithTimeInterval:locationInterval
2399
- target:self
2405
+ target:self
2400
2406
  selector:@selector(SendLocation)
2401
2407
  userInfo:nil
2402
- repeats:YES];
2408
+ repeats:YES];
2409
+ [self.LocationTimer fire];
2410
+
2403
2411
  }
2404
2412
  } else {
2405
2413
  NSLog(@"'location_configuration' key not found in JSON.");