Эх сурвалжийг харах

API Push notifications as a Nextcloud client device

Marino Faggiana 8 жил өмнө
parent
commit
928916e30b

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

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

+ 8 - 2
Libraries external/OCCommunicationLib/OCCommunicationLib/OCWebDavClient/OCWebDAVClient.m

@@ -742,9 +742,15 @@ NSString const *OCWebDAVModificationDateKey	= @"modificationdate";
     
     _requestMethod = @"POST";
     
-    NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path:serverPath parameters:nil];
+    NSString *jsonQuery = [NSString stringWithFormat:@"?format=json"];
+    NSString *pushTokenHashParam = [NSString stringWithFormat:@"&pushTokenHash=%@",pushTokenHash];
+    NSString *devicePublicKeyParam = [NSString stringWithFormat:@"&devicePublicKey=%@",devicePublicKey];
+    
+    serverPath = [serverPath stringByAppendingString:jsonQuery];
+    serverPath = [serverPath stringByAppendingString:pushTokenHashParam];
+    serverPath = [serverPath stringByAppendingString:devicePublicKeyParam];
 
-    [request setHTTPBody:[[NSString stringWithFormat: @"pushTokenHash=%@&devicePublicKey=%@", pushTokenHash, devicePublicKey] dataUsingEncoding:NSUTF8StringEncoding]];
+    NSMutableURLRequest *request = [self sharedRequestWithMethod:_requestMethod path:serverPath parameters:nil];
 
     OCHTTPRequestOperation *operation = [self mr_operationWithRequest:request onCommunication:sharedOCCommunication success:success failure:failure];
     [self setRedirectionBlockOnDatataskWithOCCommunication:sharedOCCommunication andSessionManager:sharedOCCommunication.networkSessionManager];