This article is part of the Adobe Experience Platform Mobile SDKs mini-series. It is about enabling your app to handle deep links.
You can find the overview here.
For the article about debugging, we will need to use so-called “deep links”, i.e. links that when tapped on your phone, will open your app rather than your browser.
This article is about how to add that capability to your app.
I will say up front that I can only show you how to do this on Android. There are tutorials out there for iOS, but not having an iPhone nor a developer account for the App Store, I can’t say how good they are.
Add Deep Link to your App
On Android, a lot of what your app can or should do is defined in the Manifest,
AndroidManifest.xml. In there, we define so-called “Intents“, and those Intents define “what our app feels responsible for” on the users’ phones, so to speak.
Our app will know which Intents it should react to because we define “Intent Filters” in
As usual, multiple ways lead to Rome. In this case, there is an App Links Assistant in Android Studio, or we can manually build everything.
Let’s keep this simple and use the App Links Assistant.
Open the Android App Link Assistant via the Tools menu.
The assistant walks us through the process in 4 easy steps:
- Add URL intent filters
- Add logic to handle the intent
- Associate website
- Test on device or emulator
Start the process by clicking the “Open URL Mapping Editor” button, then click the little “+” symbol to add a mapping.
In the dialog that pops up, add a host (which you must own) type a pathPattern (this has to exist on your server, except for the last part (I think)), and which Activity should be launched as a response to the deep link.
Note: I selected the Main Activity here, but a deep link would usually go somewhere else, I guess.
Once you Ok and close the dialog, you can type a URL into the field underneath, and the Mapping Editor will show you what Activity it would map to, if any.
Underneath, you can preview the changes that the assistant is making in your
Next, add logic to your Activity to handle the deep link by clicking the “Select Activity” button.
Select the Activity you chose (MainActivity in our case), then click “Insert Code”
The assistant will add three lines of code to the
// ATTENTION: This was auto-generated to handle app links. Intent appLinkIntent = getIntent(); String appLinkAction = appLinkIntent.getAction(); Uri appLinkData = appLinkIntent.getData();
This is all the code that is needed here.
Move on to configuring your web server to understand your URLs by clicking the “Open Digital Asset Links File Generator” button:
Don’t change anything in the generator right now.
If (or when) you do this for real, you have to switch to using a keystore file.
For now, just click the “Generate Digital Asset Links file” button.
If this is the first time you are doing this for this web server, you use the “Save File” button, then transfer the file to the URL indicated.
If you have done this before, you should add the lines in the preview into the existing file, instead.
Whichever way you do it, you can use the “Link and Verify” button to see if you did it right:
The final step in the Assistant is to test whether everything you have done so far actually works. You can test on your own phone. Connect it to your machine and enable debugging. Or you can test using an emulator, up to you.
Clicking the “Link and Verify” button opens a new dialogue, prepopulated with your server address.
Type the rest of your URL, then click the “Run Test” button.
The tester will show you which Activity is mapped to your URL.
It will then build the app and try to install it on your test device or launch the emulator and install it there.
Once the app is installed, the tester will simulate a tap on your link on the device, and you should see your app launch and a happy message in Android Studio telling you that “Your app is correctly linked to .MainActivity”
Awesome. We’re done!
You might wonder why we did this. Or why I chose to post this article, given that all I did was walk you through an assistant.
Point is, we will need deep links for the article about debugging with Project Griffon, and so I wanted to get it out of the way.
The important takeaway, for me, is that you need a publicly available web server.
Repeat: if you want to use Project Griffon, you need a publicly available web server!
And that’s why I’m posting this now. Giving you a week to sort out deep links.
Thank me later.
One thought on “Adobe Experience Platform Mobile SDKs – Deep Links (more setup)”