Deep Link Native App
Follow the steps to set up deep-linking for your app.
Setting up for iOS
1. Adding a URL scheme
Open up your project and go to Targets > Info > URL Types and add the following:
Change com.discoveryloft.pavejs
to your project's identifier
2. Define your deep links
We are going to support two deep links into the app:
pave://home
pave://detail
And we will represent the host
part of the URL in an enum
.
DeepLink.swift
3. Handle URLs
To handle the URL we need to go into our AppDelegate.swift
and parse the incoming request, and convert it into a DeepLink
that we can hand off to our MainViewController
for processing.
AppDelegate.swift
Once in the MainViewController
with the deeplink we can do whatever we want. Here we just manually navigate to the view controller in the tab bar we want to present.
MainViewController.swift
4. Test
You can try deeplinking into your app by firing up Safari in your simulator and enter URL in there (i.e. pave://home
).
Or an even better way is to execute deeplinks from the command line while your simulator is running with this command here:
xcrun simctl openurl booted pave://home
Setting up for Android
1. Add intent filters for incoming links
To create a link to your app content, add an intent filter that contains these elements and attribute values in your manifest:
According to Google, the autoVerify attribute “allows your app to designate itself as the default handler of a given type of link. So when the user clicks on an Android App Link, your app opens immediately if it's installed — the disambiguation dialog doesn't appear.”
2. Read data from incoming intents
Here’s a snippet that shows how to retrieve data from an Intent
:
Last updated