2

I have listings on an app that contain many different URL's; therefore, I've set my info.plist to ...

<key>NSAppTransportSecurity</key>
<dict>
    <key>NSAllowsArbitraryLoads</key>
    <true/>
</dict>

On the simulator everything works. On my testing devices it won't work.

Error is...

2015-11-10 18:58:05.159 MPSTApp[520:169178] -canOpenURL: failed for URL: "https:/www.facebook.com/prontosantateresa -- file:///" - error: "This app is not allowed to query for scheme file"

The code calling the url link is such -

var anchorLink: String?

func loadWebPage(){
    let requestURL = NSURL(string: anchorLink!)
    let request = NSURLRequest(URL: requestURL!)
    webView.loadRequest(request)
}
pjmanning
  • 1,241
  • 1
  • 20
  • 48
  • This is not related to ATS, but rather a change in IOS9 that requires your app to declare the URL schemes it will query in its info.plist - http://stackoverflow.com/questions/30987986/ios-9-not-opening-instagram-app-with-url-scheme/30988328#30988328 – Paulw11 Nov 11 '15 at 00:06
  • But what if users are able to post their own links. Or link URLs change from an API. That means the URLs could change and be anything. For example what would twitter do for all the links posted inside tweets. – pjmanning Nov 11 '15 at 00:22
  • You can open any URL scheme you like, but if you are going to call `canOpenUrl` on that scheme it must be in your Info.plist. – Paulw11 Nov 11 '15 at 00:23

2 Answers2

1

You've got a typo in your URL. Change:

https:/facebook.com

To:

https://facebook.com

Also, you should change LSAllowsArbitraryLoads back to the default value, since that's best for most apps.

Abhi Beckert
  • 32,787
  • 12
  • 83
  • 110
  • Thanks Abhi. I noticed that in the error as well and thought that to be the issue. I'm pulling the link (as well as others) from a string of text. The string would come out as `https://facebook.com`. I'm guessing the link is seeing the // as an escape character? – pjmanning Nov 12 '15 at 01:33
0

For iOS9, you must add something to the plist file:

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>fbapi</string>
    <string>fbapi20130214</string>
    <string>fbapi20130410</string>
    <string>fbapi20130702</string>
    <string>fbapi20131010</string>
    <string>fbapi20131219</string>    
    <string>fbapi20140410</string>
    <string>fbapi20140116</string>
    <string>fbapi20150313</string>
    <string>fbapi20150629</string>
    <string>fbauth</string>
    <string>fbauth2</string>
    <string>fb-messenger-api20140430</string>
</array>

For more: Preparing Your Apps for iOS9

tuledev
  • 10,177
  • 4
  • 29
  • 49