Skip to content

Upgrade to Bandyer SDK v3.0.x

Kristiyan Petrov edited this page Jun 16, 2022 · 6 revisions

Upgrade to v3.+

This new version comes with general improvements, comes with APIs that have been simplified to let the SDK integration be easier for third part apps.

SDK authentication has also been rewritten to enforce security. The SDK authentication is now enforces using access token mechanism. Access tokens have a duration that can be tweaked server side; it is now offered a fluent api to renew access tokens in order to refresh the sdk session.


Renamed UI styles

All BandyerSDKDesign style refs have been refactored in KaleyraCollaborationSuiteUI

And resources/attrs/ids are now using the prefix kaleyra instead of bandyer

Configure the BandyerSDK

The SDK configuration has been changed and must be now implmented using the new API on the BandyerSDK singleton that follows:

Environment environment = Environment.Production.INSTANCE; // or Environment.Sandbox.INSTANCE

Region region = Region.Eu.INSTANCE; // or Region.In.INSTANCE

PriorityLogger logger = null;
if (BuildConfig.DEBUG) 
	logger = AndroidPriorityLoggerKt.androidPrioryLogger(BandyerSDKLoggerKt.SDK, BaseLogger.ERROR);

 BandyerSDK.getInstance().configure(
	new BandyerSDKConfiguration.Builder(configuration.getAppId(), environment, region)
		.tools(builder -> {
			builder.withCall(configurableCall -> {
				// this callback will be called to optionally set and update the call configuration
				configurableCall.setCallConfiguration(new SimpleCallConfiguration());
			});
			
			// enable chat module
			builder.withChat(configurableChat -> {
				// this callback will be called to optionally set and update the chat configuration
				configurableChat.setChatConfiguration(new SimpleChatConfiguration());
			});
		})
		.build()
);

Note that the configuration flow must be invoked before initialization.

Initialize the BandyerSDK

The SDK can be connected and disconnected with a new set of APIs. The connect API must be called after that the configure API has been invoked. A session object must be provided to the connect api holding info about the logging user and the access token provider. An optional session observer can be passed to the session object in order to be informed about the authentication process.

AccessTokenProvider accessTokenProvider = new AccessTokenProvider() {
            
	@Override
	public void provideAccessToken(@NonNull String userId, @NonNull Completion<String> completion) {
		// retrieve token [...]
		completion.success(accessToken); // or call completion.error(exception) if an error occurred
	}
};

Session session = new Session("userId", accessTokenProvider);

BandyerSDK.getInstance().connect(session,
      errorReason -> Log.e(TAG, "Unable to connect BandyerSDK with error: " + errorReason)
);

To disconnect BandyerSDK use disconnect api as follows:

BandyerSDK.getInstance().disconnect();

BanderSDKClientObserver has been removed: to observe authentication and connection status please use SessionObserver interface as shown above and the BandyerModuleObserver interfaces as in v2.x.x

Push notifications

Managing push payload requires now that the SDK has been connected before handling push payload as follows:

Session session = new Session(
	"userId",
	accessTokenProvider);

BandyerSDK.getInstance().connect(
	session,
	errorReason -> Log.e(TAG, "Unable to connect BandyerSDK with error: " + errorReason)
);

BandyerSDK.getInstance().handleNotification(payload);

Handle external url links

Handling external url call links now requires now that the SDK has been connected before as shown below. Once BandyerSDK connect api has been called you may start the activity with the Bandyer Intent to handle the external link.

Session session = new Session(
	"userId",
	accessTokenProvider);

BandyerSDK.getInstance().connect(
	session,
	errorReason -> Log.e(TAG, "Unable to connect BandyerSDK with error: " + errorReason)
);

Intent intent = new BandyerIntent.Builder()
	.startFromJoinCallUrl(this, joinUrl)
	.build();

startActivity(intent);

UserDetailsProvider and UserDetailsFormatter

To express in a more consistent way with the other apis, the UserDetailsProvider has been updated as follows:

UserDetailsProvider userDetailsProvider = new UserDetailsProvider() {
	@Override
	public void onUserDetailsRequested(@NonNull List<String> userAliases, @NonNull Completion<Iterable<UserDetails>> completion) {
		// fetch details [...]
		completion.success(userDetailsIterable);
	}
};

The UserDetailsProvider and UserDetailsFormatter are now passed to the BandyerSDK instance in order to update them if needed:

BandyerSDK.getInstance().setUserDetailsProvider(userDetailsProvider);

BandyerSDK.getInstance().setUserDetailsFormatter(userDetailsFormatter);

Modules

BandyerModuleStatus enumeration has been simplified. Call and chat modules status are now represented by the following enum class:

enum class BandyerModuleStatus {

    /**
     * When the module has been disconnected from internet
     */
    DISCONNECTED,

    /**
     * When the module is connecting to internet
     */
    CONNECTING,

    /**
     * When the module is ready to be used
     */
    READY,

    /**
     * When the module is online a.k.a connected to internet
     */
    CONNECTED,

    /**
     * When the module has failed
     */
    FAILED
}

Changed CapabilitySet and OptionSet

Please follow the following guide to migrate to the new capabilitySet and OptionSet Customize Configuration

Removed APIs

All deprecated methods from the following classes have been removed:

  • IncomingCall
  • IncomingChat

From CallIntentBuilder class the following methods have been removed:

  • withCapabilities(CapabilitySet capabilities)
  • withOptions(CallOptionSet options)
  • withConfiguration(Configuration.Call configuration)

The call configuration can now be passed to the BandyerSDKConfiguration tools withCall callback that is called on every call showing.

From ChatIntentBuilder class the following methods have been removed:

  • withAudioCallCapability(CallCapabilitySet callCapabilities, CallOptionSet callOptions)
  • withAudioUpgradableCallCapability(CallCapabilitySet callCapabilities, CallOptionSet callOptions)
  • withAudioVideoCallCapability(CallCapabilitySet callCapabilities, CallOptionSet callOptions)
  • withConfiguration(Configuration.Chat configuration)

The chat configuration can now be passed to the BandyerSDKConfiguratio tools withChat callback that is called on every chat showing.

From IncomingCall class the following methods have been removed:

  • withConfiguration(configuration: Configuration.IncomingCall)

The call configuration for incoming calls can now be passed to the BandyerSDKConfiguration tools withCall callback that is called on every call showing.

Complete changes overview

For a complete overview of the changes please refer to: v3.0.0

Clone this wiki locally