@wmora wmora released this Sep 18, 2017 · 45 commits to master since this release

Assets 2

5.0.0

This major version introduces a new optimized initialization sequence which changes when key events like creating an appUser or establishing a websocket connection are happening. These changes result in reduced usage of the CPU and networking resources, and reduced energy impact of the SDK.

Behavior Changes

  • Initialization is no longer done with an appToken. Use your Smooch app's ID instead.
// Before
Smooch.init(this, new Settings("YOUR_APP_TOKEN");

// After
Smooch.init(this, new Settings("YOUR_APP_ID"), new SmoochCallback() {
    @Override
    public void run(Response response) {
        // Handle init result
    }
});
  • jwt credential is now required when calling the login(String, String, SmoochCallback) API. You can no longer assign userIds to users without using a JWT to secure the userId.
// Before
Smooch.login("a_user_id", null);

// After
Smooch.login("a_user_id", "a_jwt", new SmoochCallback() {
    @Override
    public void run(Response response) {
        // Your code after login is complete
    }
});
  • Users are no longer automatically created at initialization time. Instead, a user is created when they send their first message. This means that the User instance is no longer guaranteed to have an appUserId when onInitializationStatusChanged(InitializationStatus) is called with status InitializationStatus.Success.
  • onInitializationStatusChanged(InitializationStatus) is no longer fired on login and logout. Use the newly added delegate methods for login/logout, or the block callbacks instead
// Before
public class MyConversationDelegate implements Conversation.Delegate {

    @Override
    public void onInitializationStatusChanged(InitializationStatus status) {
        // Handle init, login, logout result
    }

}

// After
public class MyConversationDelegate implements Conversation.Delegate {

    @Override
    public void onInitializationStatusChanged(InitializationStatus status) {
        // Handle init result
    }

    @Override
    public void onLoginComplete(LoginResult result) {
        // Handle login result
    }

    @Override
    public void onLogoutComplete(LogoutResult result) {
        // Handle logout result
    }

}

// Or

Smooch.init(this, settings, new SmoochCallback() {
    @Override
    public void run(Response response) {
        // Handle init result
    }
});

Smooch.login("a_user_id", "a_jwt", new SmoochCallback() {
    @Override
    public void run(Response response) {
        // Handle login result
    }
});

Smooch.logout(new SmoochCallback() {
    @Override
    public void run(Response response) {
        // Handle logout result
    }
});
  • userId and jwt can no longer be passed through Settings. You must either call login(String, String, SmoochCallback) or logout(SmoochCallback) to switch users. Note that login sessions are still persisted across application launches.
// Before
Settings settings = new Settings("YOUR_APP_TOKEN");
settings.setUserId("a_user_id");
settings.setJwt("a_user_id");
Smooch.init(application, settings);

// After
Settings settings = new Settings("YOUR_APP_ID");
Smooch.init(application, settings, null);
Smooch.login("a_user_id", "a_jwt", null);
  • Removed support for Whispers

API Changes (Breaking)

  1. Class Smooch
    • Replaced method init(Application, Settings) with init(Application, Settings, SmoochCallback)
    • Removed method init(Application, String). Use init(Application, Settings, SmoochCallback) instead
    • Replaced method login(String, String) with login(String, String, SmoochCallback)
    • Replaced method logout() with logout(SmoochCallback)
    • Replaced method getApp() with getConfig()
    • Removed method track(String)
  2. Class Settings
    • Constructor Settings(String) expects an app ID instead of an appToken
    • Replaced method getAppToken() with getAppId()
    • Removed method setUserId(String)
    • Removed method setJwt(String)
    • Removed method getUserId()
    • Removed method getJwt()
  3. Class Conversation
    • Removed deprecated method uploadImage(Bitmap, SmoochCallback). Use uploadImage(Message, SmoochCallback) instead
  4. Class Message
    • Removed method isWhisper()
  5. Class User
    • Replaced method getSmoochId() with getAppUserId()
  6. Enum InitializationStatus
    • Renamed InvalidToken to InvalidId
  7. Renamed class App to Config
    • Renamed getStripeEnabled() to isStripeEnabled()
    • Removed method getHasIcon()
    • Removed method getFcmProject()
    • Removed method getIntegrations()

API Additions

  1. Class Smooch
    • Added method getLastLoginResult()
  2. Interface Conversation.Delegate
    • Added method onLoginComplete(LoginResult)
    • Added method onLogoutComplete(LogoutResult)
  3. Added enum LoginResult
  4. Added enum LogoutResult

Other Changes

  • Updated compileSdkVersion to 26
  • Updated Firebase and Google Play Services version to 11.0.4
  • Update support libraries used by the SDK to 26.0.2
  • Proguard rules are now included for app obfuscation