From 4f9253c24a75c34424ec52154f41b9b9ea80600d Mon Sep 17 00:00:00 2001 From: Shankari Date: Sat, 28 May 2022 22:13:05 -0700 Subject: [PATCH] Construct all the server call URLs using string concatenation Instead on the relativeURL method. This is because the relative URL appraoch does not work on iOS even though the documentation says that it should Relative URL doesn't work: https://github.com/e-mission/e-mission-docs/issues/732#issuecomment-1140181722 Appending strings does work: https://github.com/e-mission/e-mission-docs/issues/732#issuecomment-1140296951 Related updates: https://github.com/e-mission/cordova-connection-settings/releases/tag/v1.2.3 --- plugin.xml | 2 +- src/ios/BEMServerSyncCommunicationHelper.m | 10 ++++------ 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/plugin.xml b/plugin.xml index dce283a..b70360c 100644 --- a/plugin.xml +++ b/plugin.xml @@ -1,7 +1,7 @@ + version="1.2.9"> ServerSync Push and pull local data to the server diff --git a/src/ios/BEMServerSyncCommunicationHelper.m b/src/ios/BEMServerSyncCommunicationHelper.m index 68e6670..e14c8d1 100644 --- a/src/ios/BEMServerSyncCommunicationHelper.m +++ b/src/ios/BEMServerSyncCommunicationHelper.m @@ -112,9 +112,8 @@ +(void)phone_to_server:(NSArray *)entriesToPush completionHandler:(void (^)(NSDa NSMutableDictionary *toPush = [[NSMutableDictionary alloc] init]; [toPush setObject:entriesToPush forKey:@"phone_to_server"]; - NSURL* kBaseURL = [[ConnectionSettings sharedInstance] getConnectUrl]; - NSURL* kUsercachePutURL = [NSURL URLWithString:kUsercachePutPath - relativeToURL:kBaseURL]; + NSString* kBaseURLString = [[ConnectionSettings sharedInstance] getConnectString]; + NSURL* kUsercachePutURL = [NSURL URLWithString:[kBaseURLString stringByAppendingString:kUsercachePutPath]]; CommunicationHelper *executor = [[CommunicationHelper alloc] initPost:kUsercachePutURL data:toPush completionHandler:completionHandler]; [executor execute]; @@ -214,9 +213,8 @@ + (NSInteger)fetchedData:(NSData *)responseData { +(void)server_to_phone:(void (^)(NSData *data, NSURLResponse *response, NSError *error))completionHandler { NSLog(@"CommunicationHelper.server_to_phone called!"); NSMutableDictionary *blankDict = [[NSMutableDictionary alloc] init]; - NSURL* kBaseURL = [[ConnectionSettings sharedInstance] getConnectUrl]; - NSURL* kUsercacheGetURL = [NSURL URLWithString:kUsercacheGetPath - relativeToURL:kBaseURL]; + NSString* kBaseURLString = [[ConnectionSettings sharedInstance] getConnectString]; + NSURL* kUsercacheGetURL = [NSURL URLWithString:[kBaseURLString stringByAppendingString:kUsercacheGetPath]]; CommunicationHelper *executor = [[CommunicationHelper alloc] initPost:kUsercacheGetURL data:blankDict completionHandler:completionHandler]; [executor execute]; }