简体   繁体   中英

Is it possible to open an Native iOS app by using Custom url scheme without a webpage directs to custom url?

I am trying to open an Native iOS app by clicking a link in email. I had used "Custom url scheme". If i type "test://" in safari browser then my native iOS app is opened. But if i click a link "test://" in email then it prefixed with http like " http://test// " and its not opening an iOS App. I went through lot of links and found that "iOS needs a Webpage which will redirect to custom url of native iOS App" to open an app. Is it possible to open an app from email link without using a webpage redirects to app?

Advance, Thanks for any help !

The simple answer is likely no, as you have little control over how individual apps will handle links. The complex answer is that you should do something about it. Note that it won't always require returning a full web page -- on Android with Chrome you can fire a 307 redirect straight to a Chrome intent.

You could set up a simple web server that, when pinged, returns `window.location = 'test://'.

Or better yet, you can try to open the URI scheme in an iframe then fallback to a web URL if the app isn't present. This can be achieved using the following mechanisms:

  1. on iOS 9, use Universal Links
  2. in Chrome (and soon, Firefox 41.0!) use Chrome Intents
  3. on all other browsers, use client-side javascript

Here's an example of client-side javascript:

<script type="text/javascript">
    window.onload = function() {
        // Deep link to your app goes here
        document.getElementById("l").src = "my_app://";

        setTimeout(function() {
            // Link to the App Store should go here -- only fires if deep link fails                
            window.location = "https://itunes.apple.com/us/app/my.app/id123456789?ls=1&mt=8";
        }, 500);
    };
</script>
<iframe id="l" width="1" height="1" style="visibility:hidden"></iframe>

This is exactly what we do at my company, branch.io . We're constantly dealing with changes to browsers and webviews because there are always new scenarios to cover. It's essential to look at the user agent string when deciding how to deeplink a user into your app.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM