Deep linking in Android — Part 2

Branch Metrics
Screenshot
Screenshot
Screenshot
Screenshot
Screenshot
implementation ‘io.branch.sdk.android:library:2.+’
public final class MyApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
// Initialize the Branch object
Branch.getAutoInstance(this);
}
}
android:name=”MyApplication”
android:launchMode=”singleTask”
<activity
... >
<intent-filter>
<data android:scheme=”” android:host=”open” />
<action android:name=”android.intent.action.VIEW” />
<category android:name=”android.intent.category.DEFAULT” />
<category android:name=”android.intent.category.BROWSABLE” />
</intent-filter>
</activity>
<application ... >< ...>
</...>
<! — Branch init →
<meta-data android:name=”io.branch.sdk.BranchKey” android:value=”key_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx” />
<! — Branch testing (TestMode “true” to simulate fresh installs on dev environment) →
<meta-data android:name=”io.branch.sdk.TestMode” android:value=”false” />
</application>
@Override
public void onStart() {
super.onStart();
Branch branch = Branch.getInstance();
// Branch init
branch.initSession(new Branch.BranchReferralInitListener() {
@Override
public void onInitFinished(JSONObject referringParams, BranchError error) {
if (error == null) {
// params are the deep linked params associated with the link that the user clicked -> was re-directed to this app
// params will be empty if no data found
// … insert custom logic here …
Log.i(“BRANCH SDK”, referringParams.toString());
} else {
Log.i(“BRANCH SDK”, error.getMessage());
}
}
}, this.getIntent().getData(), this);
}
@Override
public void onNewIntent(Intent intent) {
this.setIntent(intent);
}
GET /v1/url?url=<url>&branch_key=<branch key>

Parameters:

https://api.branch.io/v1/url?url=https://qn1e.app.link/sKuyzIMlfP&branch_key=key_live_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
{
"channel": "Email",
"campaign": "test",
...
"data": {
"test_data": "123456",
...
},
"alias": "Dummy link",
"type": 0
}

Google Certified Associate Android Developer

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store