Marino Faggiana 8 years ago
parent
commit
aba9d5677c

+ 9 - 5
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -763,12 +763,16 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     
     _requestMethod = @"POST";
     
-    //NSString *pushTokenHashParam = [NSString stringWithFormat:@"?pushTokenHash=%@",pushTokenHash];
-    //NSString *devicePublicKeyParam = [NSString stringWithFormat:@"&devicePublicKey=%@",devicePublicKey];
-    
-    //serverPath = [serverPath stringByAppendingString:pushTokenHashParam];
-    //serverPath = [serverPath stringByAppendingString:devicePublicKeyParam];
+    pushToken = [NSString stringWithFormat:@"/pushToken=%@",pushToken];
+    deviceIdentifier = [NSString stringWithFormat:@"?deviceIdentifier=%@",deviceIdentifier];
+    deviceIdentifierSignature = [NSString stringWithFormat:@"&deviceIdentifierSignature=%@",deviceIdentifierSignature];
+    userPublicKey = [NSString stringWithFormat:@"&userPublicKey=%@",userPublicKey];
     
+    serverPath = [serverPath stringByAppendingString:pushToken];
+    serverPath = [serverPath stringByAppendingString:deviceIdentifier];
+    serverPath = [serverPath stringByAppendingString:deviceIdentifierSignature];
+    serverPath = [serverPath stringByAppendingString:userPublicKey];
+
     NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path:serverPath parameters:nil];
     [request setValue:[NSString stringWithFormat:@"token %@", authorizationToken] forHTTPHeaderField:@"Authorization"];
     

+ 8 - 3
iOSClient/Networking/OCNetworking.m

@@ -1244,17 +1244,22 @@
     
     [communication subscribingNextcloudServerPush:_activeUrl pushTokenHash:pushTokenHash devicePublicKey:devicePublicKey onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *publicKey, NSString *deviceIdentifier, NSString *signature, NSString *redirectedServer) {
         
-        [communication subscribingPushProxy:_activeUrl pushToken:pushToken deviceIdentifier:deviceIdentifier deviceIdentifierSignature:signature userPublicKey:devicePublicKey onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *publicKey, NSString *deviceIdentifier, NSString *signature, NSString *redirectedServer) {
+        static CFStringRef charset = CFSTR("!@#$%&*()+'\";:=,/?[] ");
+        CFStringRef str = (__bridge CFStringRef)publicKey;
+        CFStringEncoding encoding = kCFStringEncodingUTF8;
+        publicKey = (NSString *)CFBridgingRelease(CFURLCreateStringByAddingPercentEscapes(NULL, str, NULL, charset, encoding));
+    
+        [communication subscribingPushProxy:_activeUrl pushToken:pushTokenHash deviceIdentifier:deviceIdentifier deviceIdentifierSignature:signature userPublicKey:devicePublicKey onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *publicKey, NSString *deviceIdentifier, NSString *signature, NSString *redirectedServer) {
             
             NSLog(@"OK");
             
-             [self complete];
+            [self complete];
             
         } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {
            
             NSLog(@"error");
             
-             [self complete];
+            [self complete];
         }];
         
     } failureRequest:^(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer) {