Upgrade to Pro — share decks privately, control downloads, hide ads and more …

APP INVITES FOR ANDROID - Droidcon tunisia

APP INVITES FOR ANDROID - Droidcon tunisia

Thinking about free marketing ? Want to give the opportunity to your user to share your app with their friends ? Maybe you just need more downloads ? Not sure where to start? Android App Invite is one of the answer you were looking for.
You will learn more about app invite is all about and why you need to care about. This talk will teach you exactly what you need to know to integrate app invite in your application.
At the end of this class, you will learn how to:
- integrate app invite in your app
- test your app invite for sending and reception of invites
- Manage invites tracking using Google Analytics API

WillyShakes

March 06, 2016
Tweet

More Decks by WillyShakes

Other Decks in Programming

Transcript

  1. 1. Why Should I care ? 2. How do I

    use it 3. Let's measure it
  2. Code 1. Connect Google Client API with APP Invite Service

    Enabled 2. Start App Invite Intent 3. handle the result in the callback 4. Check if someone installed the app from an invitation
  3. private void onInviteClicked() { Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title)) .setMessage(getString(R.string.invitation_message))

    .setDeepLink(Uri.parse(getString(R.string.invitation_deep_link))) .setCustomImage(Uri.parse(getString(R.string.invitation_custom_image))) .setCallToActionText(getString(R.string.invitation_cta)) .build(); startActivityForResult(intent, REQUEST_INVITE); } Send invitation
  4. private void onInviteClicked() { Intent intent = new AppInviteInvitation.IntentBuilder(getString(R.string.invitation_title)) .setMessage(getString(R.string.invitation_message))

    .setDeepLink(Uri.parse(getString(R.string.invitation_deep_link))) .setEmailHtmlContent("<html><body>" + "<h1>App Invites</h1>" + "<a href=\"%%APPINVITE_LINK_PLACEHOLDER%%\">Install Now!</a>" + "<body></html>") .setEmailSubject(getString(R.string.invitation_subject)) .build(); startActivityForResult(intent, REQUEST_INVITE); } Custom Email content with html
  5. protected void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode,

    resultCode, data); if (requestCode == REQUEST_INVITE) { if (resultCode == RESULT_OK) { String[] ids = AppInviteInvitation.getInvitationIds(resultCode, data); Log.d(TAG, getString(R.string.sent_invitations_fmt, ids.length)); } else { showMessage(getString(R.string.send_failed)); } } } Send Invitation Result
  6. protected void onCreate(Bundle savedInstanceState) { boolean autoLaunchDeepLink = true; AppInvite.AppInviteApi.getInvitation(mGoogleApiClient,

    this, autoLaunchDeepLink) .setResultCallback( new ResultCallback<AppInviteInvitationResult>() { @Override public void onResult(AppInviteInvitationResult result) { Log.d(TAG, "getInvitation:onResult:" + result.getStatus()); } }); } Receive an invitation
  7. Tracking ID Create Account Add a Mobile Project to track

    -> Tracking ID Configure Analytics to process App Invites data Create App Invite DashBoard
  8. Application level private Tracker mTracker; synchronized public Tracker getDefaultTracker() {

    if (mTracker == null) { GoogleAnalytics analytics = GoogleAnalytics.getInstance(this); mTracker = analytics.newTracker(R.xml.global_tracker); } return mTracker; }
  9. Invite sent // Get tracker. AnalyticsApplication application = (AnalyticsApplication) getApplication();

    mTracker = application.getDefaultTracker(); // Build and send an Event. t.send(new HitBuilders.EventBuilder() .setCategory(getString(R.string.invitation)) .setAction(getString(R.string.sent)) .build());
  10. Invite received AnalyticsApplication application = (AnalyticsApplication) getApplication(); mTracker = application.getDefaultTracker();

    // Build and send an Event. t.send(new HitBuilders.EventBuilder() .setCategory(getString(R.string.invitation)) .setAction(getString(R.string.accepted)) .build());