Getting Started with GetSocial Android SDK

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

System Requirements

In order to use GetSocial SDK your execution and development environment should match 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 support@getsocial.im.

Creating an App on GetSocial 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 on “Step 1”, copy GetSocial App Id if needed on “Step 2”.
  4. Enable Android platform on the “Step 3”.

    Create new app on GetSocial Dashboard

  5. Fill in package name and SHA-256 signing-certificate fingerprint fields:

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

    Signing-certificate fingerprint is a SHA-256 hash of the keystore you use to sign your application. Use keytool utility provided with Android SDK to get hash:

    1
    keytool -list -v -keystore release.keystore
    

    Keystore SHA 256 hash

    If you using GetSocial Gradle plugin, run printSigningCertificateSHA256 Gradle task.

Enable Platforms from the App Settings

After closing wizard you can always enable more platforms or edit settings in the “App settings” section of the Dashboard.

Adding GetSocial to Your App

To start using GetSocial you have to add and configure GetSocial Gradle Plugin to your Android project:

  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. Get your GetSocial App Id from the App settings section on the GetSocial Dashboard:

    GetSocial App Id

  3. In the Android application project build.gradle apply im.getsocial plugin after com.android.application plugin and update your GetSocial App Id:

    1
    2
    3
    4
    5
    6
    7
    apply plugin: 'com.android.application'
    apply plugin: 'im.getsocial'
    
    getsocial {
        appId "put-your-getsocial-app-id-here"
        ...
    }
    

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

Do not want to use Gradle Plugin?

Check the guide how to integrate GetSocial SDK manually.

Configure ProGuard

If you have custom proguard configuration for you 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
36
# 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 { *; }
-keep class com.google.gson.stream.** { *; }

-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 unfortunately famous 65k methods limitation in one DEX library size and added methods count play important role during 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 to use Proguard to reduce methods count.

Start Using GetSocial

If the previous steps were executed properly at this point you have to be able to start using GetSocial. Let’s try to send a GetSocial Smart Invite via Email.

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 Android Manifest and we will do the magic.

Manual Initialization

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

Most part of GetSocial APIs require initialised SDK. You can check SDK initialization state in sync or async way.

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

If you want to be notified about initialization complete, you can set an action, 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
    }
});

It can be useful when you want to use GetSocial on application start, but you can not be sure is it ready for using, for example you want to retrieve referral data on 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(...);
            }
        });
        ...
    } 
    ...
}

GetSocial UI

GetSocial UI library contains easy to customize views for all GetSocial features.

To start using GetSocial UI, create and show any of provided views, 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

Note

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

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?

😀 🙁