Essential Smart Invites Setup on Android

In this guide we will go through all steps needed for basic configuration of GetSocial Smart Invites. Let’s get to the work!

Prerequisite

Configure Smart Invites

Gradle Plugin configures everything automatically. If you’re not using plugin read how to configure Smart Invites manually.

Setup Invite Channels

GetSocial Smart Invites has two types of Invite Channels:

  • The one that work out of the box, e.g. SMS, Email, WhatsApp, Messenger, Kik, Line, Twitter.
  • Ones that require integration of 3rd-party SDKs: Facebook and KakaoTalk.

In this step we will integrate GetSocial with the 3rd-party SDKs.

Setup Integration with Facebook SDK

GetSocial is compatible with Facebook Android SDK v4.x, older versions are not supported. Integration do not require Facebook application installed to be able to send invitations.

Facebook is deprecating App Invites

Facebook is deprecating App Invites from February 5, 2018.

New GetSocial integration with Facebook will allow posting Smart Invite to the timeline, friend’s timeline or a group. To upgrade, replace FacebookInvitePlugin with FacebookSharePlugin .

More: https://blog.getsocial.im/facebook-deprecates-app-invites-are-you-ready/

  1. Integrate Facebook Android SDK into your app as described in the Official Guide.
  2. Copy implementation of the Facebook Share plugin from GetSocial GitHub repository into your project.
  3. Register plugin with GetSocial:
    1
    2
    3
    4
    5
    CallbackManager facebookCallbackManager = CallbackManager.Factory.create();
    
    GetSocial.registerInviteChannelPlugin(
                InviteChannelIds.FACEBOOK,
                new FacebookSharePlugin((Activity)this, facebookCallbackManager));
    

Setup Integration with KakaoTalk SDK

To be able to send Smart Invites via KakaoTalk, GetSocial require: 1) Mobile KakaoTalk application installed and 2) Integration with KakaoTalk SDK.

Following steps will guide you through integration with KakaoTalk SDK:

  1. Integrate KakaoTalk Android SDK into your app as described in the Official Guide. Alternatively (if you’re not good with Korean language), follow the steps below.
    1.1. In your project, open build.gradle.
    1.2. Add KakaoTalk to the list of repositories:

    1
    2
    3
    repositories {
        maven { url 'http://devrepo.kakao.com:8088/nexus/content/groups/public/' }`
    }
    

    1.3. Add dependency to kakaolink library:

    1
    2
    3
    dependencies {
        compile 'com.kakao.sdk:kakaolink:1.0.52'
    }
    

    1.4. Create the new app on Kakao Developers Dashboard.
    1.5. Provide keystore sha1 fingerprint on the Dashboard. To get hash, use the command:

    1
    keytool -exportcert -alias [release_key_alias] -keystore [release_keystore_path] | openssl sha1 -binary | openssl base64
    

    1.5. Add GetSocial Invite Link domain to the list of Site Domains on Kakao Developers Dashboard:

    Kakao Developers Site Domain Configuration

    1.6. In your project, open AndroidManifest.xml.
    1.7. Add a meta-data referencing Kakao App Key to the application element:

    1
    2
    3
    4
    5
    <application android:label="@string/app_name" ...>
        ...
        <meta-data android:name="com.kakao.sdk.AppKey" android:value="[put your app key here]"/>
        ...
    </application>
    
  2. When KakaoTalk SDK will be added to the project, let’s integrate it with GetSocial.

  3. Copy implementation of the Kakao Invite plugin from GetSocial GitHub repository into your project.
  4. Register plugin with GetSocial:

    1
    2
    3
    4
    GetSocial.registerInviteChannelPlugin(
                    InviteChannelIds.KAKAO,
                    new KakaoInvitePlugin((Activity)this)
    );
    
  5. To validate integration, open the GetSocial Smart Invites view:

    1
    GetSocialUi.createInvitesView().show();
    

    The list should contain Kakao:

    GetSocial Smart Ivites View

Send Your First Smart Invite

To send your first Smart Invite invoke the method below. All supported Invite Channels are listed in InviteChannelIds class.

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

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

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

Facebook App Invite Dialog will be presented as a result:

GetSocial Smart Ivites View

Open GetSocial Smart Invites View

GetSocial UI library provide a view that lists all Smart Invite channels available on the device and enabled on the GetSocial Dashboard.

To open the view and register Invite callback:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
boolean wasShown = GetSocialUi.createInvitesView()
        .setInviteCallback(new InviteUiCallback() {
            @Override
            public void onComplete(String channelId) {
                Log.i("GetSocial", "Invitation was sent");
            }

            @Override
            public void onCancel(String channelId) {
                Log.i("GetSocial", "Invite cancelled");
            }

            @Override
            public void onError(String channelId, Throwable throwable) {
                Log.e("GetSocial", "Invite failed: " + throwable.getMessage());
            }
        })
        .show();

Log.i("GetSocial", "GetSocial Smart Invites UI was shown: " + wasShown);

You will see the following view on your screen:

GetSocial Smart Ivites View

Next Steps

Give us your feedback! Was this article helpful?

😀 🙁