ios - 自定义 NSURLProtocol 子类对后台 session 不可用
<p><p>来自 <strong>NSURLSession.h</strong>...</p>
<pre><code>/* 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 +, 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;
</code></pre>
<blockquote>
<p>Custom NSURLProtocol subclasses are not available to background
sessions.</p>
</blockquote>
<p>将自定义 NSURLProtocol 子类限制为仅在前台 session 中触发有什么好处? </p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>来自 Apple 文档:</p>
<blockquote>
<p>Background sessions are similar to default sessions, except that a separate process handles all data transfers.</p>
</blockquote>
<p>Apple 根本不提供将您的 <code>NSURLProtocol</code> 子类注入(inject)到另一个由 iOS 本身管理的进程的方法。</p>
<p>同样的限制适用于 <code>WKWebView</code>。</p></p>
<p style="font-size: 20px;">关于ios - 自定义 NSURLProtocol 子类对后台 session 不可用,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/34865414/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/34865414/
</a>
</p>
页:
[1]