Worklight - 重载 NSURLConnection 委托方法

Worklight - overloading NSURLConnection delegate method

由于 Worklight 提供的 iOS SDK,我正在开发一个与 Worklight 服务器通信的 iOS 应用程序。

我想将 AppConnect SDK (MDM) 集成到项目中,以便对通信进行一些隧道处理。

为此,我必须重载 NSURLConnectionDelegate method 以将一些与 AppConnect 相关的证书配置添加到 HTTP 请求中:

- (void) connection: (NSURLConnection *)connection willSendRequestForAuthenticationChallenge:(NSURLAuthenticationChallenge *)challenge;

问题是 NSURLConnections 和 NSURLRequests 由 Worklight iOS 库封装:我用来调用的方法是

[[WLClient sharedInstance] invokeProcedure:myInvocation withDelegate:self options:serviceOptions];

所以我看不到 NSURLConnections 和 NSURLRequests,也无法重载 NSURLConnectionDelegate 方法...

这就是我想知道的原因:是否可以通过这种方式重载 Worklight iOS 库的 HTTP 行为?如果可能的话,我该怎么做?

如果需要添加header,可以使用invokeProcedure中的选项。 如果您需要更复杂的东西,我建议使用 NSURLProtocol -> https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSURLProtocol_Class/index.html