Reputation: 1754
From NSURLSession.h...
/* An optional array of Class objects which subclass NSURLProtocol.
The Class will be sent +canInitWithRequest: when determining if
an instance of the class can be used for a given URL scheme.
You should not use +[NSURLProtocol registerClass:], as that
method will register your class with the default session rather
than with an instance of NSURLSession.
Custom NSURLProtocol subclasses are not available to background
sessions.
*/
@property (nullable, copy) NSArray<Class> *protocolClasses;
Custom NSURLProtocol subclasses are not available to background sessions.
What would be the advantage of restricting custom NSURLProtocol subclasses to only trigger in foreground sessions?
Upvotes: 2
Views: 366
Reputation: 4278
From Apple documentation:
Background sessions are similar to default sessions, except that a separate process handles all data transfers.
Apple simply doesn't provide a way to inject your NSURLProtocol
subclass into another process, managed by iOS itself.
Same restriction applies to WKWebView
.
Upvotes: 1