CN1中的NSAllowsArbitraryLoadsInWebContent [英] NSAllowsArbitraryLoadsInWebContent in CN1

查看:578
本文介绍了CN1中的NSAllowsArbitraryLoadsInWebContent的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试处理Apple对Codename One的http限制.

I'm trying to deal with Apple's http restrictions on Codename One.

根据iOS Cocoa密钥文档,NSAllowsArbitraryLoadsInWebContent将在以下说明的iOS 10上运行:

According to iOS Cocoa keys doc, NSAllowsArbitraryLoadsInWebContent will work on iOS 10 following these instructions:

一个可选的布尔值,仅适用于要加载的内容 进入以下类的实例:

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

WKWebView

WKWebView

UIWebView(仅适用于iOS)

UIWebView (iOS only)

WebView(仅适用于macOS)

WebView (macOS only)

将此键的值设置为YES,以免除ATS策略中的 您的应用的网络浏览量,而不会影响ATS规定的安全性 您的NSURLSession连接.

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.

默认值为否.

要支持旧版本的iOS和macOS,您可以使用此密钥 并且仍然手动配置ATS.为此,请将此键的值设置为 是,并配置NSAllowsArbitraryLoads子项.

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.

如果将此密钥添加到Info.plist文件中,则无论 密钥的值,ATS会忽略NSAllowsArbitraryLoads的值 钥匙.从iOS 10.0和macOS 10.12开始可用.

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?在这种情况下,所讨论的可可密钥将起作用,并允许我避免iOS 10冒风险的NSAllowsArbitraryLoads.

Does BrowserComponent expose WKWebView or UIWebView? In that case, the Cocoa key in question will work, and allow me to avoid the risky NSAllowsArbitraryLoads for iOS 10.

第二个问题:

为确保与早期版本兼容,我知道我应该这样做:

To ensure compatibility with earlier versions, I understand I should do this:

  • 将NSAllowsArbitraryLoads设置为true(由于以下几点,在iOS 10中将被忽略).

  • Set NSAllowsArbitraryLoads to true (this will be ignored in iOS 10 because of the following point).

将NSAllowsArbitraryLoadsInWebContent设置为true(在iOS 9中将被忽略,并将使用NSAllowsArbitraryLoads).

Set NSAllowsArbitraryLoadsInWebContent to true (this will be ignored in iOS 9 and NSAllowsArbitraryLoads will be used).

我说得对吗?

谢谢

推荐答案

我不理解您要采取的步骤,但是如果您尝试在应用程序中允许使用HTTP URL,则通过允许您添加此构建提示使其变得简单

I don't understand what steps you were trying to take, but if you are trying to allow http URLs in your application, Codename one made it simple by allowing you to add this build hint

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网址即可在所有iOS版本(包括iOS 9和10)上无缝运行.

Just add that build hint and your http / https URLs will work seamlessly on all iOS versions including iOS 9 and 10.

我目前在某些应用程序上使用了此功能,并且在10.1 beta 3上也进行了测试.

I currently use this on some of my apps and it works fine, tested on 10.1 beta 3 as well.

再次阅读您的问题后,我意识到您的问题没有得到回答:

After reading your question again, I realized that your questions were not answered:

是的,即使BrowserComponent不公开UIWebView,该键也将起作用. (基于个人测试)

Yes, the key will work even if BrowserComponent doesn't expose UIWebView. (Based on personal test)

只需使用NSAllowsArbitraryLoads并将其设置为true(如上所述),它将处理所有内容.如果您设置NSAllowsArbitraryLoadsInWebContent,则仅在iOS 10中将忽略NSAllowsArbitraryLoads.

Just use NSAllowsArbitraryLoads and set it to true as discussed above, and it will handle everything. NSAllowsArbitraryLoads will only be ignored in iOS 10 if you set NSAllowsArbitraryLoadsInWebContent.

这篇关于CN1中的NSAllowsArbitraryLoadsInWebContent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