CN1 中的 NSAllowsArbitraryLoadsInWebContent

NSAllowsArbitraryLoadsInWebContent in CN1

我正在尝试处理 Apple 对代号一的 http 限制。

根据 iOS Cocoa keys 文档,NSAllowsArbitraryLoadsInWebContent 将按照以下说明在 iOS 10 上工作:

An optional Boolean value that applies only to content to be loaded into an instance of the following classes:

WKWebView

UIWebView (iOS only)

WebView (macOS only)

Set this key’s value to YES to obtain exemption from ATS policies in your app’s web views, without affecting the ATS-mandated security of your NSURLSession connections.

Default value is NO.

To support older versions of iOS and macOS, you can employ this key and still manually configure ATS. To do so, set this key’s value to YES and also configure the NSAllowsArbitraryLoads subkeys.

If you add this key to your Info.plist file, then, irrespective of the value of the key, ATS ignores the value of the NSAllowsArbitraryLoads key. Available starting in iOS 10.0 and macOS 10.12.

我的第一个问题是:

BrowserComponent 是否公开 WKWebView 或 UIWebView?在那种情况下,有问题的 Cocoa 键将起作用,并允许我避免 iOS 10.

的危险 NSAllowsArbitraryLoads

第二个问题:

为了确保与早期版本的兼容性,我明白我应该这样做:

我说得对吗?

谢谢

我不明白你试图采取什么步骤,但如果你想在你的应用程序中允许 http URL,Codename one 通过允许你添加这个构建提示

ios.plistInject=<key>NSAppTransportSecurity</key><dict><key>NSAllowsArbitraryLoads</key><true/></dict><key>CFBundleURLTypes</key><array><dict><key>CFBundleURLName</key><string>com.mycompany.myapp</string></dict><dict><key>CFBundleURLSchemes</key><array><string>MyApp</string></array></dict></array> 

相应地更改 com.mycompany.myappMyApp

只需添加该构建提示,您的 http / https URL 将在所有 iOS 版本(包括 iOS 9 和 10)上无缝运行。

我目前在我的一些应用程序上使用它并且它工作正常,也在 10.1 beta 3 上测试过。

编辑:

再次阅读您的问题后,我发现您的问题没有得到解答:

是的,即使 BrowserComponent 不公开 UIWebView,该键也可以使用。 (基于个人测试)

只需使用 NSAllowsArbitraryLoads 并将其设置为 true 如上所述,它会处理所有事情。如果设置 NSAllowsArbitraryLoadsInWebContent.

NSAllowsArbitraryLoads 只会在 iOS 10 中被忽略