Skip to content

Misc

Referrer Receiver

Add the Broadcast Receiver in AndroidManifest.xml

AndroidManifest.xml
<receiver
    android:name=".ReferrerReceiver"
    android:exported="true">
    <intent-filter>
        <action android:name="com.android.vending.INSTALL_REFERRER" />
    </intent-filter>
</receiver>

And in the Receiver's onReceive() method, you can get the referrer value

ReferrerReceiver.kt
class ReferrerReceiver : BroadcastReceiver() {
    override fun onReceive(context: Context, intent: Intent) {
        val referrer: String? = referrer = intent.extras.getString("referrer")
    }
}

Deeplinking

You can get the deeplink Uri in your Activity's onCreate() method as well as the corresponding properties:

MainActivity.kt
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    val deeplink = intent.data
    if (deeplink != null) {
        val host = deeplink.host
        val path = deeplink.path
        val query = deeplink.query
        val fragment = deeplink.fragment
    }
}

When using Play Store url or Market scheme or Firebase Dynamic Links methods, the regular Play Store Open button will be replaced by a Continue button.
Furthermore, a notification will be displayed with Tap to continue content.
These two actions are essential to the Deferred deeplink method as they provide the initial data to the app.

Regular Deeplink Deferred Deeplink

Url redirections

  • HTML regular href link
    <a href="${link}">Click here</a>
    
  • Javascript manual redirect
    window.location = "${link}";
    
  • Javascript automatic redirect
    window.onload = function() {
      window.location.replace("${link}");
    };
    
  • Server 3XX redirection (php, nginx, etc.)
    header("Location: ${link}");
    

Adb Activity Manager

To try links with adb, use the Activity Manager (am) command:

$ adb shell 'am start "link://smarquis.fr/action?key=value#data"'

Alternatives