I have my own class NSURLProtocol which I implemented using this guide . My implementations are almost the same as in the tutorial, with the exception of names, data models, etc.
Essentially, I'm trying to send an HTTP request, but instead of a URL starting with: "http: //", it should start with, say, "bla: //"
Now I'm trying to register a protocol class and use it through the AFNetworking framework , and I'm having some problems.
canInitWithRequest: method starts returning NO at some point, and at that moment the request is not executed, and I continue to receive an "unsupported URL" error.
In addition to registering the protocol class , I tried to add the class to the AFHTTPSessionManager protocolClasses by calling this in the didFinishLaunchingWithOptions method:
[NSURLProtocol registerClass:[MyURLProtocol class]]; NSMutableArray *protocolsArray = [NSMutableArray arrayWithArray:[AFHTTPSessionManager manager].session.configuration.protocolClasses]; [protocolsArray addObject:[MyURLProtocol class]]; [AFHTTPSessionManager manager].session.configuration.protocolClasses = [protocolsArray copy];
And I also added a URL scheme to the URL scheme field in the info.plist application.
Still out of luck ... Is it possible that I'm trying to do? And if so, what could I miss? thanks
source share