简体   繁体   English

Worklight-重载NSURLConnection委托方法

[英]Worklight - overloading NSURLConnection delegate method

I am working on an iOS app that is communicating with a Worklight server thanks to the iOS SDK provided by Worklight. 由于Worklight提供的iOS SDK,我正在与iOS进行通信的iOS应用程序上工作。

I would like to integrate the AppConnect SDK (MDM) to the project in order to do some tunneling on communications. 我想将AppConnect SDK(MDM)集成到项目中,以便在通信上进行一些隧道传输。

For this, I have to overload an NSURLConnectionDelegate method to add some AppConnect-related certificate configuration to an HTTP request : 为此,我必须重载NSURLConnectionDelegate方法,以将一些与AppConnect相关的证书配置添加到HTTP请求:

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

The problem is that NSURLConnections and NSURLRequests are encapsulated by the Worklight iOS library : the method that I use to make calls is 问题是NSURLConnections和NSURLRequests由Worklight iOS库封装:我用来进行调用的方法是

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

So I can't see the NSURLConnections and NSURLRequests, and I can't overload the NSURLConnectionDelegate method... 所以我看不到NSURLConnections和NSURLRequests,也无法重载NSURLConnectionDelegate方法...

That's why I would like to know : is it possible to overload the HTTP behavior of the Worklight iOS library in this way ? 这就是为什么我想知道:这样是否可以重载Worklight iOS库的HTTP行为? And if it is possible, how can I do it ? 如果可能的话,我该怎么办?

If you need to add header, you can use the options in invokeProcedure. 如果需要添加标题,则可以使用invokeProcedure中的选项。 In case you need more complicated things, I would suggest using NSURLProtocol -> https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSURLProtocol_Class/index.html 如果您需要更复杂的东西,我建议您使用NSURLProtocol-> https://developer.apple.com/library/ios/documentation/Cocoa/Reference/Foundation/Classes/NSURLProtocol_Class/index.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM