How to open your app from a link on Android and iOS (beginner guide)
A first guide to app links: pick a URL, register it on Android and iOS, prove you own the domain with two small files, read the link in code, and test it. Covers custom schemes and https links, with the Kotlin and Swift you need and the mistakes beginners hit.
To open your app from a link, the app has to tell the phone which URLs it handles, and for normal https links your website has to confirm it. On Android that's an intent filter in the manifest plus an assetlinks.json file on your domain. On iOS it's the Associated Domains capability plus an apple-app-site-association file. When someone taps a matching link, the phone starts your app and passes it the URL, and your code shows the right screen.
This guide goes through it step by step for both platforms. Each step links to a deeper post if you get stuck.
Step 1: choose the kind of link
There are two kinds, and you'll probably use both.
| Custom scheme | https link | |
|---|---|---|
| Example | myapp://product/42 |
https://links.example.com/product/42 |
| Needs a website | No | Yes |
| If the app isn't installed | Nothing happens, or an error | The web page opens |
| Good for | Trying things out, links inside your own app | Anything you share with people |
Start with a custom scheme if you want to see a link open your app in ten minutes. Use https links, called App Links on Android and Universal Links on iOS, for everything public. The full comparison is in Universal Links vs deep links vs URI schemes.
Pick the URL shape now and keep it the same on both platforms: /product/<id>, /invite/<code>, /order/<id>.
Step 2: Android, register the link
Open AndroidManifest.xml and add intent filters to the activity that should open:
<activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTask">
<!-- Custom scheme: myapp://product/42 -->
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" />
</intent-filter>
<!-- https link: https://links.example.com/... -->
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="https" android:host="links.example.com" />
</intent-filter>
</activity>
What each line is for:
VIEWsays "this activity can show something".BROWSABLEallows a browser or another app to start it from a link. Without it, taps do nothing.DEFAULTlets the system pick the activity without naming it.autoVerify="true"asks Android to check your website's file (next step), so the link opens the app directly.
Keep the scheme and the https host in separate filters.
Step 3: Android, prove you own the domain
Create a file called assetlinks.json:
[
{
"relation": ["delegate_permission/common.handle_all_urls"],
"target": {
"namespace": "android_app",
"package_name": "com.example.app",
"sha256_cert_fingerprints": ["AA:BB:CC:…"]
}
}
]
Host it at exactly https://links.example.com/.well-known/assetlinks.json. It must answer with HTTP 200, Content-Type: application/json and no redirect.
The fingerprint identifies the key that signed your app. Get it for a debug build with:
keytool -list -v -keystore ~/.android/debug.keystore -alias androiddebugkey -storepass android
An app installed from Google Play is signed with a different key, the Play App Signing key, and Play Console shows its fingerprint on the App signing page. List both. This is the most common beginner mistake: the link works in your test build and not for users. More in Android App Links not verified? Fix assetlinks.json.
Since Android 12, an https link that isn't verified opens the browser, with no chooser, so this step isn't optional.
Step 4: Android, read the link
The URL arrives in the intent. Read it when the activity is created and again when a link arrives while the app is already open:
class MainActivity : AppCompatActivity() {
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_main)
handleLink(intent)
}
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
handleLink(intent)
}
private fun handleLink(intent: Intent?) {
val uri = intent?.data ?: return
val segments = uri.pathSegments // ["product", "42"]
if (segments.firstOrNull() == "product") {
openProduct(segments.getOrNull(1) ?: return)
}
}
}
Beginners often write only the onCreate half. Then links work when the app is closed and do nothing when it's open in the background.
Step 5: iOS, register the link
Custom scheme. In Xcode, select the target, open the Info tab and add a URL Type with myapp under URL Schemes.
https link. Open Signing & Capabilities, add the Associated Domains capability and add:
applinks:links.example.com
No https:// and no path. This capability needs a paid Apple Developer account.
Step 6: iOS, prove you own the domain
Create a file called apple-app-site-association, with no .json extension:
{
"applinks": {
"details": [
{
"appIDs": ["ABCDE12345.com.example.app"],
"components": [
{ "/": "/product/*" },
{ "/": "/invite/*" }
]
}
]
}
}
ABCDE12345 is your team ID and com.example.app is the bundle identifier. Host the file at https://links.example.com/.well-known/apple-app-site-association, over HTTPS, with HTTP 200 and no redirect.
iPhones don't download this file from your server. Apple's CDN fetches it and devices read Apple's copy, so the file has to be reachable from the public internet, and a change can take a while to arrive. The phone reads it when the app is installed, so after you fix the file, delete the app and install it again.
If you don't want to write the two files by hand, the generator builds both from your IDs, and how to host them on Vercel, Netlify, nginx and Cloudflare covers the server side.
Step 7: iOS, read the link
In a SwiftUI app, one modifier receives custom scheme links and Universal Links:
@main
struct ExampleApp: App {
var body: some Scene {
WindowGroup {
ContentView()
.onOpenURL { url in
route(url)
}
}
}
}
func route(_ url: URL) {
let parts = url.pathComponents // ["/", "product", "42"]
if parts.count >= 3, parts[1] == "product" {
openProduct(id: parts[2])
}
}
In a UIKit app with a scene delegate, Universal Links arrive as a user activity, in two places:
// App was closed
func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
if let activity = connectionOptions.userActivities.first(where: { $0.activityType == NSUserActivityTypeBrowsingWeb }),
let url = activity.webpageURL {
route(url)
}
}
// App was already running
func scene(_ scene: UIScene, continue userActivity: NSUserActivity) {
guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,
let url = userActivity.webpageURL else { return }
route(url)
}
Custom scheme links in UIKit arrive separately, in scene(_:openURLContexts:).
Treat the URL as outside input. Check the path and the values before you act on them, and never let a link do something destructive without the person confirming.
Step 8: put the link somewhere and tap it
On a web page, it's an ordinary link:
<a href="https://links.example.com/product/42">Open in the app</a>
To test from your computer:
# Android
adb shell am start -W -a android.intent.action.VIEW \
-c android.intent.category.BROWSABLE \
-d "https://links.example.com/product/42"
# Has Android verified the domain? (Android 12 and later)
adb shell pm get-app-links com.example.app
# iOS Simulator
xcrun simctl openurl booted "https://links.example.com/product/42"
On a real phone, put the link in a notes app or a chat message and tap it. Don't type or paste it into the browser's address bar: on both platforms that loads the web page and never opens the app.
Test four cases on each platform: app closed, app in the background, app already on another screen, and app not installed. All the commands are in how to test deep links on Android and iOS.
If it doesn't open
| What happens | Most likely cause |
|---|---|
| Android opens the browser | The domain isn't verified: wrong fingerprint, a redirect on the file, or autoVerify missing |
| iOS opens Safari | The app ID in the file doesn't match, the file isn't reachable by Apple's CDN, or the app was installed before the file was right |
| It works from Notes but not from Instagram | In-app browsers keep links inside their own web view |
| The app opens on the home screen | The link arrived but the code didn't route it, or routed it before the screen was ready |
| It works when the app is closed but not when open | onNewIntent or scene(_:continue:) isn't implemented |
Run your domain through the validator first. It reads both files the way Apple and Google do and names what's wrong. Then use the checklists for iOS and Android.
What about people who don't have the app?
An https link opens your web page for them, which is a reasonable start. Most apps want more: send the person to the App Store or Google Play, and after they install, open the screen the link was for. That's called deferred deep linking, and it needs a server that remembers the click. Read what deferred deep linking is before you build it yourself.
FAQ
How do I make a link open my app instead of the browser?
Use an https link on a domain you control, register the domain in the app (an intent filter with autoVerify on Android, Associated Domains on iOS), and host assetlinks.json and apple-app-site-association on that domain so the phone can confirm the app is yours.
Do I need a website to open my app from a link?
For a custom scheme such as myapp://, no. For https links you need a domain that can serve two small files over HTTPS. It doesn't need any pages.
Why does my link open the Play Store or the browser instead of the app?
On Android, the domain isn't verified for the installed build, usually because of the signing fingerprint. On iOS, the association file and the app's ID don't match or Apple hasn't fetched the file yet.
Can one link work on both Android and iOS?
Yes. The same https URL can be an App Link on Android and a Universal Link on iOS. Host both files on the domain and register it in both apps.
Does this work in React Native, Flutter or Expo?
Yes. The native set-up is the same, and the framework gives you the URL in its own way. See the React Native guide, the Expo guide and the Flutter guide.
The short way
CodeOnAir AppLinks takes care of the parts that go wrong most: it gives you a link domain, hosts both files for it from the IDs you enter, sends people without the app to the right store and brings them back to the right screen after install. In the app, one callback receives every link. The quick guide gets a first link working, and you can create a free account: the Free plan includes 100 app links.
Checked on 16 November 2026 against Android's App Links documentation and Apple's documentation on Universal Links and associated domains.