|
@@ -1690,6 +1690,28 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+- (void)getServerNotification:(NSString *)serverUrl notificationId:(NSInteger)notificationId completion:(void(^)(NSString *message, NSInteger errorCode))completion
|
|
|
+{
|
|
|
+ NSString *URLString = [NSString stringWithFormat:@"%@/ocs/v2.php/apps/notifications/api/v2/notifications/%ld", serverUrl, (long)notificationId];
|
|
|
+
|
|
|
+ NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:URLString] cachePolicy:0 timeoutInterval:20.0];
|
|
|
+ [request addValue:[CCUtility getUserAgent] forHTTPHeaderField:@"User-Agent"];
|
|
|
+ [request addValue:@"true" forHTTPHeaderField:@"OCS-APIRequest"];
|
|
|
+
|
|
|
+ NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
|
|
|
+ NSURLSession *session = [NSURLSession sessionWithConfiguration:configuration delegate:self delegateQueue:nil];
|
|
|
+
|
|
|
+ NSURLSessionDataTask *task = [session dataTaskWithRequest:request completionHandler: ^(NSData *data, NSURLResponse *response, NSError *error) {
|
|
|
+
|
|
|
+ //NSDictionary *notification = [[response objectForKey:@"ocs"] objectForKey:@"data"];
|
|
|
+
|
|
|
+ completion(@"", 0);
|
|
|
+
|
|
|
+ }];
|
|
|
+
|
|
|
+ [task resume];
|
|
|
+}
|
|
|
+
|
|
|
#pragma --------------------------------------------------------------------------------------------
|
|
|
#pragma mark ===== Manage Mobile Editor OCS API =====
|
|
|
#pragma --------------------------------------------------------------------------------------------
|
|
@@ -1940,6 +1962,16 @@
|
|
|
}];
|
|
|
}
|
|
|
|
|
|
+-(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler
|
|
|
+{
|
|
|
+ // The pinnning check
|
|
|
+ if ([[CCCertificate sharedManager] checkTrustedChallenge:challenge]) {
|
|
|
+ completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
|
|
|
+ } else {
|
|
|
+ completionHandler(NSURLSessionAuthChallengePerformDefaultHandling, nil);
|
|
|
+ }
|
|
|
+}
|
|
|
+
|
|
|
@end
|
|
|
|
|
|
#pragma --------------------------------------------------------------------------------------------
|