cordova-plugin-mserviceinterface-2.0 1.0.47 → 1.0.49
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 +3 -0
- package/src/ios/mInterface.m +141 -20
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.49">
|
|
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
|
@@ -36,6 +36,8 @@
|
|
|
36
36
|
NSString *clientUrl;
|
|
37
37
|
NSString *deviceID;
|
|
38
38
|
NSString *appInfoCaller;
|
|
39
|
+
NSString *imageAttachmentInd;
|
|
40
|
+
NSString *imageDestinationPath;
|
|
39
41
|
@protected BOOL _isLocked;
|
|
40
42
|
UIInterfaceOrientation _lastOrientation;
|
|
41
43
|
}
|
|
@@ -99,6 +101,7 @@
|
|
|
99
101
|
- (void)GetNewDate:(CDVInvokedUrlCommand*)command;
|
|
100
102
|
- (id)getCurrentDateTime;
|
|
101
103
|
-(void)timeValues:(NSString *)date hour:(NSString *)hour minute:(NSString *)minute;
|
|
104
|
+
-(void)SendChatAttachment:(CDVInvokedUrlCommand*)command;
|
|
102
105
|
- (void)KillTimers;
|
|
103
106
|
//- (void)AuthenticationRefresh;
|
|
104
107
|
//- (void)triggerAuthenticationServices:(NSString *)clientId countryCode:(NSString *)countryCode userId:(NSString *)userId sessionId:(NSString *)sessionId localeId:(NSString *)localeId deviceID:(NSString *)deviceID clientUrl:(NSString *)clientUrl cvsUrl:(NSString *)cvsUrl authIndFilePath:(NSString *)authIndFilePath;
|
package/src/ios/mInterface.m
CHANGED
|
@@ -1437,6 +1437,9 @@
|
|
|
1437
1437
|
}
|
|
1438
1438
|
|
|
1439
1439
|
- (void)CaptureImageFromCamera:(CDVInvokedUrlCommand*)command {
|
|
1440
|
+
NSMutableDictionary *inputObject = [[command arguments] objectAtIndex:0];
|
|
1441
|
+
imageAttachmentInd = inputObject[@"attachmentInd"];
|
|
1442
|
+
imageDestinationPath = inputObject[@"destinationPath"];
|
|
1440
1443
|
cameraOpen= [[UIImagePickerController alloc] init];
|
|
1441
1444
|
if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
|
|
1442
1445
|
return;
|
|
@@ -1455,6 +1458,9 @@
|
|
|
1455
1458
|
}
|
|
1456
1459
|
|
|
1457
1460
|
- (void)PickImageFromGallery:(CDVInvokedUrlCommand*)command {
|
|
1461
|
+
NSMutableDictionary *inputObject = [[command arguments] objectAtIndex:0];
|
|
1462
|
+
imageAttachmentInd = inputObject[@"attachmentInd"];
|
|
1463
|
+
imageDestinationPath = inputObject[@"destinationPath"];
|
|
1458
1464
|
imagePicker= [[UIImagePickerController alloc] init];
|
|
1459
1465
|
/*if(![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]){
|
|
1460
1466
|
return;
|
|
@@ -1490,6 +1496,34 @@
|
|
|
1490
1496
|
}
|
|
1491
1497
|
}
|
|
1492
1498
|
|
|
1499
|
+
- (void)SendChatAttachment:(CDVInvokedUrlCommand*)command {
|
|
1500
|
+
CDVPluginResult *result = nil;
|
|
1501
|
+
@try {
|
|
1502
|
+
NSString *statusIndication = @"false";
|
|
1503
|
+
NSMutableDictionary *inputObject = [[command arguments] objectAtIndex:0];
|
|
1504
|
+
NSString *filePath = inputObject[@"filePath"];
|
|
1505
|
+
NSString *serverPath = inputObject[@"serverPath"];
|
|
1506
|
+
NSString *fileName = inputObject[@"fileName"];
|
|
1507
|
+
NSString *attachURL = [NSString stringWithFormat:@"%@/common/components/msvFileHandler/UploadFiles.aspx?&client_id=%@&country_code=%@&path=%@", clientUrl, clientID, countryCode, serverPath];
|
|
1508
|
+
|
|
1509
|
+
statusIndication = [self sendFilesToServer:filePath fileName:fileName requestURL:attachURL];
|
|
1510
|
+
if ([statusIndication isEqualToString:@"true"]) {
|
|
1511
|
+
NSString *serviceResult = [NSString stringWithFormat:@"%s", "success"];
|
|
1512
|
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:serviceResult];
|
|
1513
|
+
} else {
|
|
1514
|
+
NSString *serviceResult = [NSString stringWithFormat:@"%s", "failure"];
|
|
1515
|
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:serviceResult];
|
|
1516
|
+
}
|
|
1517
|
+
|
|
1518
|
+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
|
1519
|
+
} @catch (NSException *exception) {
|
|
1520
|
+
NSString *fail_reason = [NSString stringWithFormat:@"%@\n%@\n%@",exception.name, exception.reason, exception.description ];
|
|
1521
|
+
result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:fail_reason];
|
|
1522
|
+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
|
|
1523
|
+
NSLog(@"CheckLocation Exception is : %@", exception.description);
|
|
1524
|
+
}
|
|
1525
|
+
}
|
|
1526
|
+
|
|
1493
1527
|
#pragma mark - MapViewDelegate
|
|
1494
1528
|
- (void) locationManager:(CLLocationManager *)manager didUpdateLocations:(NSArray<CLLocation *> *)locations{
|
|
1495
1529
|
|
|
@@ -1963,7 +1997,7 @@
|
|
|
1963
1997
|
}
|
|
1964
1998
|
NSDate *now = [NSDate date];
|
|
1965
1999
|
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
|
|
1966
|
-
dateFormatter.dateFormat = @"
|
|
2000
|
+
dateFormatter.dateFormat = @"yyyyMMddHHmmss";
|
|
1967
2001
|
[dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
|
|
1968
2002
|
NSString *gmtTime = [dateFormatter stringFromDate:now];
|
|
1969
2003
|
NSString *destination = [NSString stringWithFormat:@"%@/%@.jpg", dest, gmtTime];
|
|
@@ -1986,26 +2020,113 @@
|
|
|
1986
2020
|
NSLog(@"refURL : %@", refURL);
|
|
1987
2021
|
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
|
|
1988
2022
|
[assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil];
|
|
1989
|
-
} else if ([picker isEqual: cameraOpen]
|
|
1990
|
-
|
|
2023
|
+
} else if ([picker isEqual: cameraOpen]) {
|
|
2024
|
+
if ([imageAttachmentInd isEqualToString:@"true"]) {
|
|
2025
|
+
//if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone) {
|
|
2026
|
+
[picker dismissViewControllerAnimated:YES completion:nil];
|
|
2027
|
+
// } else {
|
|
2028
|
+
// [popover dismissPopoverAnimated:YES];
|
|
2029
|
+
// }
|
|
2030
|
+
UIImageView *ivPickedImage = [[UIImageView alloc] init];
|
|
2031
|
+
ivPickedImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
|
|
2032
|
+
NSURL *refURL = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL];
|
|
2033
|
+
// define the block to call when we get the asset based on the url (below)
|
|
2034
|
+
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset) {
|
|
2035
|
+
UIImage *image = ivPickedImage.image;
|
|
2036
|
+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
2037
|
+
NSString *directory = [paths objectAtIndex:0];
|
|
2038
|
+
NSString* appRootPath = [directory stringByAppendingPathComponent:[self GetAppName]];
|
|
2039
|
+
NSString *imagesFolderPath = [appRootPath stringByAppendingPathComponent:imageDestinationPath];
|
|
2040
|
+
if (![[NSFileManager defaultManager] fileExistsAtPath:imagesFolderPath]){
|
|
2041
|
+
[[NSFileManager defaultManager] createDirectoryAtPath:imagesFolderPath withIntermediateDirectories:YES attributes:nil error:nil];
|
|
2042
|
+
}
|
|
2043
|
+
NSDateFormatter *dateFormatter = [self getCurrentDateTime];
|
|
2044
|
+
[dateFormatter setDateFormat:@"yyyyMMddHHmmss"];
|
|
2045
|
+
NSString *fileName = [NSString stringWithFormat:@"%@.png", [dateFormatter stringFromDate:[NSDate date]]];
|
|
2046
|
+
NSString* imageSavedPath = [imagesFolderPath stringByAppendingPathComponent:fileName];
|
|
2047
|
+
NSData* imageData = UIImageJPEGRepresentation(image, 0.3);
|
|
2048
|
+
[imageData writeToFile:imageSavedPath atomically:YES];
|
|
2049
|
+
long imgSize = imageData.length;
|
|
2050
|
+
NSString *strImageSize = [NSString stringWithFormat:@"%ld", imgSize];
|
|
2051
|
+
NSString *extension = [[NSString stringWithFormat:@".%@",[imageSavedPath pathExtension]] lowercaseString];
|
|
2052
|
+
NSMutableDictionary * dict = [[NSMutableDictionary alloc] init];
|
|
2053
|
+
[dict setValue:[imageSavedPath stringByDeletingLastPathComponent] forKey:@"filePath"];
|
|
2054
|
+
[dict setValue:[imageSavedPath lastPathComponent] forKey:@"fileName"];
|
|
2055
|
+
[dict setValue:strImageSize forKey:@"fileSize"];
|
|
2056
|
+
[dict setValue:extension forKey:@"fileExtension"];
|
|
2057
|
+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
|
|
2058
|
+
[self.commandDelegate sendPluginResult:result callbackId:self.callbackIdForImagePicker];
|
|
2059
|
+
};
|
|
2060
|
+
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
|
|
2061
|
+
[assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil];
|
|
2062
|
+
} else {
|
|
1991
2063
|
[picker dismissViewControllerAnimated:YES completion:nil];
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
2064
|
+
UIImageView *ivPickedImage = [[UIImageView alloc] init];
|
|
2065
|
+
ivPickedImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
|
|
2066
|
+
UIImage *finalImage = [self imageWithImage:ivPickedImage.image scaledToWidth:824.00];
|
|
2067
|
+
NSURL *refURL = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL];
|
|
2068
|
+
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset)
|
|
2069
|
+
{
|
|
2070
|
+
NSData *imageData = UIImageJPEGRepresentation(finalImage, 0.1);
|
|
2071
|
+
NSString * base64String = [imageData base64EncodedStringWithOptions:0];
|
|
2072
|
+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:base64String];
|
|
2073
|
+
[self.commandDelegate sendPluginResult:result callbackId:self.callbackIdForImagePicker];
|
|
2074
|
+
};
|
|
2075
|
+
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
|
|
2076
|
+
[assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil];
|
|
2077
|
+
}
|
|
2078
|
+
} else if ([picker isEqual:imagePicker]) {
|
|
2079
|
+
if ([imageAttachmentInd isEqualToString:@"true"]) {
|
|
2080
|
+
UIImageView *ivPickedImage = [[UIImageView alloc] init];
|
|
2081
|
+
ivPickedImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
|
|
2082
|
+
NSURL *refURL = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL];
|
|
2083
|
+
// define the block to call when we get the asset based on the url (below)
|
|
2084
|
+
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset) {
|
|
2085
|
+
UIImage *image = ivPickedImage.image;
|
|
2086
|
+
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
|
|
2087
|
+
NSString *directory = [paths objectAtIndex:0];
|
|
2088
|
+
NSString* appRootPath = [directory stringByAppendingPathComponent:[self GetAppName]];
|
|
2089
|
+
NSString *imagesFolderPath = [appRootPath stringByAppendingPathComponent:imageDestinationPath];
|
|
2090
|
+
if (![[NSFileManager defaultManager] fileExistsAtPath:imagesFolderPath]){
|
|
2091
|
+
[[NSFileManager defaultManager] createDirectoryAtPath:imagesFolderPath withIntermediateDirectories:YES attributes:nil error:nil];
|
|
2092
|
+
}
|
|
2093
|
+
NSDateFormatter *dateFormatter = [self getCurrentDateTime];
|
|
2094
|
+
[dateFormatter setDateFormat:@"yyyyMMddHHmmss"];
|
|
2095
|
+
NSString *fileName = [NSString stringWithFormat:@"%@.png", [dateFormatter stringFromDate:[NSDate date]]];
|
|
2096
|
+
NSString* imageSavedPath = [imagesFolderPath stringByAppendingPathComponent:fileName];
|
|
2097
|
+
NSData* imageData = UIImageJPEGRepresentation(image, 0.3);
|
|
2098
|
+
[imageData writeToFile:imageSavedPath atomically:YES];
|
|
2099
|
+
long imgSize = imageData.length;
|
|
2100
|
+
NSString *strImageSize = [NSString stringWithFormat:@"%ld", imgSize];
|
|
2101
|
+
NSString *extension = [[NSString stringWithFormat:@".%@",[imageSavedPath pathExtension]] lowercaseString];
|
|
2102
|
+
NSMutableDictionary * dict = [[NSMutableDictionary alloc] init];
|
|
2103
|
+
[dict setValue:[imageSavedPath stringByDeletingLastPathComponent] forKey:@"filePath"];
|
|
2104
|
+
[dict setValue:[imageSavedPath lastPathComponent] forKey:@"fileName"];
|
|
2105
|
+
[dict setValue:strImageSize forKey:@"fileSize"];
|
|
2106
|
+
[dict setValue:extension forKey:@"fileExtension"];
|
|
2107
|
+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:dict];
|
|
2108
|
+
[self.commandDelegate sendPluginResult:result callbackId:self.callbackIdForImagePicker];
|
|
2109
|
+
};
|
|
2110
|
+
// get the asset library and fetch the asset based on the ref url (pass in block above)
|
|
2111
|
+
NSLog(@"refURL : %@", refURL);
|
|
2112
|
+
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
|
|
2113
|
+
[assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil];
|
|
2114
|
+
} else {
|
|
2115
|
+
[picker dismissViewControllerAnimated:YES completion:nil];
|
|
2116
|
+
UIImageView *ivPickedImage = [[UIImageView alloc] init];
|
|
2117
|
+
ivPickedImage.image = [info objectForKey:UIImagePickerControllerOriginalImage];
|
|
2118
|
+
UIImage *finalImage = [self imageWithImage:ivPickedImage.image scaledToWidth:824.00];
|
|
2119
|
+
NSURL *refURL = (NSURL *)[info valueForKey:UIImagePickerControllerReferenceURL];
|
|
2120
|
+
ALAssetsLibraryAssetForURLResultBlock resultblock = ^(ALAsset *imageAsset)
|
|
2121
|
+
{
|
|
2122
|
+
NSData *imageData = UIImageJPEGRepresentation(finalImage, 0.1);
|
|
2123
|
+
NSString * base64String = [imageData base64EncodedStringWithOptions:0];
|
|
2124
|
+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:base64String];
|
|
2125
|
+
[self.commandDelegate sendPluginResult:result callbackId:self.callbackIdForImagePicker];
|
|
2126
|
+
};
|
|
2127
|
+
ALAssetsLibrary* assetslibrary = [[ALAssetsLibrary alloc] init];
|
|
2128
|
+
[assetslibrary assetForURL:refURL resultBlock:resultblock failureBlock:nil];
|
|
2129
|
+
}
|
|
2009
2130
|
} else if ([picker isEqual:liveCamera]) {
|
|
2010
2131
|
//if(UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone) {
|
|
2011
2132
|
[picker dismissViewControllerAnimated:YES completion:nil];
|