One, foreword
Speaking of Universal Link (Universal Link), for students who have had iOS development, must be useful. Currently, you need to configure Universal Link when applying for wechat sharing or logging in. For Universal Link, you probably know:
- Apple WWDC 2015 introduced new features for iOS 9.
- Conveniently launch the App directly by opening an HTTPS link (if the App is installed on your phone).
- Seamless links to Web-apps can provide a great user experience.
But, conversely, why Universal Link? This is the interesting content of this article. The following content is compiled based on the previous content shared by the team.
Why Universal Link?
We know that the emergence of a new thing must not appear out of thin air. Similarly, the emergence of Universal Link must be based on a certain reason or foundation. Therefore, Universal Link based on Scheme and put forward.
URL Scheme
URL Scheme is generally used to jump from one App to another App, which belongs to the jump between applications. Of course, in the browser (also known as App), the Web page can also be jumped to App through Scheme ://, but this method will pop up every time the jump, if the App is not installed in the device, an error message will pop up directly, and the experience is not friendly. You should be familiar with the following scheme:
Scheme: / / weixin: / / dl/moments (friends) weixin: / / scanqrcode (WeChat scan code) alipayqr: / / platformapi/startapp? SaId =10000007 shoebox:// (Apple Pay)Copy the code
Why do URL schemes exist?
So, again, why URL schemes?
When iPhoneOS came out in that year, there was already a sandbox mechanism, which resulted in that two apps could not read each other’s sandbox space and could not communicate directly. Therefore, Apple provided Apple URL Scheme Reference to solve the problem that its own apps could not interact.
For example, if I see a phone number on a web page in Safari, can I dial the number directly? We know we can code it like this:
HTML link:
<a href="tel:1-408-555-5555">408-555-5555</a>
Native app URL string:
tel:1-408-555-5555
Copy the code
As you can see in the documentation of Apple, URL Schemes are available to developers in iPhoneOS. Details of Apple URL Schemes can be found in the documentation of About Apple URL Schemes.
The apps that use URL Schemes the most are the efficiency tools class, because they have workflow requirements, so they make A lot of different versions of URL Schemes, including callback-URL callbacks.
What are the disadvantages of Scheme?
Universal Link, so what’s wrong with URL Schemes? Conversely, what are the advantages of Universal Link?
The Universal Link advantages
Universal Link has four main advantages:
- generality
- flexibility
- security
- privacy
Universality: A URL is common to both your website and App. Universal Links is a standard URL format, while a custom URL Scheme may be interpreted as a special URL Scheme. By default, only your App can resolve it, not your browser.
Flexibility: Universal Links can be used even if your App is not installed. When your app is not installed, you can open the link and display the content of your website in Safari, which is in line with the user’s expectation. Meanwhile, the webpage can display the guidance to download from AppStore, further improving the user experience.
Security: Only the developer’s own network domain name is configured with apple-app-site-association, the corresponding app can be invoked. However, the Scheme configured with URL Scheme can be configured with the same Scheme for any App, which cannot guarantee the safe invocation of developer App. In addition, when a user installs your App, iOS will check the configuration of the files you have uploaded to the web server to make sure that only your website is allowed to call your App.
Privacy: Once upon a time, you could use Scheme to check whether your App was installed or not. In fact, once you know what apps users have installed, you can analyze their preferences or habits, of course, for now. On the other hand, many apps will pretend to register well-known App schemes to block scheme initiation of legitimate apps.
Note: In iOS 9, Apple has changed URL Schemes to whitelist, which means only whitelisted Schemes can check for other applications. At the same time, you can have a maximum of 50 different Schemes whitelist (if more than 50 Schemes call canOpenURL, return NO).
In addition, Universal Link must be configured when wechat creates an application. For details, see the document: wechat Open Platform releases a new version of SDK. Developers are requested to update it as soon as possible. In terms of security and privacy, wechat is the best and most avant-garde, and even the SDK of overseas Facebook and Google has not put forward the idea of Universal Link.
The Universal Link configuration
- Only iOS 9+ is supported
- Have a domain name
- Accessing domain names over SSL (that is, HTTPS supported)
- Upload a JSON file to the domain name (named
apple-app-site-association
Json format file)
There are many online tutorials on Universal Link configuration that I won’t go into here. Support Universal Links, Supporting Universal Links in Your App
The Universal Link pit
While apple provide search.developer.apple.com/appsearch-v… The web page lets developers check that the Universal Link configuration is normal, but if you check for abnormal links, the Universal Link may be normal. The biggest pitfall is that it must be cross-domain, such as configuring Universal Link to: https://applink.app.com, so this Link can not be directly called in the page to evoke App, must be other secondary domain name, therefore, general Universal Link configuration Link is a separate secondary domain name, separate from the business domain name.
Finally, there are two common ways to check your configuration:
Universal Link feature Review
Finally, a review of Universal Link’s new features over the years.
Universal Link will be available on iOS 9 in 2015 and on tvOS in 2017.
Until 2019, refined address matching is supported, allowing multiple apps to share a set of configurations, paths, etc.
Wildcard matches, for example.
*
: asterisks match zero or more characters, and match greedily. It will match as many characters as possible.?
: Question mark matches one character.? *
: To match at least one character, use a question mark followed by an asterisk.
Support macOS 10.15 or above, note that Mac apps, if downloaded from the Mac AppStore, Universal Link has taken effect by default, while developers need to open the App at least once before it takes effect.
In 2020, Apple released SwiftUI, a cross-platform UI framework that supports iOS, macOS, tvOS, and watchOS, so it’s natural to support watchOS as well. Note that if the Universal Link is invalid, watchOS cannot handle it and will display an error message. WebKit has been available since watchOS 5, but Safari is still not built into watchOS. Haha, I don’t know if you expect support ~
At the same time, support case ignoring pattern matching through configuration"caseSensitive": false
To disable case sensitivity. Solve the problem of different front-end pages or case.
Unicode schema support, such as ChineseSautéed Vermicelli with Spicy Minced Pork
Ulr encode is required to read by default. through"percentEncoded": false
In this way, any language is directly displayed, convenient display and maintenance, but also reduce link length.
The last key function is the support of substitution variables. For example, if the App sells different products in multiple countries and regions, a certain country or region may not sell a certain product, so a lot of data needs to be written before /en_US/
,/fr_CA/
The language region identifier is not available.
Now, Apple provides common variables by default, for example, with$(alpha)
To represent the[ "A","a", "B", "b", "C", ... "Z", "z" ]
Any character in. And the same thing.
For example, by field"substitutionVariables":
From the defined character set, which can then be applied to"components":
, withThe $()
To include the substitution.
“/$(lang)_CA/$(Canadian food)/”, “percentEncoded”: False indicates that Canadian food contains a product that matches any language in Canada and is encoded in Unicode because the last product is the “tete-de-violon” non-English character. Similarly, the second contains “exclude”: true to exclude the path.
The original Universal Link is a URL request configured in the App when the user installs the App by defaultapple-app-site-association
Contents of the configuration file. However, the deployment of developer websites may be different from users, resulting in the access speed cannot be guaranteed. Therefore, Apple instead requests apple-app-site-Association configuration files through Apple CDN and caches them, so as to speed up the acquisition of configuration files for users in different regions.
Finally, Apple provides a way to bypass the CDN to download the configuration file, which is also convenient for developers to test Universal Link. Specifically, in SettingsDeveloper
下 Associated Domains Development
And then configure it in Xcodeassociated-domains
When Universal Link is linked, splice? mode=developer
At this time, Universal Link can be deployed on the internal network, without the need for external network deployment, which is very convenient for debugging.
Third, summary
Finally, we summarize the functional evolution of URL Scheme and Universal Link from a product perspective.
URL schemes have changed from breaking the disconnection between apps to relying heavily on productivity tools, among which Workflow App was the most popular at that time and was later acquired by Apple. As just said, apple can acquire more system-level permissions after being acquired, which is actually very good for efficiency apps! Later, Apple renamed Workflow Shortcuts and made it accessible to Siri.
For example, Shortcuts will read NFC card permissions and open all apps! No need to rely on URL Scheme, open all apps! So, for Shortcuts, you don’t need to rely on URL Scheme at all.
Of course, 3D Touch is an innovative way of interaction for Apple, but users are not used to it. Hidden interaction design is, objectively speaking, unfriendly to the user experience.
Of course, in the end URL Scheme persists! Because third-party apps cannot interact directly with each other. In addition to interaction, it is also a solution to open a certain function or path of the App and add it to the main screen by USING PWA. However, it is not easy to promote for ordinary users who need to be taught.
In the end, Universal Link concludes that universality, security, flexibility, and privacy are all in the developer’s hands, as no one else can fake them. Simply put, through the domain name and background control, can be adjusted at any time, no impact on users.
For example, On the Web page, Zhihu uses Universal Link to display “open in App”, while the top is “use”Smart App BannersDisplay open or display when the user installs the App or does not install the App (open the App when clicking, or open the AppStore to display). Of course, Zhihu also uses the URL Scheme backstop, and finally, the web landing page that displays the boot installation of Universal Link.
Handoff also needs to use the Universal Link configuration file to verify permissions, and Shared Web Credentials are optimized for login with Shared accounts between Web and app.
Apple also uses apple-app-site-Association to create permissions for App Clips, a small App introduced last year.
The in-App Events app Store launched this year also requires Universal Link.
Finally, we said the origin of URL Scheme and Universal Link. At present, Universal Link can not completely replace URL Scheme, but Universal Link because of its advantages, Apple is putting more and more functionality verification into Universal Link configurations, and we believe there will be more Universal Links to come. Therefore, understand the reasons behind the emergence of these functions and solve the problems, for us to master things are helpful, I hope you have a harvest, if you feel can, welcome to like forwarding ah ~
Welcome to join us in the comments section
Please follow us for more updates on iOS and Apple
Iv. Reference
- About Apple URL Schemes
- URL Schemes use details
- Getting Started with iOS Automation: Read URL Schemes – Minority
- WeChat open platform to release a new version of the SDK, developers as soon as possible, please update | WeChat open community
- App Search Programming Guide: Support Universal Links
- Universal Links – Apple Developer
- Supporting Universal Links in Your App | Apple Developer Documentation
- Allowing Apps and Websites to Link to Your Content | Apple Developer Documentation
- What’s new in Universal Links – WWDC20
- What’s New in Universal Links – WWDC19
- Extend Your App’s Presence with Deep Linking – WWDC17
- Universal Links New features – small column
- WWDC20 10098 – What’s New in Universal Links – small column
- Workflow Help
- Quick Instruction Manual – Apple support
- Promoting Apps with Smart App Banners | Apple Developer Documentation
- Configure and link your App Clips – WWDC20 – Videos – Apple Developer
- Meet in-app events on the App Store – WWDC21 – Videos – Apple Developer