cordova-plugin-mserviceinterface-2.0 1.0.53 → 1.0.55
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 +1 -1
- package/plugin.xml +1 -1
- package/src/ios/mInterface.h +1 -0
- package/src/ios/mInterface.m +50 -10
package/package.json
CHANGED
package/plugin.xml
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
|
|
3
3
|
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
4
4
|
id="cordova-plugin-mserviceinterface-2.0"
|
|
5
|
-
version="1.0.
|
|
5
|
+
version="1.0.55">
|
|
6
6
|
<name>mserviceinterface-2.0</name>
|
|
7
7
|
<description>This plugin establishes the connection to the native interface and performs the requested task.</description>
|
|
8
8
|
<author>selfservit@gmail.com</author>
|
package/src/ios/mInterface.h
CHANGED
|
@@ -89,6 +89,7 @@
|
|
|
89
89
|
- (void)GetPackageName:(CDVInvokedUrlCommand*)command;
|
|
90
90
|
- (void)UpdateNew:(CDVInvokedUrlCommand*)command;
|
|
91
91
|
- (void)StartService:(CDVInvokedUrlCommand*)command;
|
|
92
|
+
- (void)SendAttachmentToServer:(CDVInvokedUrlCommand*)command;
|
|
92
93
|
- (void)SendLocation;
|
|
93
94
|
- (void)GetLocation:(CDVInvokedUrlCommand*)command;
|
|
94
95
|
- (void)timeReader;
|
package/src/ios/mInterface.m
CHANGED
|
@@ -38,6 +38,36 @@
|
|
|
38
38
|
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
|
39
39
|
}
|
|
40
40
|
|
|
41
|
+
- (void)SendAttachmentToServer:(CDVInvokedUrlCommand *)command {
|
|
42
|
+
NSString *statusIndication = @"false";
|
|
43
|
+
NSMutableArray *argumentsList = [command arguments];
|
|
44
|
+
CDVPluginResult *result;
|
|
45
|
+
NSDictionary *argumentObject;
|
|
46
|
+
NSString *filePath;
|
|
47
|
+
NSString *serverPath;
|
|
48
|
+
NSString *fileName;
|
|
49
|
+
NSString *attachURL;
|
|
50
|
+
for(int index = 0; index < [argumentsList count]; index++) {
|
|
51
|
+
argumentObject = [argumentsList objectAtIndex:index];
|
|
52
|
+
filePath = argumentObject[@"filePath"];
|
|
53
|
+
serverPath = argumentObject[@"serverPath"];
|
|
54
|
+
fileName = argumentObject[@"fileName"];
|
|
55
|
+
attachURL = [NSString stringWithFormat: @"%@/common/components/msvFileHandler/UploadFiles.aspx?client_id=%@&country_code=%@&path=%@", clientUrl, clientID, countryCode, serverPath];
|
|
56
|
+
statusIndication = [self sendFilesToServer:filePath fileName:fileName requestURL:attachURL];
|
|
57
|
+
if ([statusIndication isEqualToString:@"false"]) {
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if ([statusIndication isEqualToString:@"true"]) {
|
|
62
|
+
NSString *serviceResult = [NSString stringWithFormat:@"%s", "success"];
|
|
63
|
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:serviceResult];
|
|
64
|
+
} else {
|
|
65
|
+
NSString *serviceResult = [NSString stringWithFormat:@"%s", "failure"];
|
|
66
|
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:serviceResult];
|
|
67
|
+
}
|
|
68
|
+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
|
69
|
+
}
|
|
70
|
+
|
|
41
71
|
-(void)GetBase64String:(CDVInvokedUrlCommand *)command {
|
|
42
72
|
NSMutableDictionary *dict = [[command arguments] objectAtIndex:0];
|
|
43
73
|
NSString *directory = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES)[0];
|
|
@@ -937,9 +967,12 @@
|
|
|
937
967
|
[self.locationManager setHeadingFilter:kCLHeadingFilterNone];
|
|
938
968
|
[self.locationManager requestAlwaysAuthorization];
|
|
939
969
|
[self.locationManager requestWhenInUseAuthorization];
|
|
940
|
-
|
|
941
|
-
if (
|
|
942
|
-
|
|
970
|
+
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
|
|
971
|
+
if (status == kCLAuthorizationStatusAuthorizedAlways) {
|
|
972
|
+
// Location permission is granted, enable background location updates
|
|
973
|
+
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
|
|
974
|
+
_locationManager.allowsBackgroundLocationUpdates = YES;
|
|
975
|
+
}
|
|
943
976
|
}
|
|
944
977
|
[self.locationManager startUpdatingLocation];
|
|
945
978
|
double lat = self.locationManager.location.coordinate.latitude;
|
|
@@ -1015,13 +1048,12 @@
|
|
|
1015
1048
|
if(networkStatus == NotReachable){
|
|
1016
1049
|
} else {
|
|
1017
1050
|
NSError *error;
|
|
1018
|
-
NSArray *myAccountsArray = [NSJSONSerialization JSONObjectWithData:[[NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/
|
|
1051
|
+
NSArray *myAccountsArray = [NSJSONSerialization JSONObjectWithData:[[NSString stringWithContentsOfFile:[NSString stringWithFormat:@"%@/%@/my_accounts_encrypted.txt", directory, [self GetAppName]] encoding:NSUTF8StringEncoding error:&error] dataUsingEncoding:NSUTF8StringEncoding] options: NSJSONReadingMutableContainers error:&error];
|
|
1019
1052
|
for( int index = 0; index < [myAccountsArray count]; index++ ) {
|
|
1020
1053
|
NSString *locationUpdateInd = [myAccountsArray[index] valueForKey:@"location_update_ind"];
|
|
1021
1054
|
if([locationUpdateInd isEqual: @"true"]) {
|
|
1022
1055
|
NSString *clientId = [myAccountsArray[index] valueForKey:@"client_id"];
|
|
1023
1056
|
NSString *countryCode = [myAccountsArray[index] valueForKey:@"country_code"];
|
|
1024
|
-
NSString *deviceID = [myAccountsArray[index] valueForKey:@"device_id"];
|
|
1025
1057
|
NSString *clientUrl = [myAccountsArray[index] valueForKey:@"client_url"];
|
|
1026
1058
|
NSString *locationData = [NSString stringWithContentsOfFile:locationFilePath encoding:NSUTF8StringEncoding error:&error];
|
|
1027
1059
|
NSString *baseURL = [NSString stringWithFormat:@"%@/common/components/GeoLocation/update_device_location_offline.aspx", clientUrl];
|
|
@@ -1031,7 +1063,12 @@
|
|
|
1031
1063
|
[request setValue:@"text/xml" forHTTPHeaderField:@"Content-type"];
|
|
1032
1064
|
[request setHTTPMethod : @"POST"];
|
|
1033
1065
|
[request setHTTPBody : inputData];
|
|
1034
|
-
|
|
1066
|
+
NSError *jsonError;
|
|
1067
|
+
NSURLResponse *response = nil;
|
|
1068
|
+
//[NSURLConnection connectionWithRequest:fileRequest delegate:self];
|
|
1069
|
+
NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&jsonError];
|
|
1070
|
+
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
|
|
1071
|
+
|
|
1035
1072
|
} else {
|
|
1036
1073
|
NSLog(@"The locationUpdateInd indication is set to false");
|
|
1037
1074
|
}
|
|
@@ -1566,10 +1603,13 @@
|
|
|
1566
1603
|
[self.locationManager setHeadingFilter:kCLHeadingFilterNone];
|
|
1567
1604
|
[self.locationManager requestAlwaysAuthorization];
|
|
1568
1605
|
[self.locationManager requestWhenInUseAuthorization];
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1606
|
+
CLAuthorizationStatus status = [CLLocationManager authorizationStatus];
|
|
1607
|
+
if (status == kCLAuthorizationStatusAuthorizedAlways) {
|
|
1608
|
+
// Location permission is granted, enable background location updates
|
|
1609
|
+
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 9) {
|
|
1610
|
+
_locationManager.allowsBackgroundLocationUpdates = YES;
|
|
1611
|
+
}
|
|
1612
|
+
}
|
|
1573
1613
|
[self.locationManager startUpdatingLocation];
|
|
1574
1614
|
[self KillTimers];
|
|
1575
1615
|
self.LocationTimer = [NSTimer scheduledTimerWithTimeInterval:locationInterval
|