Opening apps from Safari with iOS 9 Universal Link

2019-06-04 10:02发布

问题:

In this situation:

  1. Twitter's official app registered to handle twitter.com URLs with Universal Links on iOS 9
  2. User starts from Safari and have Twitter's official app installed
  3. User clicks a link one of Twitter's claimed URLs

What happens? Does it stay within Safari or switch to Twitter's app?

回答1:

Does it stay within Safari or switch to Twitter's app?

Switches to the Twitter app (tested on iOS 9.1 using Twitter app v6.39) unless you have turned it off (see the comment by st.derrick on Sep 24, 2015 in iOS9: Universal Links does not work).



回答2:

Does it stay within Safari or switch to Twitter's app?

Stay in Safari.


UPDATE: One workaround would be to have a second subdomain that you also use for Universal Links. Keeping with the Twitter example, if Twitter used ul.t.co for links, then users on twitter.com who click on ul.t.co would be taken into the Twitter app. Users of Branch benefit from this "feature" of Universal Links.


This seems to be an inherent limitation of Universal Links. If anyone solves this, I'd love to hear the solution.

Note that it's still possible to fire a URI scheme in the browser on iOS 9 -- we do this at my company, Branch. What you need to be aware of is that you cannot fire a URI scheme inside an iframe like you could on iOS 8 and below.

So I recommend examining the navigator.agent and:

  1. if it's iOS 9 and if so setting window.location = 'twitter://'; if you want to try to open the Twitter app. The user will see an error message if they don't have Twitter installed.

  2. if it's iOS 8 or below you can still fire the URI scheme in an iframe and the user will not see an error message if the app is not installed.



回答3:

Straight from Apples Website:

Use Universal Links to Enable Your App to Handle Links to Your Website

With emphasis on your website. This feature uses a combination of many things, one of which is Shared Web Credentials. Which is summarized as the following:

Accessing shared web credentials requires permission from the app, the website, and the user.

In order for access to be fulfilled an association must be created:

Add an apple-app-site-association file to your website. This file must include application identifiers for all the apps with which the site wants to share credentials, and it must be properly signed.

So in short, yes, but also no. It has to be supported by all the agencies/parties (website & app, just like handoff). In your circumstance, if twitter includes the proper certificates for universal links, (as well as Apple including entitlements) then it will redirect them as it already does.

To answer your question specifically, the technology itself is available in order to completely bypass Safari as a whole, by sending users directly to the app in question, instead of the http calls by adding specific entitlements to your own app (com.apple.developer.associated-domains), even though I understand what you meant. It's not made for Safari



回答4:

Stays in Safary.

From my expirience, app opens when clicking link from other apps (iMessage, Mail, Slack, etc.) and when clicking from google search results inside safary (if result links to applinks-page)



回答5:

It opens the link within the official Twitter app.

From Apple's docs

Universal links let iOS 9 users open your app when they tap links to your website within WKWebView and UIWebView views and Safari pages, in addition to links that result in a call to openURL:, such as those that occur in Mail, Messages, and other apps.

For users who are running versions of iOS earlier than 9.0, tapping a universal link to your website opens the link in Safari.