cordova-plugin-mserviceinterface-2.0 1.0.105 → 1.0.107

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.105",
3
+ "version": "1.0.107",
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.105">
3
+ xmlns:android="http://schemas.android.com/apk/res/android" id="cordova-plugin-mserviceinterface-2.0" version="1.0.107">
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>
@@ -559,10 +559,7 @@ public class mInterfaceService extends Service implements com.google.android.gms
559
559
  }
560
560
  String[] fileName = queueFiles[queueIndex].toString().split("/");
561
561
  String queueURL = clientUrl + "/common/components/QueueManager/QueueUpload.aspx?file_path=queue&client_id=" + clientID + "&country_code=" + countryCode + "&user_id=" + userID + "&file_name=" + fileName[fileName.length - 1];
562
- statusIndication = new mInterfaceUtil().sendFilesToServer(queueFiles[queueIndex].toString(), fileName[fileName.length - 1], queueURL, () -> isCancelled() || !running);
563
- if (statusIndication.equals("true")) {
564
- break;
565
- }
562
+ new mInterfaceUtil().sendFilesToServer(queueFiles[queueIndex].toString(), fileName[fileName.length - 1], queueURL, () -> isCancelled() || !running);
566
563
  }
567
564
  }
568
565
  }
@@ -634,11 +634,7 @@ public class mInterfaceUtil {
634
634
  }
635
635
  String[] fileName = queueFiles[queueIndex].toString().split("/");
636
636
  String queueURL = clientUrl + "/common/components/QueueManager/QueueUpload.aspx?file_path=queue&client_id=" + clientID + "&country_code=" + countryCode + "&user_id=" + userID + "&file_name=" + fileName[fileName.length - 1];
637
- statusIndication = sendFilesToServer(queueFiles[queueIndex].toString(), fileName[fileName.length - 1], queueURL);
638
- if (statusIndication.equals("true")) {
639
- breakIndication = "true";
640
- break;
641
- }
637
+ sendFilesToServer(queueFiles[queueIndex].toString(), fileName[fileName.length - 1], queueURL);
642
638
  }
643
639
  }
644
640
  }
@@ -2358,7 +2358,6 @@
2358
2358
  - (void)StartService:(CDVInvokedUrlCommand*)command
2359
2359
  {
2360
2360
  @try {
2361
- [self KillTimers];
2362
2361
  [self ValidateAppStateInfo];
2363
2362
  self.QueueToServerTimer = [NSTimer scheduledTimerWithTimeInterval:5.0
2364
2363
  target:self
@@ -2368,7 +2367,7 @@
2368
2367
  double locationInterval = 0.0;
2369
2368
  NSString * directory = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
2370
2369
  NSFileManager *fileManager = [NSFileManager defaultManager];
2371
- NSString *locConfgFilePath = [NSString stringWithFormat:@"%@/%@/app_controller.json", directory, [self GetAppName]];
2370
+ NSString *locConfgFilePath = [NSString stringWithFormat:@"%@/%@/app_controller.json.txt", directory, [self GetAppName]];
2372
2371
  if([fileManager fileExistsAtPath:locConfgFilePath]){
2373
2372
  NSData *user_data = [NSData dataWithContentsOfFile:locConfgFilePath];
2374
2373
  NSError *jsonError = nil;
@@ -2382,32 +2381,25 @@
2382
2381
  NSLog(@"No location update should not be happnened..");
2383
2382
  } else {
2384
2383
  self.locationManager = [[CLLocationManager alloc] init];
2385
- self.locationManager.delegate = self;
2386
- self.locationManager.distanceFilter = kCLDistanceFilterNone;
2387
- self.locationManager.headingFilter = kCLHeadingFilterNone;
2388
-
2389
- // Foreground-only: When In Use authorization
2384
+ [self.locationManager setDelegate:self];
2385
+ [self.locationManager setDistanceFilter:kCLDistanceFilterNone];
2386
+ [self.locationManager setHeadingFilter:kCLHeadingFilterNone];
2387
+ [self.locationManager requestAlwaysAuthorization];
2388
+ [self.locationManager requestWhenInUseAuthorization];
2390
2389
  CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
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];
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
+ }
2399
2395
  }
2400
-
2401
- // No allowsBackgroundLocationUpdates here
2402
-
2403
-
2396
+ [self.locationManager startUpdatingLocation];
2397
+ [self KillTimers];
2404
2398
  self.LocationTimer = [NSTimer scheduledTimerWithTimeInterval:locationInterval
2405
- target:self
2399
+ target:self
2406
2400
  selector:@selector(SendLocation)
2407
2401
  userInfo:nil
2408
- repeats:YES];
2409
- [self.LocationTimer fire];
2410
-
2402
+ repeats:YES];
2411
2403
  }
