我的应用扩展程序需要从许多网站打开URL.我做如下:
for (NSExtensionItem *item in self.extensionContext.inputItems) { for (NSItemProvider *itemProvider in item.attachments) { if ([itemProvider hasItemConformingToTypeIdentifier:(NSString *)kUTTypeURL]) { [itemProvider loadItemForTypeIdentifier:(NSString *)kUTTypeURL options:nil completionHandler:^(NSURL *url,NSError *error) { NSLog(@"URL: %@",url);
App Transport Security has blocked a cleartext HTTP (http://) resource load since it is insecure. Temporary exceptions can be configured via your app’s Info.plist file.
我试图完全关闭ATS,
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
但它不起作用,我无法在NSExceptionDomain中列出网站.我试过模拟器和设备.有人可以帮忙吗?
编辑
我认为导致问题的代码是这样的:
NSString* htmlString = [NSString stringWithContentsOfURL: url encoding:NSUTF8StringEncoding]
我在url log之后使用这行代码将html作为纯文本.