Skip to content

GetSocial Android SDK Upgrade Guide

For a minor version update, please check version-specific upgrade instructions in the Changelog.

If you are integrating from scratch, please follow Getting Started with GetSocial Android SDK guide.

Upgrade from SDK 6 to SDK 7

  1. In your project open build.gradle.
  2. Find a line similar to classpath "im.getsocial:plugin:+" and change to classpath "im.getsocial:plugin-v7:[1,2)".
  3. If you have an explicitly specified version in gradle plugin, update it to 7.0.0 or just remove it use the latest one.
  4. Add Java 8 compatibility:

    android {
        ...
        compileOptions {
            sourceCompatibility JavaVersion.VERSION_1_8
            targetCompatibility JavaVersion.VERSION_1_8
        }
    }
    
  5. Sync the Android Studio project.

Configuration

Most of the GetSocial settings are moved to a single getsocial.json file which could be used across all platforms. You can read more about single configuration file.

Open getsocial.json, which should lay in the same directory as your build.gradle and generated automatically by our script. . in the key name means it is inner json object, e.g. pushNotifications.autoRegister in json file should be translated to:

// getsocial.json
{
    ...
    "pushNotifications": {
        ...
        "autoRegister": true
    }
}

Gradle Plugin

useUiLibrary, version and appId are left in getsocial { } configuration closure in build.gradle.

Gradle Plugin Key getsocial.json key
autoInit autoInit
uiConfig uiConfig
useUiLibrary uiLibrary
autoRegisterForPush pushNotifications.autoRegister
foregroundNotifications pushNotifications.foreground
disableFacebookReferralCheck disableFacebookReferralCheck
disableAutoSetup Removed
disableDeepLinking Removed

Manual Integration

All pushNotifications.android.* values should not contain @drawable/, @color/, @string/ or any other prefix, it should be just a name of file without extension. For example, if you had im.getsocial.sdk.LargeNotificationIcon in AndroidManifest.xml with value @drawable/large_notification_icon, it should become pushNotifications.android.largeIcon with value large_notification_icon.

AndroidManifest.xml Key getsocial.json key
im.getsocial.sdk.AppId appId
im.getsocial.sdk.AutoInitSdk autoInit
im.getsocial.sdk.UiConfigurationFile uiConfig
im.getsocial.sdk.AutoRegisterForPush pushNotifications.autoRegister
im.getsocial.sdk.ShowNotificationInForeground pushNotifications.foreground
im.getsocial.sdk.DisableFacebookReferralCheck pushNotifications.disableFacebookReferralCheck
im.getsocial.sdk.DebugMode debugMode
im.getsocial.sdk.LargeNotificationIcon pushNotifications.android.largeIcon
im.getsocial.sdk.NotificationIcon pushNotifications.android.icon
im.getsocial.sdk.NotificationColor pushNotifications.android.color
im.getsocial.sdk.NotificationsChannelName pushNotifications.android.channelName
im.getsocial.sdk.NotificationsChannelDescription pushNotifications.android.channelDescription
im.getsocial.sdk.NotificationBackgroundImage pushNotifications.android.backgroundImage
im.getsocial.sdk.NotificationTitleColor pushNotifications.android.titleColor
im.getsocial.sdk.NotificationMessageColor pushNotifications.android.messageColor
im.getsocial.sdk.ShouldWaitForPushNotificationListener pushNotifications.customListener

Methods

All methods that had a CompletionCallback, Callback or other callback mechanism now have two different parameters for callbacks: CompletionCallback and Callback are called if operation succeeds and FailureCallback is called in case of error.

All methods that supported operations by GetSocial User ID now support both GetSocial ID and Identity ID. This is encapsulated in UserId and UserIdList classes for a single and multiple users respectively. Read more about this.

All methods that support pagination are now unified and use the same approach with classes PagingQuery and PagingResult. Read more about this.

Initialization

whenInitialized is changed to addOnInitializeListener and can be called multiple times.

SDK v6 Method SDK v7 Method
GetSocial.whenInitialized GetSocial.addOnInitializeListener

User Management

Current User

All methods related to the current user were in GetSocial.User class. Now you can get an object of CurrentUser using GetSocial.getCurrentUser(). This method returns null if SDK is not initialized. When you update user properties like avatar or display name, the object is automatically updated after opertion succeeded. If you switch or reset user, this object is changed to a new one. You will receive the new object in OnUserChangeListener or you can call GetSocial.getCurrentUser() again and get the new instance.

All getters should be called on GetSocial.http://docs.getsocial.im/reference/android/im/getsocial/sdk/communities/CurrentUser.htmlgetCurrentUser().
All setters are removed and you should use a single method GetSocial.getCurrentUser().updateDetails(...) instead.