2412
2404
  } else {
2413
2405
  NSLog(@"'location_configuration' key not found in JSON.");
@@ -2513,11 +2505,7 @@
2513
2505
  for( int queueIndex = 0; queueIndex < [queueFilesMutArr count]; queueIndex++ ) {
2514
2506
  NSString *queueFilesPath = [NSString stringWithFormat:@"%@/%@", queueFolderPath, queueFilesMutArr[queueIndex]];
2515
2507
  NSString *queueURL = [NSString stringWithFormat:@"%@/common/components/QueueManager/QueueUpload.aspx?file_path=queue&client_id=%@&country_code=%@&user_id=%@&file_name=%@", clientUrl, clientId, countryCode, userID, queueFilesMutArr[queueIndex]];
2516
- statusIndication = [self sendFilesToServer:queueFilesPath fileName:queueFilesMutArr[queueIndex] requestURL:queueURL];
2517
- if ([statusIndication isEqualToString:@"true"]) {
2518
- breakIndication = @"true";
2519
- break;
2520
- }
2508
+ [self sendFilesToServer:queueFilesPath fileName:queueFilesMutArr[queueIndex] requestURL:queueURL];
2521
2509
  }
2522
2510
  }
2523
2511
  } else {
@@ -2606,10 +2594,7 @@
2606
2594
  for( int queueIndex = 0; queueIndex < [queueFilesMutArr count]; queueIndex++ ) {
2607
2595
  NSString *queueFilesPath = [NSString stringWithFormat:@"%@/%@", queueFolderPath, queueFilesMutArr[queueIndex]];
2608
2596
  NSString *queueURL = [NSString stringWithFormat:@"%@/common/components/QueueManager/QueueUpload.aspx?file_path=queue&client_id=%@&country_code=%@&user_id=%@&file_name=%@", clientUrl, clientId, countryCode, userID, queueFilesMutArr[queueIndex]];
2609
- statusIndication = [self sendFilesToServer:queueFilesPath fileName:queueFilesMutArr[queueIndex] requestURL:queueURL];
2610
- if ([statusIndication isEqualToString:@"true"]) {
2611
- break;
2612
- }
2597
+ [self sendFilesToServer:queueFilesPath fileName:queueFilesMutArr[queueIndex] requestURL:queueURL];
2613
2598
  }
2614
2599
  }
2615
2600
  } else {
@@ -3282,43 +3267,33 @@
3282
3267
 
3283
3268
  - (void)OpenFileWithViewer:(CDVInvokedUrlCommand *)command {
3284
3269
  self.fileOpenCallbackId = command.callbackId;
3285
-
3286
- CDVPluginResult *commandResult = nil;
3287
- NSString *filePath = [command.arguments objectAtIndex:0];
3288
-
3289
- if (filePath != nil && [filePath length] > 0) {
3290
- NSURL *url = [NSURL URLWithString:filePath];
3291
-
3292
- NSError *err = nil;
3293
- if (url.isFileURL && [url checkResourceIsReachableAndReturnError:&err]) {
3294
- self.fileUrl = url;
3295
-
3296
- dispatch_async(dispatch_get_main_queue(), ^{
3270
+ [self.commandDelegate runInBackground:^{
3271
+ CDVPluginResult* commandResult = nil;
3272
+ NSString *filePath = [command.arguments objectAtIndex:0];
3273
+ if (filePath != nil && [filePath length] > 0) {
3274
+ NSURL *url = [NSURL URLWithString:filePath];
3275
+ NSError *err;
3276
+ if (url.isFileURL && [url checkResourceIsReachableAndReturnError:&err] == YES) {
3277
+ self.fileUrl = url;
3297
3278
  QLPreviewController *previewCtrl = [[QLPreviewController alloc] init];
3298
3279
  previewCtrl.delegate = self;
3299
3280
  previewCtrl.dataSource = self;
3300
3281
  [previewCtrl.navigationItem setRightBarButtonItem:nil];
3301
-
3302
- [self.viewController presentViewController:previewCtrl
3303
- animated:YES
3304
- completion:nil];
3305
- });
3306
-
3307
- commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK
3308
- messageAsString:@"Success"];
3309
- [commandResult setKeepCallback:@(YES)];
3282
+ dispatch_async(dispatch_get_main_queue(), ^{
3283
+ [self.viewController presentViewController:previewCtrl animated:YES completion:nil];
3284
+ });
3285
+ commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:@"Success"];
3286
+ [commandResult setKeepCallback:[NSNumber numberWithBool:YES]];
3287
+ } else {
3288
+ NSLog(@"Invalid file URL");
3289
+ commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid file URL"];
3290
+ }
3310
3291
  } else {
3311
- NSLog(@"Invalid file URL: %@", err);
3312
- commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
3313
- messageAsString:@"Invalid file URL"];
3292
+ NSLog(@"Missing URL argument");
3293
+ commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Missing URL argument"];
3314
3294
  }
3315
- } else {
3316
- NSLog(@"Missing URL argument");
3317
- commandResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR
3318
- messageAsString:@"Missing URL argument"];
3319
- }
3320
-
3321
- [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
3295
+ [self.commandDelegate sendPluginResult:commandResult callbackId:command.callbackId];
3296
+ }];
3322
3297
  }
3323
3298
 
3324
3299
  #pragma - QLPreviewControllerDataSource Protocol