I was reading up on Google Invites: https://developers.google.com/app-invites/android/guides/app and also branch.io: https://dev.branch.io/recipes/content_sharing/android/#routing-to-content-within-your-android-app
Google Invites seems to excel at Content Sharing, providing an interface to select from Google all the people you want to send the deep link to your app.
Branch.io seems to excel at generating deeplinks and their shorturl would contain all the data needed by an app in their "Embed key/value deep link metadata".
Branch.io also has a built in "native share sheet" but I don't think its as advance / nice as Google Invites.
I would like to use the Branch.io deeplinks with Google Invites interface for content sharing.
What I'm struggling with is to merge the two.
When someone clicks on the Google Invites link, the android app opens and inside the onCreate method, the following code runs to intercept the intent:
@Override
protected void onCreate(Bundle savedInstanceState) {
// ...
if (savedInstanceState == null) {
// No savedInstanceState, so it is the first launch of this activity
Intent intent = getIntent();
if (AppInviteReferral.hasReferral(intent)) {
// In this case the referral data is in the intent launching the MainActivity,
// which means this user already had the app installed. We do not have to
// register the Broadcast Receiver to listen for Play Store Install information
launchDeepLinkActivity(intent);
}
}
}
Branch.io tells android to intercept the intent in the onStart method:
@Override
public void onStart() {
super.onStart();
Branch branch = Branch.getInstance();
// If NOT using automatic session management
// Branch branch = Branch.getInstance(getApplicationContext());
branch.initSession(new BranchReferralInitListener(){
@Override
public void onInitFinished(JSONObject referringParams, Branch.BranchError error) {
if (error == null) {
// params are the deep linked params associated with the link that the user clicked before showing up
// params will be empty if no data found
String pictureID = referringParams.optString("picture_id", "");
if (pictureID.equals("")) {
startActivity(new Intent(this, HomeActivity.class));
}
else {
Intent i = new Intent(this, ViewerActivity.class);
i.putExtra("picture_id", pictureID);
startActivity(i);
}
} else {
Log.e("MyApp", error.getMessage());
}
}
}, this.getIntent().getData(), this);
}
If I use both Branch.io and Google Invites, which code should I use to intercept the intent that would start the android app when I click on the deeplink?