Getting Started with GetSocial Android SDK

Welcome to the Getting Started section of the GetSocial documentation. Here you will find guides that describe how to accomplish a specific task with code samples you can re-use in your app.

System Requirements

To use GetSocial SDK your execution and development environment should match the following requirements:

  • Android v4.0.3 (SDK v15) or higher
  • Android Developers Tools (ADT) version 19 or above
  • Google Play Services library v6.1.11 or above (for push notifications)

Not sure if GetSocial is going to work in your specific configuration? Feel free to reach us via Intercom or email.

Adding GetSocial to Your App

Create App on the Dashboard

To start using GetSocial, you have to create a free account and login to GetSocial Dashboard. Dashboard provides a web interface to manage all GetSocial services.

  1. Login to GetSocial Dashboard.
  2. Open Add new app wizard.
  3. Fill in App name and upload App icon image.
  4. Select Android platform and Finish the wizard.

Configure GetSocial Gradle Plugin

To start using GetSocial, you have to add and configure GetSocial Gradle Plugin to your Android project. Plugin adds all GetSocial dependencies to the project and configures AndroidManifest.xml.

Alternatively, you can add dependencies and modify AndroidManifest.xml manually. Please follow the manual integration guide for details.

To add GetSocial Gradle plugin:

  1. Add repository and classpath dependency for the plugin in your top-level build.gradle:

     1
     2
     3
     4
     5
     6
     7
     8
     9
    10
    11
    12
    buildscript {
        repositories {
            ...
            maven {
                url "https://plugins.gradle.org/m2/"
            }
        }
        dependencies {
            ...
            classpath "gradle.plugin.im.getsocial:plugin:[0,1)"
        }
    }
    
  2. In the Android application project build.gradle apply im.getsocial plugin after com.android.application plugin:

    1
    2
    apply plugin: 'com.android.application'
    apply plugin: 'im.getsocial' // should be applied after com.android.application plugin
    
  3. In the same build.gradle configure GetSocial plugin with GetSocial App id:

    1
    2
    3
    4
    getsocial {
        appId "put-your-getsocial-app-id-here"
        ...
    }
    

    You can find GetSocial App id in the App settings section on the GetSocial Dashboard:

    GetSocial App Id

Check the GetSocial Gradle plugin reference for the full list of available configurations.

Configure Dependencies (optional)

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:

    1
    2
    3
    4
    dependencies {
        ...
        implementation 'com.android.installreferrer:installreferrer:1.0'
    }
    

    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.

Enable Google Play on the Dashboard

Next step is to enable Google Play store on the GetSocial Dashboard:

  1. On the App settings section → App information tab → enable Google Play store.
  2. Fill in Package name and Signing-certificate fingerprint fields:

    Create new app on GetSocial Dashboard

    Package name is the applicationId in your app-level build.gradle file.

    Signing-certificate fingerprint is a list of SHA-256 hashes of the certificates you use to sign your application. You have to add fingerprints of all keys you use to sign app. GetSocial Gradle plugin adds a helper task printSigningCertificateSHA256 to print SHA-256 fingerprints for all configured build flavors:

    1
    gradle printSigningCertificateSHA256
    

    Keystore SHA 256 hash

    Using Google Play App Signing?

    If you are using Google Play App Signing you can copy SHA256 from the Play Console. If you’re using a separate Upload certificate, please add his SHA256 to GetSocial Dashboard as well. Learn more in the detailed guide.

Configure ProGuard

If you have custom ProGuard configuration for your project include the lines below:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# Required
-keepattributes Signature,InnerClasses,Annotation
-keepattributes SourceFile,LineNumberTable
-keepattributes *Annotation*
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-dontwarn sun.misc.Unsafe
-keep class sun.misc.Unsafe { *; }

-dontwarn im.getsocial.**
-keep class im.getsocial.** {*;}
-keepnames class im.getsocial.** {*;}

# Used for GetSocial analytics
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
    public com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
    public java.lang.String getId();
}

# Push Notifications (do not include, it you do not use this feature)
# If you use GCM:
-keep class com.google.android.gms.iid.InstanceID {
    static com.google.android.gms.iid.InstanceID getInstance(android.content.Context);
    java.lang.String getToken(java.lang.String, java.lang.String);
}
# If you use Firebase:
-keep class com.google.firebase.iid.FirebaseInstanceId {
    static com.google.firebase.iid.FirebaseInstanceId getInstance();
    java.lang.String getToken();
}

GetSocial SDK Size

Due to limited resources on mobile devices and 65k methods limitation in one DEX library size and added methods count play an important role in app development.

Below you can find size and method count values for GetSocial Android SDK v6.6.2. You can expect similar values for all future versions of the library.

Android Library Raw Aar Size Methods Count
getsocial-core.aar 0.67 MB 4331
getsocial-ui.aar 0.36 MB 2414

Enable ProGuard

We suggest using ProGuard to reduce methods count.

Start Using GetSocial

At this point, you should be able to start using GetSocial. Let’s try to send our first Smart Invite with and without GetSocial UI.

GetSocial UI

GetSocial UI library contains easy to customize views for all GetSocial features, e.g. code below will create and show GetSocial Smart Invites view:

1
2
boolean wasShown = GetSocialUi.createInvitesView().show();
Log.i("GetSocial", "GetSocial Smart Invites UI was shown: " + wasShown);

After invoking code above, GetSocial Smart Invites view will be shown:

GetSocial Smart Invites View

Why there are only a few apps?

The list of Smart Invites Channels in the view above will contain all social apps that are 1) enabled on the GetSocial Dashboard and 2) installed on the device.

GetSocial without UI

If you plan to build your own UI, you can remove GetSocial UI library from dependencies and use only GetSocial data layer. To run the test, add the code below to any button callback:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
GetSocial.sendInvite(InviteChannelIds.EMAIL, new InviteCallback() {
    @Override
    public void onComplete() {
        Log.i("GetSocial", "Invitation via EMAIL was sent");
    }

    @Override
    public void onCancel() {
        Log.i("GetSocial", "Invitation via EMAIL was cancelled");
    }

    @Override
    public void onError(Throwable throwable) {
        Log.e("GetSocial", "Invitation via EMAIL failed, error: " + throwable.getMessage());
    }
});

After calling this method email client will be opened:

GetSocial Smart Ivite over Email

SDK Initialization

GetSocial SDK is auto-initialized, just provide a GetSocial App Id in the Gradle plugin and we will do the magic.

Manual Initialization

If you want to initialize GetSocial SDK manually, check this topic.

Most of GetSocial APIs require the SDK to be initialized. You can check the if SDK is initialized synchronously or asynchronously.

1
2
3
if (GetSocial.isInitialized()) {
    // use GetSocial
}

If you want to be notified about initialization complete, you can set a callback, that will be invoked when SDK gets initialized or invoked immediately if it is already initialized:

1
2
3
4
5
6
GetSocial.whenInitialized(new Runnable() {
    @Override
    public void run() {
        // GetSocial is ready to be used
    }
});

For instance, you can use whenInitialized to ensure GetSocial SDK is initialized to get referral data on the application start:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
public class MainActivity extends Activity {
    ...
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        ...
        GetSocial.whenInitialized(new Runnable() {
            @Override
            public void run() {
                GetSocial.getReferralData(...);
            }
        });
        ...
    }
    ...
}

Demo Application

To showcase all GetSocial SDK features, we have created a simple demo application. Explore it on the GitHub or install from Google Play.

Next Steps

Well-done! GetSocial SDK is now set up and ready to rock, check what you can do next:

Give us your feedback! Was this article helpful?

😀 🙁