Skip to content

Handling URLs using the SDK

Once you have correctly set up the intent filters in your Manifest file, your app is now ready to handle clicked links that match your configuration.

Data from incoming intents

When a deeplink is clicked, the Android OS will launch the app and pass the URL data to the specified activity or fragment. To handle the deeplink event, the activity or fragment should override the onCreate method and extract the URL data from the intent that was passed to it.

override fun onCreate(savedInstanceState: Bundle?) {
  super.onCreate(savedInstanceState)

  val intentData = intent?.data
  if (intentData != null) {
    /* 
      Handle the deeplink URL data here 
      If the Uri is not null , at this point you can retrieve the final click-through url using the SDK
      as shown below 
    */
    val action: String? = intent?.action
    val data: Uri? = intent?.data
  }
}

To retrieve the click-through (resolved) url that you can use for deep-linking in your app, you can do that in one of two ways:

Synchronously

MIClient.resolveUrl("https://domain.com/p/cpm/f9e1dde60c33993")
// returns a nullable url String 

Note

resolveUrl is a suspend function

Asynchronously

MIClient.resolveUrlAsync(uri) { resolvedUrl ->
   //do something with the resolved URL
 }
MIClient.resolveUrlAsync(uri, resolvedUrl -> {
   // do something with the resolved URL
   return null;
});

Common use-cases for resolving a MovableInk Link are:

  • Clicking on a link
  • Opening the app from a push notification
  • In-App messages
  • Scanning a QR Code