My app extension needs to open the URL from many websites. I do the following:
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);
I can get the url, but at this moment I got this error:
App Transport Security has blocked the loading of the plaintext HTTP resource (http: //) because it is unsafe. Temporary exceptions can be configured through your application's Info.plist file.
I tried to completely disable ATS,
<key>NSAppTransportSecurity</key> <dict> <key>NSAllowsArbitraryLoads</key> <true/> </dict>
but it does not work, and I cannot list the websites inside NSExceptionDomain. I tried on the simulator and on the device. Can anybody help?
EDIT
I think the code causing the problem is:
NSString* htmlString = [NSString stringWithContentsOfURL: url encoding:NSUTF8StringEncoding]
I use this line of code after the url log to get html like plain text.
ios objective-c ios9 nsstring nsurl
Totka
source share