How to Deep Link Mobile Apps: URL Schemes and Universal Links Explained
This article explains the purpose, mechanisms, and implementation details of deep linking mobile apps using custom URL schemes and Universal Links, covering success detection, fallback strategies, and practical code examples for both Android and iOS platforms.
Introduction
When a user clicks a push notification or a link in a third‑party app (e.g., WeChat), a web page may need to open a specific screen of a native app such as NetEase News. This process is called deep linking or app wake‑up .
Why Deep Linking Matters
The main goals are to acquire users and to capture the time they spend inside the app, making the wake‑up step essential for product growth.
Two General Solutions
URL Scheme
Universal Links
1. URL Scheme
A URL Scheme is a custom protocol that launches an app, e.g., newsapp:// for NetEase News, weixin:// for WeChat, or openApp.jdMobile:// for JD.
Format: [scheme]://[path]?[query]. The path part identifies a specific function page inside the app, such as newsapp://doc/F6RAR7OF05179U0P to open an article.
Implementation example using an invisible iframe:
const url = 'newsapp://doc/F6RAR7OF05179U0P'; // target article
const iframe = document.createElement('iframe');
iframe.style.display = 'none';
document.body.appendChild(iframe);
iframe.src = url;Because browsers cannot directly detect whether the scheme succeeded, a common pattern is to set a timer (e.g., 1.2 seconds) and listen for the page‑visibility change event. If the page becomes hidden, the app was launched and the timer is cleared; otherwise the fallback logic runs.
const loadTimer = setTimeout(() => {
// fallback when scheme fails
unSchemeOpenApp();
}, 1200);
document.addEventListener('visibilitychange', function () {
if (document.hidden || document.webkitHidden) {
clearTimeout(loadTimer);
}
}, false);
window.addEventListener('pagehide', function () {
clearTimeout(loadTimer);
}, false);2. Universal Links
Introduced by Apple in iOS 9, Universal Links are standard HTTPS URLs that can open an installed app without leaving Safari; if the app is not installed, the link behaves like a normal web link.
Advantages:
Uniqueness – they use standard HTTP/HTTPS, avoiding protocol collisions.
Flexibility – they work even when the app is absent, falling back to the web page.
Security – iOS verifies a developer‑hosted apple-app-site-association file before allowing the link.
NetEase News Universal Link example: https://m.163.com/newsapp/applinks.html?path=/doc/{docid} Common path values:
/doc/{docid} – open an article
/topic/{tid} – open a topic
/shortvideo/{vid} – open a short video
If the user does not have the app, the intermediate page can guide them to download the app.
3. Fallback Strategies
When neither scheme nor Universal Links work, three fallback routes are used:
Redirect to Tencent App Store (App QQ, App WeChat, etc.) which can wake the target app.
Show a download page (Universal Link intermediate page) that prompts the user to open the app via the browser.
Directly offer the Android APK download.
Redirect to Tencent App Store example:
if (isTencentMarketCase) {
const pkgname = 'com.netease.newsreader.activity';
const tencent = `http://a.app.qq.com/o/simple.jsp?pkgname=${pkgname}&ckey=CK1331205846719&android_scheme=${wechatScheme}&ios_scheme=${wechatScheme}`;
window.location.href = tencent;
return;
}iOS fallback to the intermediate page:
if (isIOS) {
const downloadPage = '//m.163.com/newsapp/applinks.html?path=' + path;
window.location.href = downloadPage;
return;
}Android APK download fallback:
if (isAndroid) {
const androidDownloadUrl = '//static.ws.126.net/163/apk/newsapp/newsreader_sps_article.apk';
showToast(androidDownloadUrl, channel, scheme, spss);
}Visual Overview
Conclusion
Deep linking can be achieved through URL Schemes for installed apps, Universal Links for iOS, and a set of fallbacks (Tencent App Store, download pages, direct APK) for cases where the primary methods fail. By combining these techniques and handling success detection with timers and visibility events, developers can maximize the probability of a seamless user transition from web content to native app functionality.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
