Skip to content

Dynamic Link

Dynamic Link can help for Marketing Campaign and other use cases. With one link, Service module can handle how to treat the link based on condition, like what operating system does the link clicked, does the app installed, if not redirect to open Play Store or AppGallery, etc. DevBase included with global function to handle Dynamic Link.

  • First, register Activity to handle link in AndroidManifest.xml like this:

    AndroidManifest.xml
    <activity
      android:name=".presentation.home.HomeActivity"
          android:screenOrientation="portrait">
          <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:host="garnishcode.dev/deeplink"
                  android:scheme="https" />
          </intent-filter>
    </activity>
    

  • In registered Activity (in this case HomeActivity), call this method:

    HomeActivity.kt
    handleDynamicLink(intent) { type, uri ->
          when(type) {
              GMS_DYNAMIC_LINK -> {
                  // Action when dynamic link from Firebase
              }
              HMS_DYNAMIC_LINK -> {
                  // Action when dynamic link from AppGallery Connect
              } 
          }
    }
    

Demo