Marino Faggiana 8 years ago
parent
commit
93da50a317

+ 1 - 1
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.h

@@ -840,7 +840,7 @@ typedef enum {
  *
  */
 
-- (void)subscribingNextcloudServerPush:(NSString *)serverPath pushTokenHash:(NSString *)pushTokenHash devicePublicKey:(NSString *)devicePublicKey onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void (^)(NSHTTPURLResponse *, NSString *))successRequest failureRequest:(void (^)(NSHTTPURLResponse *, NSError *, NSString *))failureRequest;
+- (void)subscribingNextcloudServerPush:(NSString *)serverPath pushTokenHash:(NSString *)pushTokenHash devicePublicKey:(NSString *)devicePublicKey onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void (^)(NSHTTPURLResponse *response, NSString *publicKey, NSString *deviceIdentifier, NSString *signature, NSString *redirectedServer))successRequest failureRequest:(void (^)(NSHTTPURLResponse *, NSError *, NSString *))failureRequest;
 
 
 #pragma mark -  Server Activity

+ 13 - 5
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m

@@ -1508,7 +1508,7 @@
     }];
 }
 
-- (void)subscribingNextcloudServerPush:(NSString *)serverPath pushTokenHash:(NSString *)pushTokenHash devicePublicKey:(NSString *)devicePublicKey onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void (^)(NSHTTPURLResponse *, NSString *))successRequest failureRequest:(void (^)(NSHTTPURLResponse *, NSError *, NSString *))failureRequest {
+- (void)subscribingNextcloudServerPush:(NSString *)serverPath pushTokenHash:(NSString *)pushTokenHash devicePublicKey:(NSString *)devicePublicKey onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSString *publicKey, NSString *deviceIdentifier, NSString *signature, NSString *redirectedServer)) successRequest failureRequest:(void (^)(NSHTTPURLResponse *, NSError *, NSString *))failureRequest {
     
     serverPath = [serverPath encodeString:NSUTF8StringEncoding];
     serverPath = [serverPath stringByAppendingString:k_url_acces_remote_subscribing_nextcloud_server_api];
@@ -1517,14 +1517,22 @@
     request = [self getRequestWithCredentials:request];
     
     [request subscribingNextcloudServerPush:serverPath authorizationToken:_password pushTokenHash:pushTokenHash devicePublicKey:devicePublicKey onCommunication:sharedOCComunication success:^(NSHTTPURLResponse *response, id responseObject) {
+        
+        NSData *responseData = (NSData*) responseObject;
+        
+        //Parse
+        NSError *error;
+        NSDictionary *jsongParsed = [NSJSONSerialization JSONObjectWithData:responseData options:NSJSONReadingMutableContainers error:&error];
+        NSLog(@"[LOG] Subscribing at the Nextcloud server : %@",jsongParsed);
+        
+        
         if (successRequest) {
             //Return success
-            successRequest(response, request.redirectedServer);
+            //successRequest(response, request.redirectedServer);
         }
-    } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
-        
-        NSLog(@"%@", response);
         
+    } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
+                
         failureRequest(response, error, request.redirectedServer);
     }];
 }

+ 6 - 1
iOSClient/AppDelegate.m

@@ -432,7 +432,12 @@
     NSString *pushTokenHash = [[CCCrypto sharedManager] createSHA512:pushTokenString];
     
     NSDictionary *keys = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:k_nextcloudDevicePushKey ofType:@"plist"]];
-    NSString *devicePublicKey = [keys objectForKey:@"devicePublicKey"];
+    
+#ifdef DEBUG
+    NSString *devicePublicKey = [keys objectForKey:@"devicePublicKeyDev"];
+#else
+    NSString *devicePublicKey = [keys objectForKey:@"devicePublicKeyDev"];
+#endif
     
     NSLog(@"DEVICE TOKEN = %@", pushTokenString);
     

+ 1 - 1
iOSClient/Networking/OCNetworking.m

@@ -1240,7 +1240,7 @@
     NSString *pushTokenHash = [parameter objectForKey:@"pushTokenHash"];
     NSString *devicePublicKey = [parameter objectForKey:@"devicePublicKey"];
     
-    [communication subscribingNextcloudServerPush:_activeUrl pushTokenHash:pushTokenHash devicePublicKey:devicePublicKey onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *redirectedServer) {
+    [communication subscribingNextcloudServerPush:_activeUrl pushTokenHash:pushTokenHash devicePublicKey:devicePublicKey onCommunication:communication successRequest:^(NSHTTPURLResponse *response, NSString *publicKey, NSString *deviceIdentifier, NSString *signature, NSString *redirectedServer) {
         
         [self complete];