Marino Faggiana 8 年之前
父节点
当前提交
f6fc35a389
共有 2 个文件被更改,包括 31 次插入2 次删除
  1. 29 0
      Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m
  2. 2 2
      iOSClient/AppDelegate.m

+ 29 - 0
Libraries external/OCCommunicationLib/OCCommunicationLib/OCCommunication.m

@@ -1537,6 +1537,35 @@
     }];
 }
 
+- (void)subscribingPushProxy:(NSString *)serverPath pushTokenHash:(NSString *)pushTokenHash deviceIdentifier:(NSString *)deviceIdentifier deviceIdentifierSignature:(NSString *)deviceIdentifierSignature 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];
+    
+    OCWebDAVClient *request = [OCWebDAVClient new];
+    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);
+        
+        NSString *publicKey = [jsongParsed objectForKey:@"publicKey"];
+        NSString *deviceIdentifier = [jsongParsed objectForKey:@"deviceIdentifier"];
+        NSString *signature = [jsongParsed objectForKey:@"signature"];
+        
+        successRequest(response, publicKey, deviceIdentifier, signature, request.redirectedServer);
+        
+    } failure:^(NSHTTPURLResponse *response, NSData *responseData, NSError *error) {
+        
+        failureRequest(response, error, request.redirectedServer);
+    }];
+}
+
 #pragma mark - Activity
 
 - (void) getActivityServer:(NSString*)serverPath onCommunication:(OCCommunication *)sharedOCComunication successRequest:(void(^)(NSHTTPURLResponse *response, NSArray *listOfActivity, NSString *redirectedServer)) successRequest failureRequest:(void(^)(NSHTTPURLResponse *response, NSError *error, NSString *redirectedServer)) failureRequest {

+ 2 - 2
iOSClient/AppDelegate.m

@@ -434,9 +434,9 @@
     NSDictionary *keys = [NSDictionary dictionaryWithContentsOfFile:[[NSBundle mainBundle] pathForResource:k_nextcloudDevicePushKey ofType:@"plist"]];
     
 #ifdef DEBUG
-    NSString *devicePublicKey = [keys objectForKey:@"devicePublicKeyDev"];
+    NSString *devicePublicKey = [keys objectForKey:@"devicePublicKeyDevelopment"];
 #else
-    NSString *devicePublicKey = [keys objectForKey:@"devicePublicKeyDev"];
+    NSString *devicePublicKey = [keys objectForKey:@"devicePublicKeyProduction"];
 #endif
     
     NSLog(@"DEVICE TOKEN = %@", pushTokenString);