GetSocial.addOnCurrentUserChangedListener can be called multiple times with different listeners. It returns a String - listener ID - which should be passed to GetSocial.removeOnCurrentUserChangedListener if you want to remove a certain listener. Listener is called with an instance of a new user, you can use it or call GetSocial.getCurrentUser() again.

SDK v6 Method SDK v7 Method
GetSocial.User.get* GetSocial.getCurrentUser().get*
GetSocial.User.set* GetSocial.getCurrentUser().updateDetails
GetSocial.User.addAuthIdentity GetSocial.getCurrentUser().addIdentity
GetSocial.User.removeAuthIdentity GetSocial.getCurrentUser().removeIdentity
GetSocial.User.switchUser GetSocial.switchUser
GetSocial.User.reset GetSocial.resetUser
GetSocial.User.setOnUserChangedListener GetSocial.addOnCurrentUserChangedListener
GetSocial.User.removeOnUserChangedListener GetSocial.removeOnCurrentUserChangedListener

Search Users

findUsers returned only the first page of matching users. New Communities.getUsers supports pagination.
You can also get a number of users that match a certain query using Communities.getUsersCount.

SDK v6 Method SDK v7 Method
GetSocial.getUserById, GetSocial.getUserByAuthIdentity Communities.getUser(UserId, Callback, FailureCallback)
GetSocial.getUsersByAuthIdentities Communities.getUsers(UserIdList, Callback, FailureCallback)
GetSocial.findUsers Communities.getUsers(PagingQuery, Callback, FailureCallback)

Activities

All activities related methods are moved to Communities class.
Like concept is now extended to Reaction and supports multiple reactions, like is among them.

All GetSocial.post* methods are replaced with a single Communities.postActivity with PostActivityTarget parameter. Read more about new features in Feeds 2.0.

SDK v6 Method SDK v7 Method
GetSocial.postActivityToFeed, GetSocial.postActivityToGlobalFeed, GetSocial.postCommentToActivity Communities.postActivity
GetSocial.likeActivity(…, true, …) Communities.addReaction
GetSocial.likeActivity(…, false, …) Communities.removeReaction
GetSocial.getActivityLikers Communities.getReactions
GetSocial.findTags Communities.getTags

Notifications

All notifications related methods are moved to Notifications class.

NotificationListener is now split into two: OnNotificationClickedListener and OnNoticationReceivedListener.

OnNotificationReceivedListener is called when application is in foreground and GetSocial Push Notification is received. Note that now it is called even if notifications in foreground are enabled.

Enable Click Listener

In order to make OnNotificationClickedListener being invoked, you have to set pushNotifications.customListener to true in getsocial.json:

// getsocial.json
{
    ...
    "pushNotifications": {
        ...
        "customListener": true
    }
}

OnNotificationClickedListener does not return a boolean anymore. If you have a custom listener and want to invoke a default behaviour, you should call GetSocial.handle() in places where you would return false in SDK 6.

SDK v6 Method SDK v7 Method
GetSocial.registerForPushNotifications Notifications.registerDevice
GetSocial.setNotificationListener Notifications.setOnNotificationClickedListener, Notifications.setOnNotificationReceivedListener
GetSocial.setPushNotificationTokenListener Notifications.setOnTokenReceivedListener
GetSocial.User.getNotifications Notifications.get
GetSocial.User.getNotificationsCount Notifications.getCount
GetSocial.User.sendNotification Notifications.send
GetSocial.User.setNotificationsStatus Notifications.setStatus
GetSocial.User.setPushNotificationsEnabled Notifications.setPushNotificationsEnabled
GetSocial.User.isPushNotificationsEnabled Notifications.arePushNotificationsEnabled

Invites

All invites related methods are moved to Invites class.

Available invite channels list is now asynchronous operation.

To get a referral data, you now have a ReferralDataListener, which will be called everytime the new referral data appears after clicking the link, whether on application launch or if application was running before.

SDK v6 Method SDK v7 Method
GetSocial.isInviteChannelAvailable Removed. You can get the list of available invite channels and check if invite channel is there.
GetSocial.getInviteChannels Invites.getAvailableChannels
GetSocial.sendInvite Invites.send
GetSocial.registerInviteChannelPlugin Invites.registerPlugin
GetSocial.getReferralData Invites.setReferralDataListener
GetSocial.clearReferralData Removed. You don’t need to clear referral data anymore, as you will receive only a new referral data in a listener.

Analytics

All analytics methods are moved to Analytics class.

SDK v6 Method SDK v7 Method
GetSocial.trackCustomEvent Analytics.trackCustomEvent
GetSocial.trackPurchaseEvent Analytics.trackPurchaseEvent

Promo Codes

All promo codes methods are moved to PromoCodes class.

SDK v6 Method SDK v7 Method
GetSocial.createPromoCode PromoCodes.create
GetSocial.getPromoCode PromoCodes.get
GetSocial.claimPromoCode PromoCodes.claim

Give us your feedback! Was this article helpful?

😀 🙁