Skip to content

User details formatter

Kristiyan Petrov edited this page Jan 22, 2019 · 4 revisions

Once user aliases are retrieved from your local or network storage with UserContactProvider, provide a formatter to display users textual info. The main advantage of using UserDetailsFormatter is that display data can be customized based on the context that has requested the display, so for example the display of a user can differ when has to be printed on a notification or on the ringing activity. FormatContext object describes which module (call or chat) has requested the user to display, so you can change how user details are displayed.

BandyerSDK.Builder builder = new BandyerSDK.Builder(appContext, appId)

builder.withUserDetailsFormatter(new UserDetailsFormatter() {
	@NonNull
	@Override
	public String format(@NonNull UserDetails userDetails, @NonNull FormatContext context) {
		if (context.getComponent() instanceof BandyerComponent.CallComponent)
       			if (context.isNotification())
       			       	return userDetails.getNickName();
       			else 
       			       	return userDetails.getEmail();
		else return userDetails.getFirstName() + " " +userDetails.getLastName();
	}
})
Clone this wiki locally