Skip to content

Growth

Introduction

StreetHawk Growth component lets your user share your application with friends. Also the feature can be extended to invite the new user to a deep linked page inside your application. Create a Share button inside your application and call originateShareWithSourceSelection 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

StreetHawkGrowth component depends on StreetHawk's Analytics components. This document assumes that you have already integrated StreetHawkAnalytics component. if not then click here for detailed documentation on StreetHawkAnalytics components which describes steps to integrate Analytics component.

Integration Steps


  • Include StreetHawk Growth Component

1.In Xamarin Studio, double click on Components folder
2.Click on "Get More Components", and search for StreetHawk Growth. Click Add to App
3.Once downloaded, click on Add to Project

  • Check StreetHawk.IOS.Growth.dll reference

Right click project->References->Edit References..., make sure StreetHawk.IOS.Core.dll and StreetHawk.IOS.Growth.dll are added to project.

For Unified projects, please add corresponding StreetHawk.IOS.Core-Unified.dll and StreetHawk.IOS.Growth-Unified.dll.

  • Modify Info.plist

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.

  • Include Statements

Add the following include statements

using StreethawkIOS.Core;
using StreethawkIOS.Growth;
  • Generate share link

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 originateShareWithSourceSelection 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 user for sharing it. Below is the sample code.
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";
SHGrowthCallbackHandler handler = delegate(NSObject result, NSError error) {
    InvokeOnMainThread ( () => {
        if (error == null)
        {
            UIAlertView alert = new UIAlertView("Growth share url:", result.ToString(), null, "OK", null);
            alert.Show();   
        }
        else
        {
            UIAlertView alert = new UIAlertView("Growth share fail:", error.LocalizedDescription, null, "OK", null);
            alert.Show();                       
        }
    });
};
SHGrowth.instance().originateShareWithCampaign(ID, utm_source, utm_medium, campaign_content, utm_term, shareLink, default_url, handler);
  • 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 sample code.
string ID = "ShareViaFacebook";
string shareLink = "recipeApp://homepage?recipe=chocolatechipcookie";
string default_url = "http://recipeApp.com/chocolatechipcookie";
SHGrowth.instance().originateShareWithSourceSelectionID, shareLink, default_url);
Parameter Data type Description
utm_campaign NSString Optional, for identify how this share is used for. For example in a book App, it would be "Child", "Computer", "Poetry".
utm_source NSString Optional, indicate where share url will be posted (Example facebook, twitter, whatsapp etc). It's free text string.
utm_medium NSString Optional, medium as url will be posted. For example cpc.
utm_content NSString Optional, content of campaign.
utm_term NSString Optional, keywords for campaing.
shareUrl NSURL 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 NSURL 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 SHCallbackHandler 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.

public override bool FinishedLaunching (UIApplication application, NSDictionary launchOptions)
{
    ...
    //streethawk handle open url sample.
    SHApp.instance ().shDeeplinking = delegate (NSUrl openUrl) 
    {
        //receive deeplinking url and do whatever you want
    };

    return YES;
}