19

I was able to open apps from safari this way:

window.location = 'myapp://do/xx';

or open facebook app:

window.location = 'fb://';

But this stopped working in iOS9.

How can I open apps using URL schemes in safari?

kevin
  • 4,177
  • 10
  • 32
  • 33
  • Kevin, I am seeing similar behavior, and haven't been able to find any documentation indicating this was intended. It seems like URI schemes just don't work on iOS 9, but perhaps I have things misconfigured. – shortstuffsushi Jul 13 '15 at 17:57
  • It's definitely a bug with iOS9 beta. I submitted a bug report to Apple and they closed it saying it's a duplicate of another issue which is still open. – skensell Jul 20 '15 at 07:43
  • @kevin have you found out the solution for this? I'm using window.location = 'myapp://do/xx'; to open my app too but it stops working. Thanks for sharing. – JHHoang Sep 25 '15 at 19:42
  • Possible duplicate of [iOS 9 not opening Instagram app with URL SCHEME](http://stackoverflow.com/questions/30987986/ios-9-not-opening-instagram-app-with-url-scheme) – thelaws Oct 07 '15 at 17:04

5 Answers5

3

IOS 9 URL Shchemes Update : iOS 9 introduces LSApplicationQueriesSchemes to allow apps to query if other apps are installed.

1- If a url scheme is declared and calling canOpenURL(scheme)

YES if a installed app supports that URL scheme

NO if no app supporting that url

syslog will show canOpenURL: failed for URL: "urlScheme://" - error: null

2- If a url scheme is not declared and calling canOpenURL(scheme)

always return NO

syslog will show canOpenURL: failed for URL: "urlScheme://" - error: null

In iOS 9, the developer must add these info.plist LSApplicationQueriesSchemes

<array>
    <string>urlscheme</string>
    <string>urlscheme2</string>
    <string>urlscheme3</string>
    <string>urlscheme4</string>
</array>

50 max. unqiue URL scheme can be declared!

Malek Belkahla
  • 510
  • 5
  • 17
2

With iOS9, Apple is changing a few things concerning URL schemes. Here is an article about those changes.

Basically, you now have to register all URL schemes that are supported by your app in your .plist file.

eschanet
  • 1,063
  • 6
  • 15
  • Eric, thanks for replying. I have 'URL Types' registered in the Info.plist. The article talks about 'canOpenURL' from inside objective-c/swift. I just want to open my app from Safari. – kevin Jul 11 '15 at 21:17
  • 1
    What about the most common URL scheme? taking users to rate your app on the app store. Is that killed too? str = [NSString stringWithFormat:@"itms-apps://itunes.apple.com/app/id%@",appIDStr]; [[UIApplication sharedApplication] openURL:[NSURL URLWithString:str]]; – Sam B Jul 11 '15 at 21:48
  • Also, [here](http://stackoverflow.com/a/30988328/4988014) is another answer that might be helpful. – eschanet Jul 11 '15 at 21:52
  • 2
    I'm investigating this today and am somewhat confused. I haven't been able to find any documentation about it, but it seems that existing URI Schemes just entirely stop working. What you're referring to is *outward* calls (thus the "queries" thing in the plist), but what about incoming (from Safari to your app)? – shortstuffsushi Jul 13 '15 at 17:55
  • 1
    I submitted a bug report to Apple. It's broken for me in iOS 9 beta 3. – skensell Jul 15 '15 at 12:39
  • 1
    ios 9 beta4 has the same problem.Could not open app via url scheme in safari. – yudun1989 Jul 23 '15 at 08:19
  • 1
    @yudun1989 was this ever resolved? I'm unable to open my app via url scheme in iOS 9 right now, but in iOS 8 all is good --- and unfortunately universal links are not an option for me for the moment. – Cameron Askew Oct 15 '15 at 20:15
2

With the general release of ios9 setting window.location to a custom url does launch the app, but only after the user hits open in a popup. I filed a bug with apple about this, and they responded saying that it was intended behavior for launching an app from safari. They said they would look into the issue where if you hit cancel it fails out on future attempts.

0

Just assign a desired address to the href property, instead of trying to replace the whole window.location object:

window.location.href = 'myapp://do/xx';

It works for me on iOS 9.0.2, but now safari shows a confirmation dialog to ensure а user really wants open your link in the app.

-1

this is how I have revised my Facebook/Google Login integration to get it work on latest update. which now user Safari web view.

<key>LSApplicationQueriesSchemes</key>
  <array>
      <string>fbapi</string>
      <string>fb-messenger-api</string>
      <string>fbauth2</string>
      <string>fbshareextension</string>
      <string>com.googleusercontent.apps.39373238582-opjuqokmar2i5t3sdk2vs5sifer4moen</string>
      <string>com-google-gidconsent-google</string>
      <string>com-google-gidconsent-youtube</string>
      <string>com-google-gidconsent</string>
      <string>com.google.gppconsent.2.4.1</string>
      <string>com.google.gppconsent.2.4.0</string>
      <string>googlechrome</string>
      <string>googlechrome-x-callback</string>
  </array>
swiftBoy
  • 35,607
  • 26
  • 136
  • 135