Adobe Experience Platform Mobile SDKs – Deep Links (more setup)

[screenshot]

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 AndroidManifest.xml.

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.

[screenshot]
Launch App Link Assistant
Open the Android App Link Assistant via the Tools menu.

[screenshot]
The App Link Assistant
The assistant walks us through the process in 4 easy steps:

  1. Add URL intent filters
  2. Add logic to handle the intent
  3. Associate website
  4. 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.

[screenshot]
Add URL 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.

[screenshot]
Mapping Editor
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 AndroidManifest.xml

[screenshot]
Check URL and see changes
Next, add logic to your Activity to handle the deep link by clicking the “Select Activity” button.

[screenshot]
Open Activity Selector
Select the Activity you chose (MainActivity in our case), then click “Insert Code”

[screenshot]
Insert Code
The assistant will add three lines of code to the onCreate() method:

    // 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:

[screenshot]
Open Digital Asset Links file Generator
Don’t change anything in the generator right now.

[screenshot]
Digital Asset Links file Generator
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.

[screenshot]
File Contents
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:

[screenshot]
Link and Verify

Testing

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.

[screenshot]
Testing…
It will then build the app and try to install it on your test device or launch the emulator and install it there.

[screenshot]
Installing the app…
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”

[screenshot]
Success!
Awesome. We’re done!

Notes

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)

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.