How to open URL schemes from Safari in iOS9?

烂漫一生 提交于 2019-11-30 06:27:09

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!

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.

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.

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.

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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!