Migration Guide

If you're migrating from an older version of the Chat SDK (prior to v2), this guide will help to highlight some of the key differences.

Updating Dependencies

Before

implementation group: 'com.zopim.android', name: 'sdk', version: '1.4.8'

If you only want to use the SDK's API providers and no UI components, insert the following line instead in the dependencies section:

implementation group: 'com.zopim.android', name: 'sdk-api', version: '1.4.8'

After

Before the dependencies section, add the following repositories section:

repositories {
     maven { url 'https://zendesk.jfrog.io/zendesk/repo' }
}

If you plan on using the SDK's built-in UI components, insert the following lines in the dependencies section:

dependencies {
     implementation group: 'com.zendesk', name: 'chat', version: '2.2.0'
     implementation group: 'com.zendesk', name: 'messaging', version: '4.3.1'
     ...
}

If you only want to use the SDK's API providers and no UI components, insert the following line instead in the dependencies section:

dependencies {
     implementation group: 'com.zendesk', name: 'chat-providers', version: '2.2.0'
     ...
}

For more information, see Add the Chat SDK dependencies.

Initializing the Chat SDK

The Chat SDK initialization should take place in the onCreate() method of your application class. The initialization method takes the Context and your account key (this can be obtained by asking the account owner).

Before

ZopimChat.init(String chatAccountKey);

After

//BaseApplication.java
Chat.INSTANCE.init(Context context, String chatAccountKey);

Adding visitor information

Before

VisitorInfo visitorInfo = new VisitorInfo.Builder()
                .phoneNumber(String phoneNumber)
                .email(String email)
                .name(String name)
                .build();

ZopimChat.setVisitorInfo(visitorInfo);

After

ProfileProvider profileProvider = Chat.INSTANCE.providers().profileProvider();

VisitorInfo visitorInfo = VisitorInfo.builder()
                .withPhoneNumber(String phoneNumber)
                .withEmail(String email)
                .withName(String name)
                .build();

profileProvider.setVisitorInfo(visitorInfo);

Setting the department

Before

final ZopimChat.SessionConfig config = new ZopimChat.SessionConfig()
                .department(String departmentName);

After

ChatProvider chatProvider = Chat.INSTANCE.providers().chatProvider();

chatProvider.setDepartment(String departmentName, ZendeskCallback<Void> zendeskCallback);

// OR

chatProvider.setDepartment(long departmentId, ZendeskCallback<Void> zendeskCallback);

Starting the chat

Before

startActivity(new Intent(this, ZopimChatActivity.class));

After

// YourActivity.java
MessagingActivity.builder()
  .withEngines(ChatEngine.engine())
  .show(view.getContext());

For a full list of all the new methods, see the reference docs.

Sending a message

Before

ZopimChat.start(getActivity()).send("Your message");

After

chatProvider.sendMessage(String message);