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 a GetSocial Account

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

GetSocial Dashboard

Adding GetSocial to Your App

Configure SDK Dependencies

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

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

    1
    2
    3
    repositories {
        maven { url 'http://maven.getsocial.im/' }
    }
    
  3. Add SDK dependency to your build.gradle, please note that transitive property has to be set to true to resolve GetSocial library dependencies automatically:

    1
    2
    3
    4
    dependencies {
        compile('im.getsocial:getsocial-core:[6,7)@aar') { transitive = true }
        compile('im.getsocial:getsocial-ui:[6,7)@aar') { transitive = true } // Note: add this dependency only if you plan to use GetSocial UI
    }
    
  4. Build your project.

  5. Import GetSocial SDK into your app:
    1
    import im.getsocial.sdk.GetSocial;
    

Configure Manifest

In this step we’ll 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:

    1
    2
    3
    4
    5
    <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:

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

    1
    2
    3
    4
    5
    6
    7
    8
    9
    <application android:label="@string/app_name" ...>
        ...
        <provider
            android:authorities="${applicationId}.AutoInitSdkContentProvider"
            android:exported="false"
            android:enabled="true"
            android:name="im.getsocial.sdk.AutoInitSdkContentProvider"/>
        ...
    </application>
    

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
37
-keepattributes Signature,InnerClasses,Annotation
-keepattributes SourceFile,LineNumberTable
-keepattributes *Annotation*
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-dontwarn com.squareup.picasso.*

-dontwarn android.support.**

-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }

-keep public class * extends android.support.v4.view.ActionProvider {
    public <init>(android.content.Context);
}

-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient {
    com.google.android.gms.ads.identifier.AdvertisingIdClient$Info getAdvertisingIdInfo(android.content.Context);
}
-keep class com.google.android.gms.ads.identifier.AdvertisingIdClient$Info {
    java.lang.String getId();
    java.lang.Boolean isLimitAdTrackingEnabled();
}
-dontwarn im.getsocial.**
-keep class im.getsocial.** {*;}
-keepnames class im.getsocial.** {*;}

-dontwarn sun.misc.Unsafe
-keep class sun.misc.Unsafe { *; }
-keep class com.google.gson.stream.** { *; }

-dontwarn com.facebook.**
-keep class com.facebook.** {*;}

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

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: