Skip to content

GetSocial Android SDK Manual Integration Guide

Basic Setup

Configure SDK Dependencies

GetSocial SDK is distributed as an Android Library in aar format. You can get it from our Maven Repository or Downloads page in the documentation.

  1. In your project, open build.gradle.
  2. Add GetSocial Maven Repository to the list of project dependencies repositories:

    repositories {
        maven { url 'https://maven.getsocial.im/' }
    }
    
  3. Add SDK dependency to your build.gradle:

    dependencies {
        implementation('im.getsocial:getsocial-core:[6,7)@aar')
        implementation('im.getsocial:getsocial-ui:[6,7)@aar') // Note: add this dependency only if you plan to use GetSocial UI
    
        implementation 'com.android.installreferrer:installreferrer:1.0' // Optional. GetSocial is using it to obtain more accurate data about installs and make attribution more reliable
    }
    

    Using Gradle version before 3.0?

    Starting from version 3.0.0 Gradle deprecated compile dependency scope and replaced with implementation. If you are using Gradle version before 3.0.0, replace implementation keyword with compile to avoid build errors.

  4. Build your project.

  5. Import GetSocial SDK into your app:

    import im.getsocial.sdk.GetSocial;
    

Configure Manifest

In this step, we will add your GetSocial App Id to your app and update your Android manifest with required permissions.

  1. Get your GetSocial App Id from the “App settings” section on the GetSocial Dashboard:

    GetSocial App Id

  2. Open AndroidManifest.xml.

  3. Add a meta-data referencing GetSocial App Id to the application element:

    <application android:label="@string/app_name" ...>
        ...
        <meta-data android:name="im.getsocial.sdk.AppId" android:value="[put your app id here]"/>
        ...
    </application>
    
  4. Add permissions required for GetSocial SDK:

    <uses-permission android:name="android.permission.INTERNET"/>
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
    
  5. Add Content Provider for GetSocial SDK to the application element:

    <application android:label="@string/app_name" ...>
        ...
        <provider
            android:authorities="${applicationId}.AutoInitSdkContentProvider"
            android:exported="false"
            android:enabled="true"
            android:name="im.getsocial.sdk.AutoInitSdkContentProvider"/>
        ...
    </application>
    

    This step is required for manual initialization as well.

Smart Invites

Add Image Content Provider

To be able to attach images to the Smart Invite messages you have declare an Image Content Provider:

  1. Open AndroidManifest.xml in your project.
  2. Add GetSocial Image Content Provider to the application element:

    <provider
        android:name="im.getsocial.sdk.invites.ImageContentProvider"
        android:authorities="${applicationId}.smartinvite.images.provider"
        android:grantUriPermissions="true"
        android:exported="true"/>
    

Configure Install Referrer Receiver

Install Referrer Receiver is needed to track install event and attribute installs to the referrers. To set it up:

  1. In your project, open AndroidManifest.xml.

  2. Set INSTALL_REFERRER broadcast receiver to track app install events in GetSocial Analytics.

    Android apps can not have multiple receivers with the same intent-filtered action.

    The following two options are available for adding the install referrer receiver:

    2.1. Using a multiple install referrer receiver. GetSocial provides a solution that re-broadcasts INSTALL_REFERRER to all receivers defined in AndroidManifest.xml automatically.

    In the AndroidManifest.xml, add the following receiver as the FIRST receiver for INSTALL_REFERRER, under the application tag:

    <application android:label="@string/app_name" ...>
        ...
        <receiver android:name="im.getsocial.sdk.invites.MultipleInstallReferrerReceiver"  android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER"/>
            </intent-filter>
        </receiver>
        ...
    </application>
    

    If you want to use multiple install referrer receivers declare them in AndroidManifest.xml in the following order:

    <!— GetSocial Install Referrer Receiver is first and will re-broadcast to all receivers placed below it -->
    <receiver android:name="im.getsocial.sdk.invites.MultipleInstallReferrerReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    
    <!— All other receivers should declared after it -->
    <receiver android:name="com.google.android.apps.analytics.AnalyticsReceiver" android:exported="true">
        <intent-filter>
            <action android:name="com.android.vending.INSTALL_REFERRER" />
        </intent-filter>
    </receiver>
    

    2.2. Using default install referrer receiver. In the AndroidManifest.xml, add the following receiver as the FIRST receiver for INSTALL_REFERRER or after another multiple INSTALL_REFERRER receivers:

    <application android:label="@string/app_name" ...>
        ...
        <receiver android:name="im.getsocial.sdk.invites.InstallReferrerReceiver"  android:exported="true">
            <intent-filter>
                <action android:name="com.android.vending.INSTALL_REFERRER"/>
            </intent-filter>
        </receiver>
        ...
    </application>
    

