Marino Faggiana 8 years ago
parent
commit
0ffca90aaf

+ 3 - 2
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m

@@ -1512,8 +1512,9 @@
     
     serverPath = [serverPath encodeString:NSUTF8StringEncoding];
     serverPath = [serverPath stringByAppendingString:k_url_acces_remote_subscribing_nextcloud_server_api];
-    pushTokenHash = [pushTokenHash encodeString:NSUTF8StringEncoding];
-    devicePublicKey = [devicePublicKey encodeString:NSUTF8StringEncoding];
+
+    pushTokenHash = [pushTokenHash stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
+    devicePublicKey = [devicePublicKey stringByAddingPercentEscapesUsingEncoding:NSASCIIStringEncoding];
     
     OCWebDAVClient *request = [OCWebDAVClient new];
     request = [self getRequestWithCredentials:request];

+ 4 - 0
Nextcloud.xcodeproj/project.pbxproj

@@ -494,6 +494,7 @@
 		F78088EB1DD3A1DB005C5A7C /* cryptocloud.xcdatamodeld in Sources */ = {isa = PBXBuildFile; fileRef = F78088E51DD3A1DB005C5A7C /* cryptocloud.xcdatamodeld */; };
 		F78BFED41D3111B800E513CF /* LaunchScreenNextcloud.xib in Resources */ = {isa = PBXBuildFile; fileRef = F78BFECA1D3111B800E513CF /* LaunchScreenNextcloud.xib */; };
 		F78BFEE11D31126B00E513CF /* MainInterface.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = F78BFEDE1D31126B00E513CF /* MainInterface.storyboard */; };
+		F79160541E76EE3500F6214C /* aps_development_pubkey.pem in Resources */ = {isa = PBXBuildFile; fileRef = F79160531E76EE3500F6214C /* aps_development_pubkey.pem */; };
 		F7B1FBC41E72E3D1001781FE /* Media.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = F7B1FBB11E72E3D1001781FE /* Media.xcassets */; };
 		F7B1FBC51E72E3D1001781FE /* SwiftWebVC.strings in Resources */ = {isa = PBXBuildFile; fileRef = F7B1FBB31E72E3D1001781FE /* SwiftWebVC.strings */; };
 		F7B1FBC61E72E3D1001781FE /* SwiftModalWebVC.swift in Sources */ = {isa = PBXBuildFile; fileRef = F7B1FBBF1E72E3D1001781FE /* SwiftModalWebVC.swift */; };
@@ -1391,6 +1392,7 @@
 		F78BFEDE1D31126B00E513CF /* MainInterface.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; path = MainInterface.storyboard; sourceTree = "<group>"; };
 		F78F6FAE1CC8CCB700F4EA25 /* CCSection.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSection.h; sourceTree = "<group>"; };
 		F78F6FAF1CC8CCB700F4EA25 /* CCSection.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCSection.m; sourceTree = "<group>"; };
+		F79160531E76EE3500F6214C /* aps_development_pubkey.pem */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = aps_development_pubkey.pem; sourceTree = SOURCE_ROOT; };
 		F792A77B1BC7C45400C9388E /* CCSplit.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCSplit.h; sourceTree = "<group>"; };
 		F792A77C1BC7C45400C9388E /* CCSplit.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = CCSplit.m; sourceTree = "<group>"; };
 		F7956FC91B4886E60085DEA3 /* CCUploadFromOtherUpp.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCUploadFromOtherUpp.h; sourceTree = "<group>"; };
@@ -3326,6 +3328,7 @@
 				F7D154271E2392A300202FD9 /* Nextcloud-Bridging-Header.h */,
 				F75CDBF51DF063AD00116AD0 /* .gitignore */,
 				F7724CB21E71960F005AD84C /* NextcloudDevicePushKey-Info.plist */,
+				F79160531E76EE3500F6214C /* aps_development_pubkey.pem */,
 				F7229B461DF71BA800E8C4E7 /* ChangeLog */,
 				F7229B491DF71BB300E8C4E7 /* AUTHORS */,
 				F78BFECA1D3111B800E513CF /* LaunchScreenNextcloud.xib */,
@@ -3700,6 +3703,7 @@
 				F75ADF451DC75FFE008A7347 /* CCLogin.storyboard in Resources */,
 				F77B0EEA1D118A16002130FE /* ZSSbold@2x.png in Resources */,
 				F77B0EEB1D118A16002130FE /* ZSSrightjustify@2x.png in Resources */,
+				F79160541E76EE3500F6214C /* aps_development_pubkey.pem in Resources */,
 				F7C00D481E2D0D0F0032160B /* CCCellOffline.xib in Resources */,
 				F77B0EEC1D118A16002130FE /* ZSSindent@2x.png in Resources */,
 				F7F54CED1E5B14C700E19C62 /* ImageSelectedOn@3x.png in Resources */,

+ 5 - 3
iOSClient/AppDelegate.m

@@ -429,18 +429,20 @@
     
 #if defined(OPTION_NOTIFICATION_PUSH_ENABLE) || defined(DEBUG)
     
-    NSDictionary *keys = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:k_nextcloudDevicePushKey ofType:@"plist"]];
-    
-    NSString *devicePublicKey = [keys objectForKey:@"devicePublicKey"];
     NSString *pushTokenString = [[[[deviceToken description] stringByReplacingOccurrencesOfString: @"<" withString: @""] stringByReplacingOccurrencesOfString: @">" withString: @""] stringByReplacingOccurrencesOfString: @" " withString: @""];
     NSString *pushTokenHash = [[CCCrypto sharedManager] createSHA512:pushTokenString];
     
+    NSString *path = [[[NSBundle mainBundle] URLForResource:k_nextcloudDevicePushPublicKeyDev withExtension:@"pem"] absoluteString];
+    NSData *devicePublicKeyData = [NSData dataWithContentsOfURL:[NSURL URLWithString:path]];
+    NSString *devicePublicKey = [[NSString alloc] initWithData:devicePublicKeyData encoding:NSUTF8StringEncoding];
+    
     NSLog(@"DEVICE TOKEN = %@", pushTokenString);
     NSLog(@"DEVICE PUBLIC KEY = %@", devicePublicKey);
     
     if ([devicePublicKey length] > 0 && [pushTokenHash length] > 0) {
         
         CCMetadataNet *metadataNet = [[CCMetadataNet alloc] initWithAccount:app.activeAccount];
+    
         NSDictionary *options = [[NSDictionary alloc] initWithObjectsAndKeys:pushTokenHash,@"pushTokenHash", devicePublicKey, @"devicePublicKey", nil];
         
         metadataNet.action = actionSubscribingNextcloudServer;

+ 1 - 1
iOSClient/CCGlobal.h

@@ -267,7 +267,7 @@ extern NSString *const BKPasscodeKeychainServiceName;
 #define k_minCharsSearch                                2
 
 // Nextcloud Plist Key Push Service
-#define k_nextcloudDevicePushKey                        @"NextcloudDevicePushKey-Info"
+#define k_nextcloudDevicePushPublicKeyDev               @"aps_development_pubkey"
 
 // -----------------------------------------------------------------------------------------------------------
 // -----------------------------------------------------------------------------------------------------------