Skip to content

Growth

Introduction

StreetHawk Growth lets your user share your application with friends. Also, the feature can be extended to invite the new user to a deep link page inside your application. Create a Share button inside your application and call GetShareUrlForAppDownload to generate the share URL. StreetHawk SDK will then ask user ways to share the generated URL. That is (email, post on Facebook etc). Below are the APIs which generates sharable URL. A scheme for deep linking is required for StreetHawk growth.

Pre-requisites

The documents assume that you have downloaded and added the boiler-plate code described in the introduction document. You will require IStreetHawkGrowth.cs, StreetHawkGrowth.cs (iOS) and StreetHawkGrowth.cs (Android) in particular for StreetHawkGrowth component.

StreetHawk Growth component depends on StreetHawk Analytics components. This document assumes that you have already integrated StreetHawk Analytics. If not then click here for detailed documentation which describes steps to integrate Analytics component.

Integration Steps

  • Add StreetHawk Growth component

Add StreetHawk Growth component in both iOS and Droid project as shown below:

  1. In iOS project, right click on component folder
  2. Click on "Get More Components" and search for StreetHawk Growth. Click Add to App.
  3. Once downloaded, click on Add to Project.
  4. Repeat the above steps for adding the component in .Droid project of your application

  • Add platform specific code
    • iOS

Add Open Url scheme in Info.plist. The scheme is for open url to launch App.

  • Input App ID

Input your App ID into web console locating: App Details->App Summary->Apple App ID, which is formatted as <Team ID>.<Bundle ID>.

The team id and bundle id can read in https://developer.apple.com, section "iOS App IDs":

  • Add associate domain in project

Double click Entitlements.plist and open edit page. Add associate domain applinks:hwk.io.

Normally XCode can automatically re-generate provisioning profile for this change. In case XCode fail to do it, please go to https://developer.apple.com to enable "Associate Domains" in App ID, and re-generate provisioning profiles.

  • Android

Copy and pate the below code in AndroidManifest.xml located under properties folder of your Droid project

<manifest>
    <application>
         <receiver
            android:name="com.streethawk.library.growth.Register"
            android:enabled="true" >
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER" />
            </intent-filter>
        </receiver>

    </application>
</manifest>

Register deep link parameters such as scheme and host to the activity which needs to be launched with deep link URL.

... 
// Add for deeplinking
    [Activity (Label = "XamGrowth", MainLauncher = true, Icon = "@mipmap/icon")]
    [IntentFilter (new[]{Intent.ActionView},
        Categories=new[]{Intent.CategoryLauncher,Intent.CategoryBrowsable,Intent.CategoryDefault},
        Icon="@mipmap/icon",
        DataScheme="<DEEPLINK_SCHEME>", // define scheme here
        DataHost="<DEEPLINK_HOST>")]      // define host here

public class MainActivity : global::Xamarin.Forms.Platform.Android.FormsAppCompatActivity
{
... 
            new StreetHawkAnalytics(Application);
            new StreetHawkGrowth(this);
  • Get Shareable URL
    Add the following code to get sharable URL from StreetHawk servers.

    StreetHawk Growth feature lets your user share your application with friends. Also the feature can be extended to invite the new user to a deeplinking page inside your application. Create a Share button inside your application and call GetShareUrlForAppDownload to generate the share url. App can get the generated url and share by any way ie (email, post on Facebook etc). A scheme for deep linking is required for StreetHawk growth.

    • Generate share link and handle in application
      In this case, SDK fetches the share link and pass it to application to present it to the user for sharing it. Below is the sample code.

      using StreetHawkCrossplatform;
      
      string ID = "ShareViaFacebook";
      string shareLink = "recipeApp://homepage?recipe=chocolatechipcookie";
      string utm_source = "Facebook";
      string utm_medium = "cpc";
      string utm_term = "facebookAdd";
      string campaign_content = "best chocolate chip cookie recipe";
      string default_url = "http://recipeApp.com/chocolatechipcookie";
      DependencyService.Get<IStreetHawkGrowth>().GetShareUrlForAppDownload(ID, shareLink, utm_source, utm_medium, utm_term, campaign_content, default_url, delegate (string shareUrl, string error)
                     {
                         Device.BeginInvokeOnMainThread(() =>
                             {
                                 if (error == null)
                                 {
                                     DisplayAlert("Get growth share url:", shareUrl, "OK");
                                 }
                                 else
                                 {
                                     DisplayAlert("Share fail with error:", error, "OK");
                                 }
                             });
                     });
      

    • Generate link with source selection
      In this case the SDK presents user with list of applications (Email, SMS, Facebook, Twitter, Sina Weibo, Tencent Weibo) on which the URL can be shared and picks utm_source parameter as per the user's selection. Below is the code snippet.

      using StreetHawkCrossplatform;
      
      string ID = "ShareViaFacebook";
      string shareLink = "recipeApp://homepage?recipe=chocolatechipcookie";
      string default_url = "http://recipeApp.com/chocolatechipcookie";
      DependencyService.Get<IStreetHawkGrowth>().GetShareUrlForAppDownload(ID, shareLink, default_url);
      

    Parameter Data type Description
    utm_campaign string Optional, for identify how this share is used for. For example in a book App, it would be "Child", "Computer", "Poetry".
    utm_source string Optional, indicate where share URL will be posted (Example facebook, twitter, whatsapp etc). It's free text string.
    utm_medium string Optional, medium as URL will be posted. For example CPC.
    utm_content string Optional, content of the campaign.
    utm_term string Optional, keywords for campaign
    shareUrl string Optional, deeplinking url which will open App by browser link. For example, to open App page with parameter, url like "SCHEME://HOST?param1=VALUE1&param2=VALUE2".
    default_url string Optional, fallback url if user opens url not on iOS or Android mobile devices. It's a normal url to display on browser, for example the developer's website which describes the App, like http://www.myapp.com.
    handler delegate RegisterForShareURLCallback Share result callback handler, when successfully share `result` is share_guid_url, otherwise it contains error.
  • Handle shared deeplinking Url

App would like to handle the deeplinking URL by itself, not leverage StreetHawk SDK to automatically launch the page. In this case, implement following code snippet. It can handle any format of url by yourselves, like scheme://host/path?param1=value1&param2=value2.

using StreetHawkCrossplatform;

protected override void OnStart()
{
    ......

    DependencyService.Get<IStreetHawkAnalytics>().RegisterForDeeplinkURL( delegate (string openUrl)
    {
        Device.BeginInvokeOnMainThread(() =>
            {
                MainPage.DisplayAlert("Open url: ", openUrl, "OK");
            });
    });