Configure Dependencies

To obtain more accurate data about installs and make attribution more reliable, GetSocial is using Google Play Install Referrer API. To add library to your project:

  1. Open the Android application project build.gradle.
  2. Add library to the dependencies list:

    dependencies {
        ...
        implementation 'com.android.installreferrer:installreferrer:1.1'
    }
    

    Using Gradle version before 3.0?

    Starting from version 3.0.0 Gradle deprecated compile dependency scope and replaced with implementation. If you are using Gradle version before 3.0.0, replace implementation keyword with compile to avoid build errors.

Url Scheme Configurations

Setup Url Schemes for Android 4+

  1. In your project, open AndroidManifest.xml.
  2. Add following intent filter to the activity that should be opened from the deep link. Do not forget to put your GetSocial App Id into the data tag:

    <intent-filter>
        <action android:name="android.intent.action.VIEW"/>
    
        <category android:name="android.intent.category.DEFAULT"/>
        <category android:name="android.intent.category.BROWSABLE"/>
    
        <data
                android:host="[put your getsocial app id here]"
                android:scheme="getsocial"/>
    </intent-filter>
    
  3. To validate the configuration, send a Smart Invite and click on the link, your app should be opened:

    Smart Invite via Twitter with Custom Subdomain

To improve user experience on clicking the GetSocial Smart Invites link we highly recommend setup Android App links in your app in addition to Url Schemes.

Android 6.0 (API level 23) and higher allow an app to designate itself as the default handler for a given type of link. App Links allow taking the user directly to the app on the link click without the browser window in the middle. Check the official Android App Links docs for more details.

To set up App Links support follow the next steps:

  1. To setup App Links in your app open AndroidManifest.xml in your project.
  2. Copy Smart Link domain from the GetSocial Dashboard.

    Copy Smart Links Domain Configuration

    There are two options:

    • If you are using prefix for the default gsc.im domain for Smart Links, you have to add intent filter with the following host configurations to the activity that must be opened from the Smart Link:
    <data android:scheme="https" android:host="[PREFIX].gsc.im" />
    <data android:scheme="https" android:host="[PREFIX]-gsalt.gsc.im" />
    
    • If you are using custom domain for Smart Links you have to specify both, custom domain and default gsc.im domain configurations:
    <data android:scheme="https" android:host="[YOUR_CUSTOM_DOMAIN]" />
    <data android:scheme="https" android:host="[PREFIX].gsc.im" />
    

    For instance for our Documentation Demo app we use prefix for gsc.im domain for Smart Links, intent filter that must be added will be the following:

    <intent-filter android:autoVerify="true">
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <data android:scheme="https" android:host="getdocs.gsc.im" />
        <data android:scheme="https" android:host="getdocs-gsalt.gsc.im" />
    </intent-filter>
    
  3. To validate configuration:

    1. Go to “App info” → “Open by default”, domain(s) specified in the intent filter should be listed in “Supported links” section:

      Supported links section

    2. Send a Smart Invite and click on the link, and the app selector screen with your app should be opened, or you have to be taken to the app directly.

Push Notifications

Enable/Disable GetSocial Notifications on the Client Side

Specify special meta-tag in AndroidManifest.xml:

<application ...>
    ...
    <meta-data
        android:name="im.getsocial.sdk.AutoRegisterForPush"
        android:value="false" />
</application>

Show Notifications In Foreground

Specify special meta-tag in AndroidManifest.xml:

<application ...>
    ...
    <meta-data
        android:name="im.getsocial.sdk.ShowNotificationInForeground"
        android:value="true" />
</application>

UI Configuration

Configuration Loading

Set a path to configuration file or directory in your AndroidManifest.xml:

<application ...>
    ...
    <meta-data
        android:name="im.getsocial.sdk.UiConfigurationFile"
        android:value="getsocial/ui-landscape.json" />
</application>

Give us your feedback! Was this article helpful?

😀 🙁