Hello,
i want implement a publickey compare method.
For this an NSURLSession, its delegate methods and the
Instance Method dataTaskWithURL: completionHandler: needed.
So far, I have written only simple objective c methods in B4i, but
I have no idea how to install and use delegates and completionhandlers.
In B4i code I need to know if (error == NULL)
i want implement a publickey compare method.
For this an NSURLSession, its delegate methods and the
Instance Method dataTaskWithURL: completionHandler: needed.
So far, I have written only simple objective c methods in B4i, but
I have no idea how to install and use delegates and completionhandlers.
B4X:
#If OBJC
…..
NSURLSession = [NSURLSession sessionWithConfiguration:sessionConfig delegate:self delegateQueue:nil];
[[urlSession dataTaskWithURL:[NSURL URLWithString:urlstring] completionHandler:^(NSData * _Nullable data, NSURLResponse * _Nullable response, NSError * _Nullable error) {
if (error == NULL){
}
else{
}
}] resume];
……
-(void)URLSession:(NSURLSession *)session didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition, NSURLCredential * _Nullable))completionHandler {
if(myCompareMethod == True ){
NSURLCredential *credential = [NSURLCredential credentialForTrust:serverTrustRef];
completionHandler(NSURLSessionAuthChallengeUseCredential, credential);
}
else{
completionHandler(NSURLSessionAuthChallengeCancelAuthenticationChallenge, NULL);
}
}
In B4i code I need to know if (error == NULL)