API Usage guide

1. Overview

YuWee Android SDK is intended to be used by developers to integrate real-time communication in their existing Android app with features like Audio-Video calls and Chat. The SDK is provided in the form of an easy-to-use Android library (AAR) that contains a set of exposed APIs and callback listeners to facilitate integration.

2. Setup integration

2.1 Register your application with Yuwee

Developers can sign up on YuWee Developer Console via following link: https://connect.yuwee.com/#/login

Developers can then login into the developer console and register their application(s) to get Client Id, Application Key and Application Secret needed for the next steps of SDK integration.

2.2 Setup and configure SDK

The YuWee SDK library is distributed in the .AAR format, which can be included into the existing project via build.gradle file as below

repositories {
flatDir{         
dirs 'libs'     
 	} 
} 
dependencies {     
compile(name:'yuwee', version:'1.0.0', ext:'aar') 
}

2.3 Permissions

YuWee SDK requires a minimum set of permissions and features, which needs to be allowed. The same are mentioned below and should be specified in the AndroidManifest.xml file of the project.

<uses-permission android:name="android.permission.INTERNET" /> 
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.RECORD_AUDIO" />
<uses-permission android:name="android.permission.MODIFY_AUDIO_SETTINGS" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<uses-feature android:glEsVersion="0x00020000" android:required="true" /> 

Note

Sensitive permission: Ask for run time permission for CAMERA, WRITE_EXTERNAL_STORAGE, RECORD_AUDIO

2.4 Initialize YuWee Client (yuweeClient):

YuWee is the core class to leverage the YuWee SDK. A global YuWee Client (yuweeClient) can be instantiated and then initialised in the onCreate() method of the Application Class in the following described way. yuweeClient can then be used across the project to call various APIs of YuWee SDK

public static YuWee yuweeClient = YuWee.getInstance(); 
 
 @Override 
    public void onCreate() 
 	{     

		super.onCreate();    
		yuweeClient .init(context, appKey, appSecret, clientId); 

	}

Description and Usage

yuweeClient.init(context, appKey, appSecret, clientId) 

Parameter

Parameter Name Type Description
Context Android context Global application context
appkey String Application key obtained from developer console
appSecret String Application secret obtained from developer console
clientId String Client ID obtained from the developer console

2.5 Create/Register User

yuweeClient.createUser (name, email, password) 

Description

This API is used to signup a new user in YuWee.

Parameters

Parameter name Type Description
Name String 3-30 chars limit
Email String A valid email
Password String 6-20 chars limit

Note

For more security, these APIs can be called from server side as well. API to export the user list via CSV is also available for initial migration. Please request for “Server-side API” document for the same.

Event listeners

Even listeners Parameter Description
onAccountCreateSuccess Success message This listener is invoked when the account has been successfully created in YuWee
onAccountCreatedFailure Error message This listener is invoked when accout creation fails for some reason

Usage

yuweeClient.createUser(name, email, password).setCreateUserListener(new YuWee.OnCreateUserListener() 
{ 
    
​	@Override     
		public void onAccountCreateSuccess(UserRegistrationResponse body) 
		{     
			// account creation successful    
 		} 
    
​ 	@Override
   		public void onAccountCreateFailure(UserRegistrationResponse body)
   		{                 
   			// account creation failed     
   		} 
   
}); 

2.6 Create Session

yuweeClient.createSessionViaCredentials(email, password, sessionExpirationTime) 

Description

This API will create a new session for the user.

Parameter

Parameter name Type Description
Email String A valid Email
Password String 6-20 chars limit
sessionExpirationTime String Time after which the session should expire and hence renew. It should be provided in seconds. Renewal of session is handled internally by YuWee SDK

Event listeners

Event listeners Parameter Description
onSessionCreateSuccess Success message This listener method is invoked when the session has been successfully created in YuWee
onSessionCreateFailure Error message This listener method is invoked when session creation fails for some reason

Usage

yuweeClient.createSessionViaCredentials(email, password).setCreateSessionListener( new YuWee.OnCreateSessionListener() 
{ 
     
​ @Override 
    public void onSessionCreateSuccess(UserLoginResponse userLoginResponse) 
    {  
    	// session creation successful 

    } 
 
    
​ @Override 
    public void onSessionCreateFailure(UserLoginResponse userLoginResponse) 
    {  
    	// session creation failed     
    } 
});

2.7 Logout/Destroy Session

yuweeClient.logout() 

This API will destroy user’s current session and also disconnects the user from the YuWee server.

2.8 Check Session Status

yuweeClient.isLoggedIn() 

This API will return a boolean stating whether there is an active session for the user or not. This is useful when we want to know if a user is logged in or not.

2.9 Manage Server Connection

To receive real time events such as incoming call, call accepted, etc a persistent connection needs to be managed between the SDK and YuWee’s communication server. After login YuWee is automatically connected to server. This connection can be impacted due to network fluctuation or change in network, etc and the same needs to be managed.

GET CONNECTION STATUS

yuweeClient.getConnectionController().isConnected(); 

This API is used to check the current status of the connection. it return true or false as boolean depending on whether the connection is intact.

3. Audio-Video Call

3.1 View Initialisation

  1. Developer need to create a Call Activity which will Extend “YuWeeCallActivity” from the SDK & override following 2 methods for initiating the Video Views:

    setRemoteVideoView()

    setLocalVideoView()

  2. On the layout file, developer needs to create two views of the class com.yuwee.sdk.view.YuWeeVideoView and return those two views on setRemoteVideoView & setLocalVideoView

N.B : setLocalVideoView is not used in case of group call.

On the onCreate() call the following API for the initialisation of the view:

yuweeClient.getCallController ().init() 

With this the views and main call activity will be initialised.

3.2 Start a call

yuweeClient.setupCall (callParams) 

Description

This API is used to setup a call. It takes an object of the class callParams as the parameter.

Usage of API

1. Direct Call using email

CallParams callParams = new CallParams(); 
callParams.mediaType = MediaType.VIDEO;  
callParams.invitationMessage = "Hi, lets have a call";  
callParams.inviteeEmail = "user@email.com";  
callParams.inviteeName = "Name";  
callParams.isGroup = false;  
 
yuweeClient.setupCall(callParams) 

2. Group call using emails

ArrayList<String> usersEmail = new ArrayList<>(); 
usersEmail.add(user1_email.getText().toString()); 
usersEmail.add(user2_email.getText().toString()); 
 
CallParams callParams = new CallParams(); 
callParams.mediaType = MediaType.VIDEO; 
callParams.isGroup = true; 
callParams.groupName = "test"; 
callParams.invitationMessage = "Test Message"; 
callParams.groupEmailList = usersEmail; 
 
yuweeClient.setupCall(callParams) 

3. Direct/group call using roomId

roomId can either be fetched from an existing room/conversation from the chat list model (received via FetchChatList API) or via the api FetchChatRoom as described later under chat section

CallParams callParams = new CallParams(); 
callParams.mediaType = MediaType.VIDEO; 
callParams.isGroup = true; // or false for  direct call 
callParams.groupName = "test";  //blank for direct call 
callParams.invitationMessage = "Test Message"; 
callParams.roomId = roomId; 
 
yuweeClient.setupCall(callParams) 

Note

Advantage of using roomId over emails in group calls is that when emails are used, a new room will be created every time a call is made even for the same set of users. Hence roomId should be used when calling over an existing room or group of users.

Parameters

Key Type Description
mediaType enum Its value will be MediaType.AUDIO for an audio call type, MediaType.VIDEO for video call type
invitationMessage String Optional
inviteeEmail String Email of the participant
inviteeName String Optional
isGroup Boolean True/false
groupName String Mandatory for group call
roomId String Fetched from ChatList model(received in FetchChatList API) or FetchChatRoom API

Event listeners

Event listener Parameter Description
onAllUsersOffline nil This listener method is invoked if none of the callees is online. In this case, a mail is triggered for the callees with links to join the call. The callee can click on the email link so as to re-initiate the call to the caller
onAllUserBusy nil This listener method is invoked in case all the callees are busy on another call and hence unavailable
onReadyToInitiateCall callType, list of busy users This listener method is invoked when atleast one callee is online and available. By now the available callees have already received a call notification via a callback. At this point, the caller can be taken to the next step of call connection

Usage

yuweeClient
​ .setUpCall(callParams).setUpCallListener(new YuWee.OnSetUpCallListener() 
 {     @Override     
 public void onAllUsersOffline()
{ 
 // when all Callees are offline
} 
 
@Override   
  public void onAllUsersBusy() 
  {
   // when all Callees are busy     
  } 
 
  @Override    
   public void onReadyToInitiateCall(CallParams callParams, ArrayList<String> busyUserList) 
  { 
   // Great! We are ready to initiate call!    
  } 
 
  @Override   
   public void onError(CallParams callParams, String message) 
    { 
     // Oops, something went wrong, check message.       
    } 
  }); 

3.3 Answer a call

To get notified of the incoming call event, developers need to set the following listener : YuWee.OnIncomingCallEventListener

Event listeners

Event listener Parameter Description
onIncomingCall UserId,email and name of caller This listener method is invoked when there is a new incoming call received. When this is invoked, developer can show incoming call activity with accept and reject buttons
onIncomingCallAcceptSuccess nil This listener method is invoked at the caller’s end when the callee accepts the call
onIncomingCallRejectSuccess callType, list of busy users This listener method is invoked at the caller’s end when the callee rejects the call

Usage

yuweeClient.setOnIncomingCallEventListener(new YuWee.OnIncomingCallEventListener()  
{     
@Override     
 public void onIncomingCall(String callerUserId, String email, String name)
 { 
 // called when new incoming call is received 
 // show incoming call activity, so that user can accept or reject call     
 } 
 
@Override     
 public void onIncomingCallAcceptSuccess() 
 {
 // called when user accepts incoming call
 // shows main call activity
 } 
 
@Override     
 public void onIncomingCallRejectSuccess() 
 { 
  // called when user rejects incoming call     
  }
     
});

3.4 Accept a call

yuweeClient.acceptIncomingCall(); 

3.5 Reject a call

yuweeClient.rejectIncomingCall(); 

3.6 Listen to OnGoing call events

yuweeClient.setCallEventListener(callEventListener)

This listener is used to listen to events related to an ongoing call.

Event listeners

Event listener Parameter Description
onCallTimeOut JSON participantInfo This listener method is invoked when the callee has not responded for 30 seconds and the call has timeout
onCallAccept JSON participantInfo This listener method is invoked when a participant has accepted the call
onCallReject JSON participantInfo This listener method is invoked when a participant has rejected the call
onCallRemoteHangup JSON participantInfo This Listener method is invoked when a participant has hung the call
onCallEnd JSON participantInfo This listener method is invoked when a participant has hung the call
onCallConnected null This listener method is invoked when a 1-to-1 call is connected, or when the participant has successfully joined a group call
onCallDisconnected null This listener method is invoked when the call has been disconnect for network issues
onCallConnectionFailed   YuWee automatically tries to connect a call after the call is disconnected for some reason, but if automatic connection is failed, this listener will be invoked

Usage

yuweeClient.setCallEventListener(new YuWee.OnCallEventListener() 
{
    @Override
    public void onCallTimeOut() 
    {
	   // when user didn’t respond to call.
    }

    @Override
    public void onCallAccept() 
    {
	   // when user accepted call
    }

     @Override
    public void onCallReject() 
    {
     // when user rejected call!
    }

    @Override
    public void onCallEnd() 
    {
     // when call finally ended.
    }

    @Override
   public onCallConnected() 
   {
    // when call is connected 
   }

    @Override
   public onCallDisconnected() 
   {
    // call may disconnect in case of internet connection lost
   }

   @Override
   public onCallReconnecting() 
   {
    // when trying to reconnect after you force connect a call.
   }

   @Override
   public onCallReconnected() 
   {
    // when a call is reconnected after force connecting a call
   }

@Override
   public onCallConnectionFailed()
    {
     // YuWee automatically tries to connect a call after the call is disconnected for some       
     // reason, but if automatic connection is failed, this method will be called. In this 
     //scenario, you may want to Force Reconnect the call.
   }

@Override
   public onCallReconnectionFailed() 
   {
    // this method will be called, in case Force Reconnection is failed as well
   }

});

3.7 Other call controls

CallController ​class is the core class to control different variables of a call. CallController ​instance can be fetched using ​yuweeClient.getCallController() and then can be used for following call controls

3.7.1 Switch camera

yuweeClient.getCallController().switchCamera(); 

This method toggles the front and rear camera during a call.

3.7.2 Control media stream

Pause/Un-pause video stream

yuweeClient.getCallController().setVideoEnabled(boolean isEnabled); 

Participant(s) in a call can choose whether he wants his video stream to be shown to other participant(s) or not. This can be done by toggling the Video stream to pause or unpause via this API. For a Video Call, Video stream is by default in unpaused state, whereas in Audio call, It is in paused state. Calling this API will toggle the state.

Mute/Unmute Audio stream

yuweeClient.getCallController().setAudioEnabled(boolean isEnabled);

Participant(s) in a call can choose whether he wants his Audio stream to be sent to other participant(s) or not. This can be done by toggling the Audio stream to mute or unmute via this API. Audio stream is by default in unmuted state, calling this API will toggle the state.

Listen to audio/video toggle

yuweeClient.setMediaToggleEventListener(mediaToggleListener) 

This Listener is used to listen to events of other users toggling their Audio or Video Stream either by Muting/Unmuting Audio or Pausing/Unpausing their Video Stream.

Event listeners

Event listener Parameter Description
onRemoteVideoToggle JSONObject userinfo This listener method is invoked when other participant has toggled his video stream
onRemoteAudioToggle JSONObject userinfo This listener method is invoked when other participant has toggled his audio stream

Usage

yuweeClient.setMediaToggleEventListener(new YuWee.MediaToggleEventListener()  
{
@Override     
 public void onRemoteVideoToggle(JSONObject jsonObject)
{ 
 // called when other user’s Video is toggled 
 // JSONObject : user info with video toggle data     
} 
 
@Override     
 public void onRemoteAudioToggle(JSONObject jsonObject)
{ 
 // called when other user’s Audio is toggled
 // JSONObject : user info with audio toggle data     
} 
}); 

3.7.3 Change Audio output

yuweeClient.getCallController().setAudioOutputType(AudioOutputType);

This method changes the Audio output to various output devices such as ear-piece, speaker or headset.

Parameters

Parameter name Type Description
AudioOutputType enum

AudioOutputType.SPEAKER: Audio output changes to Speaker

AudioOutputType.EARPIECE: Audio output changes to earpiece

AudioOutputType.WIRED_HEADSET: Audio output changes to wired headset

3.7.4 Call hangup

yuweeClient.getCallController().hangUpCall(); 

This API ends the ongoing call and clears up all the used resources.

Event listener

Event listener Parameter Description
onCallHangUpSuccess nil This listener method is invoked when participant has successfully ends the call
onError String error This listener method is invoked when there is an error hanging up the call

Usage

yuweeClient.setCallHangupEventListener(new YuWee.CallHangupEventListener()  
{     
@Override     
  public void onCallHangUpSuccess()
  { 
	//Call hung up successfully by self      
  } 

@Override     
  public void onError(String error)
  {      
  // Error     
  } 
 
});

3.7.5 Add participants to an existing call

yuweeClient.getCallController().addMemberOnCall(ArrayList<String> newMembers, String groupName)

This API is used to add new participants to an ongoing call.

Event listeners

Event listeners Parameter Description
onAddMemberSuccess ArrayList<Member> memberList This listener method is invoked when participants are added successfully to a call
onAddMemberFailure Error message This listener method is invoked when addition of participants has failed

Usage

ArrayList<String> newParticipantsEmails = new ArrayList<>(); 
newParticipantsEmails.add(user1_email.getText().toString());
 newParticipantsEmails.add(user2_email.getText().toString()); 
 
 
yuweeClient.addMemberOnCall(newParticipantsEmails, "My Group") .setAddMemberOnCallListener(new YuWee.OnAddMemberOnCallListener() 
	{     
		@Override     
		public void onAddMemberSuccess(ArrayList<Member> memberList) 
		{
		// new members are successfully added 
        // memberList = new all members list 
        } 
 
        @Override     
        public void onAddMemberFailure(String message) 
        { 
        // Failed!! Check message     
        }
    });  

3.7.6 Listen to event of new participant addition

yuweeClient.setOnMemberAddedOnCallListener( listener) 

This Listener is used to listen to the event of addition of new member to a call. On receiving this event user can update their UI such as - total participant count of the call or details of the participants in the call.

Event listeners

Event Listener Parameters Description
onMemberAddedOnCall CallType, participant details

This listener method is invoked when a new participant has been added by another participant in the call

callType= CallType.DIRECT when a participant has been added to a direct 1-to-1 call. In this case user can hide the local video.

callType= CallType.GROUP when a participant has been added to a group call

participantDetails: This is a JSONObject type param which contains the details of newly added participant

Usage

yuweeClient.setOnMemberAddedOnCallListener(new YuWee.OnMemberAddedOnCallListener()  
	{  
	   @Override     
	   public void onMemberAddedOnCall(CallType callType, JSONObject participantDetails)
	    { 
 
    	} 
});

3.7.7 Fetch recent calls list

yuweeClient.getRecentCall (String skipCount)

This API is used to fetch list of recent calls made or received by the user

Parameter

Parameters name Type Description
skipCount String skipCount is the number of calls that needs to be skipped from last. Ex. First time skipCount can be 0 because you want to get 20 recents most calls. To get next 20 calls, value of skipCount should be 20

Event listeners

Event name Parameter Description
onGetRecentCallSuccess JSONObject response This listener method is invoked when the call list has been successfully fetched
onGetRecentCallError String error This listener method is invoked when call list fetch has failed

Usage

yuweeClient.getRecentCall(“0”).setOnGetRecentCallListener(new YuWee.OnGetRecentCallListener() 
 {  
  @Override     
    public void onGetRecentCallSuccess(JSONObject jsonObject)
    { 
    // JSONObject : Contains recent call data
    } 
 
  @Override
    public void onGetRecentCallError(String error)
    { 
    // something went wrong. Check error! 
    } 
  });

3.7.8 Join an ongoing call

yuweeClient.joinOngoingCall (callId, mediaType);

This API is used to join an ongoing call

Parameter

Parameter name Type Description
callId String callId is the identifier which is unique for each call and can be used to join a specific call. To join a specific call, developer can look at the response of the fetch recent calls list API which contains callId of each ongoing as well as past call.
mediaType String Its value will be MediaType.AUDIO to join the ongoing call with only audio enabled and MediaType.VIDEO for both audio and video

Event listeners

Event name Parameter Description
onJoinSuccess nil This listener method is invoked when user has successfully joined the call
onError Error message This listener method is invoked when joining of the call fails

Usage

yuweeClient.joinOngoingCall(callId, MediaType.VIDEO).setOnJoinCallListener(new YuWee.OnJoinOngoingCallListener() 
{
    @Override
    public void onJoinOngoingCallSuccess() 
    {
    	//Success
    }

    @Override
    public void onError(String message) \
    {
        // some error occurred! Check message.
    }
});

4. Schedule a meeting

yuweeClient.schedu​leMeeting(JSONObject object) 

This API is used to schedule a call for a future date-time. Once a call has been scheduled, a meeting setup mail is sent to each participant with the meeting information. The email automatically makes entry in the respective email’s client calendar for native client reminder for the meeting. E.g. if the mail goes to outlook, an event is entered to the outlook calendar. Other supported clients/Calendars are Gmail, Apple calendar. User can accept/reject the meeting via calendar.

Parameters

Parameter name Type Description
scheduler_name String Name of the meeting
scheduler_description String Meeting description
date_of_start String Format dd/mm/yyyy, e.g 17/Aug/2019
Time String Format HH:MM
Duration String Format HH:MM
scheduler_media String “audio”/”video”
time_zone String Format: “GMT+HH:MM”. E.g GMT+05:30
alert_before_meeting Number In minutes
Members JSONArray JSONArray of emails

Event listeners

Event listeners Parameters Description
onMeetingCreatedSuccessfully JSONObject response This listener method is invoked for each participants once a meeting has been successfully registered
onMeetingCreationFailure Error message This listener method is invoked when a meeting creation has failed

Usage

JSONArray members= new JSONArray(); 
members.put("user1@email.com"); 

members.put("user2@email.com"); 
 
 
JSONObject object = new JSONObject(); 
object.put("scheduler_name", name);  
object.put("scheduler_description", description);
object.put("date_of_start", startDate);  
object.put("time", time); // Format HH:mm
object.put("duration", duration); // Format HH:mm
object.put("scheduler_media", “video”);
object.put("time_zone", timeZone);
object.put("alert_before_meeting", minutes); 
object.put("members", members);  
 
yuweeClient.scheduleMeeting(object).setScheduleMeetingListener(new YuWee.OnMeetingListener() 
{     
	@Override     
 		public void onMeetingCreatedSuccessfully(JSONObject response)
  		{ 
  			// meeting created successfully     
  		} 
 
    @Override     
    	public void onMeetingCreationFailure(String error)
     	{
     		// meeting creation failed!! Check error message.
     	} 
}); 

4.1 Schedule Call Event Listener

yuweeClient.setOnScheduleCallEventsListener( )

Above listener is used to listen for a new scheduled call, join call, scheduled call expiration and scheduled call delete events

Event listeners

Even listener Parameters Description
onNewScheduledCall JSONObject callDetails This listener method is invoked for each participants once a meeting has been successfully registered
onScheduledCallActivated Error message This listener method is invoked for each participants when a scheduled call has got activated, i.e just before the reminder duration prior to the scheduled time
onScheduledCallDeleted JSONObject callDetails This listener method is invoked for each participant once a meeting has been deleted by the host
onScheduleCallExpired JSONObject callDetails This listener method is invoked for each participant once a meeting has expired

Usage

yuweeClient.setOnScheduleCallEventsListener(new YuWee.OnScheduleCallEventsListener() 
{     
@Override     
    public void onNewScheduleCall(JSONObject jsonObject)
    {               
 	// when someone scheduled a call with you as a participant     
    } 
 
 @Override     
    public void onJoinScheduleCall(JSONObject jsonObject)
    {               
    // when scheduled call has been activated     
    } 
 
@Override
    public void onDeleteScheduleCall(JSONObject jsonObject) 
    {               
    // when host deletes the scheduled call     
    } 

@Override     
    public void onExpireScheduleCall(JSONObject jsonObject)
    {               
    // when a scheduled call is expired     
    }
}); 
 

4.2 Get Upcoming Call List

yuweeClient.getAllUpcomingCalls() 

This API is used to get list of all upcoming calls for the user.

Event listeners

Event name Parameter Description
onGetUpcomingCallSuccess JSONObject response This listener method is invoked when the list of upcoming calls has been fetched successfully
onGetUpcomingCallError Error messsage This listener method is invoked when fetching of list fails

Usage

yuweeClient.getAllScheduledMeeting().setOnGetUpcomingCallListener(new YuWee.OnGetScheduleMeetingListener() 
{     
@Override     
	public void onGetUpcomingCallSuccess(JSONObject response)
	{              
  	// json response containing all scheduled meeting     
	} 
 
@Override     
    public void onGetUpcomingCallError(String error)
    {               
    // Error     
    }
}); 

4.3 Delete an upcoming/scheduled call

yuweeClient.deleteMeeting(JSONObject object) 

This API is used to delete a particular upcoming or scheduled call.

Event listeners

Event name Parameter Description
onDeleteMeetingSuccess JSONObject response This listener method is invoked when an upcoming call has been successfully deleted
onDeleteMeetingError Error message This listener method is invoked when deletion of the upcoming call fails

Usage

JSONObject params= new JSONObject();
params.put("scheduler_id", schedulerId);  // scheduled meeting id 
params.put("meeting_entry_id", meetingEntryId);  // meeting entry id   

yuweeClient.deleteMeeting(params).setOnDeleteMeetingListener(new YuWee.OnDeleteMeetingListener()  
{     
  @Override     
	 public void onDeleteMeetingSuccess(JSONObject response) 
	 { 
 
    } 
 
  @Override
    public void onDeleteMeetingError(String error)
    { 
 
    }
});

4.4 Join an Active upcoming/scheduled call

yuweeClient.joinMeeting(callId, mediaType);

This API is used to join a particular upcoming or scheduled call. callId is the identifier which is unique for each call. Developer can look at the response of the Get Upcoming Call List API which contains details along with callId of each upcoming/scheduled call.

Parameters

Parameter name Type Description
callId String callId is the identifier which is unique for each call and can be used to join a specific call.
mediaType String Its value will be MediaType.AUDIO to join the ongoing call with only audio enabled and MediaType.VIDEO for both audio and video

Event listeners

Event name Parameter Description
onJoinSuccess nil This listener method is invoked when user has successfully joined the call
onError Error message This listener method is invoked when joining of the call fails

Usage

yuweeClient.joinMeeting(callId, MediaType.VIDEO).setOnJoinCallListener(new YuWee.OnJoinScheduleCallListener()  
{    
  @Override
    public void onJoinSuccess() 
    {
      //Success     
    } 
 
  @Override 
    public void onError(String message)
    {          
      // some error occurred! Check message.     
    } 
}); 

5. Chat

5.1 Create a chat room

yuweeClient.getChatController().fetchChatRoombyUserIds(ArrayList<String> userIds) 
yuweeClient.getChatController().fetchChatRoombyEmails(ArrayList<String> emails)

These APIs are used to create a new chat room. They will return the roomId which can be used to communicate messages and also calls. ​If a chat room with provided users or emails already exists, existing roomId will be returned otherwise a new roomId will be returned.

Event listeners

Event name Parameter Description
onFetchChatRoomSuccess room details This listener method is invoked when a room has been successfully created or fetched
onFetchChatRoomFailed Error message This listener method is invoked when room creation fails

Usage

ArrayList<String> emailList = new ArrayList<>(); 
emailList.add("xyz@email.com"); emailList.add("abcd@email.com"); 
 
yuweeClient.getChatController().fetchChatRoombyUserIds(emailList).setFetchChatRoomListener(new YuWee.ChatController.OnFetchChatRoomListener()  
	{  
		@Override
	    	public void onFetchChatRoomSuccess(yuweeRoomodel room)
	     	{                
	     		// response containing room details     
	     	} 
 
    	@Override
        	public void onFetchChatRoomFailed(String error)
          	{            
          		//Error     
          	}
    }); 

5.2 Send a chat message

yuweeClient.getChatController().sendMessage(Message, RoomId , messageIdentifier​); 

This API is used to send chat messages.

Parameter

Parameter name Parameter Description
Message String Message to be sent
RoomId String The roomId on which the message will be sent. It can be either received through “Create a room” API or through parameter in the roomList
messageIdentifier String This is unique id defined by developer, so that when this message is delivered, developer will know which message has been delivered

5.3 Message delivered listener

Event listeners

Event name Parameter Description
onMessageDeliverySuccess JSONObject messageDetails This listener method is invoked when a message has been successfully delivered

Usage

yuweeClient.getChatController().setMessageDeliveryListener(new YuWee.ChatController.OnMessageDeliveryListener()  
{     
	@Override
    	public void onMessageDeliverySuccess(JSONObject object)
    	{         
      		// called when a message is delivered     
    	}
}); 

5.4 Receive a Chat Message

YuWee.ChatController.OnNewMessageReceivedListener() 

To listen for new chat message, above listener is used

Event listeners

Event name Parameter Description
onNewMessageReceived JSONObject messageDetails This listener method is invoked when a new message is received

Usage

yuweeClient.getChatController().setOnNewMessageReceivedListener(new YuWee.ChatController.OnNewMessageReceivedListener()  
{
    @Override     
    	public void onNewMessageReceived(JSONObject jsonObject) 
     	{         
     		// called when new message is received     
     	} 
}); 

5.5 Fetch a chat list

YuWee.getChatController().fetchChatList() 

This API is used to fetch all the chat list (list of conversations or rooms) of the users.

Event name Parameter Description
onFetchChatListSuccess yuweeChatListModel type This listener method is invoked when chat list has been successfully fetched
onFetchChatListFailed String error This listener method is invoked when fetching the chat list fails

Usage

yuweeClient.getChatController().fetchChatList().setFetchChatListListener(new YuWee.ChatController.OnFetchChatListListener()  
	{    
		@Override
	 		public void onFetchChatListSuccess(yuweeChatListModel body) 
	 		{ 
 
    		} 
 
    	@Override     
    		public void onFetchChatListFailed(String error) 
    		{ 
 
    		} 
	}); 

5.6 Fetch a conversation

yuweeClient.getChatController().fetchChatMessages(String roomId, String skipCount) 

This API is used to fetch all the messages of a particular conversation or room

Parameters

Parameters name Type Description
roomId String roomId of the room whose conversation needs to be fetched
skipCount String skipCount is the number of messages that needs to be skipped from last. ex: first time skip Count can be 0 because you want to get 20 recent most messages. To get next 20 messages, value of skipCount should be 20.

Event listeners

Event name Parameter Description
onFetchChatMessageSuccess JSONObject response This listener method is invoked when messages of the chat room has been successfully fetched
onFetchChatMessageFailed String error This listener method is invoked when message fetch for the room has failed

Usage

yuweeClient.getChatController().fetchChatMessages("5b4de673952c6a154a30b82d", "0" ) .setFetchChatMessageListener(new YuWee.ChatController.OnFetchChatMessageListener() 
	{     
		@Override     
			public void onFetchChatMessageSuccess(JSONObject response)
		 	{       
	
			 } 
 
    	@Override     
    		public void onFetchChatMessageFailed(String error)
     		{       
     
    		 }
    }); 

5.7 Mark Message as Read

yuweeClient.getChatController().markMessagesReadInRoom(String roomId)

This API is used to mark the messages as “read”.

Parameters

Parameter name Type Description
roomId String roomId of the room whose all messages need to be marked as read

Event listeners

Event name Parameter Description
onReadMessageInRoomSuccess JSONObject response This listener method is invoked when all messages of a room are successfully marked as read
onReadMessageInRoomFailed String error This listener method is invoked when process for marking all the messages in a room as read has failed

Usage

yuweeClient.getChatController().markMessagesReadInRoom("5b4de673952c6a154a30b82d"). setReadMessageInRoomListener(new YuWee.ChatController.OnReadMessageInRoomListener()
 {     
 	@Override     
 		public void onReadMessageInRoomSuccess(JSONObject response)
 	 	{

        } 
 
    @Override     
    	public void onReadMessageInRoomFailed(String error) 
    	{       
    
   		 }
     
}); 

5.8 Delete Message in a Conversation

yuweeClient.getChatController().deleteMessageInRoom( roomId, messageId, messagetype)

This API is used to delete a particular message of a conversation or room.

Parameters

Parameters name Type Description
roomId String roomId of the room whose message needs to be deleted
messageId String MessageId of the message to be deleted
MessageDeleteType enum

MessageDeleteType.FOR_ME: Delete the message for me only.

MessageDeleteType.FOR_ALL: Delete the message for everyone in the room

Event Listeners

Event name Parameter Description
onDeleteMessageInRoomSuccess JSONObject response This listener method is invoked when the targeted message has been successfully deleted
onDeleteMessageInRoomFailed String error This listener method is invoked when deletion of the taget message has failed

Usage

yuweeClient.getChatController().deleteMessageInRoom ("5b4de673952c6a154a30b82d","5b55bacde3b1611befbcfebe",MessageDeleteType.FOR_ME)
.setDeleteMessageInRoomListener(new YuWee.ChatController.OnDeleteMessageInRoomListener() 
	{             
		@Override
			public void onDeleteMessageInRoomSuccess(JSONObject response)
	 		{              	  

     		} 

        @Override
		 
		 public void onDeleteMessageInRoomFailed(String error)
	  		{               

	   		}        
	}); 

5.9 Listen for Message Deletion

yuweeClient.getChatController().setOnMessageDeletedListener() 

This Listener needs to be registered to listen to event which is triggered when a message has been deleted by the sender.

Event listener

Event name Parameter Description
onMessageDeleted JSONObject messageDetails This listener method is invoked for all the room participants when a message is deleted by the sender in that room

Usage

yuweeClient.getChatController().setOnMessageDeletedListener(new YuWee.ChatController.OnMessageDeletedListener()  
	{    
		@Override     
	 		public void onMessageDeleted(JSONObject jsonObject)
	  		{ 
 
    		} 
	}); 

Clear Conversation

yuweeClient.getChatController().clearChatRoom(roomId) 

This API is used to delete all messages of a particular conversation or room.

Parameters

Parameters name Type Description
roomId String roomId of the room whose conversation needs to be cleared

Event listeners

Event name Parameter Description
onClearChatRoomSuccess JSONObject response This listener method is invoked when the targeted conversation/room is cleared successfully
onClearChatRoomFailed String error This listener method is invoked when the method to clear the room has failed

Usage

yuweeClient.getChatController().clearChatRoom("5b4de673952c6a154a30b82d").setClearChatRoomListener(new YuWee.ChatController.OnClearChatRoomListener() 
	{             
		@Override             
		    public void onClearChatRoomSuccess(JSONObject response)
		    {

                } 
 
            @Override
                  public void onClearChatRoomSuccess(String error) 
                  { 
            	
            	}         
      });

5.10 Delete a conversation/Room

yuweeClient.getChatController().deleteChatRoom(roomId) 

This API is used to delete a particular conversation or room completely from the listing.

Parameters

Parameters name Type Description
roomId String roomId of the room which needs to be deleted

Event listeners

Event name Parameter Description
onDeleteChatRoomSuccess JSONObject response This listener method is invoked when the targeted conversation/room is deleted successfully
onDeleteChatRoomFailed String error This listener method is invoked when the method to delete the conversation room has failed

Usage

yuweeClient.getChatController().deleteChatRoom("5b4de673952c6a154a30b82d").setDeleteChatRoomListener(new YuWee.ChatController.OnDeleteChatRoomListener() 
	{             
		@Override 
			public void onDeleteChatRoomSuccess(JSONObject response) 
		  	{         

		    } 
 
        @Override 
            public void onDeleteChatRoomFailed(String error) 
            {    

            } 

    });

5.11 Sent typing events in room

yuweeClient.getChatController().sendTypingStatus(roomId) 

This API is used to broadcast user’s typing event to the room. Everyone else in the room receives the typing status of other users via a listener described in 2.8.13

Parameters

Parameters name Type Description
roomId String roomId of the room where typing status need to be broadcasted

5.12 Listen to typing events in room

yuweeClient.getChatController().setOnTypingEventListener(listener) 

This Listener is used to register to events of other user’s typing in the room.

Event listeners

Event name Parameter Description
onUserTypingInRoom JSONObject response This listener method is invoked when any other user is typing a message in the room

Usage

yuweeClient.getChatController().setOnTypingEventListener(new YuWee.ChatController.OnTypingEventListener()  
	{     
		@Override
		     public void onUserTypingInRoom(JSONObject userde) 
		     { 
		     		// called when other users in the room type      
		     } 
	});

6. Push notifications

To receive notification of Calls, Chats, Scheduled Meeting when app is not in open or active state, developer needs to activate Push Notification for the app.

To enable push notification for the app, developer needs to upload its unique FCM Server key at the developer panel. The FCM Server key is generated via Firebase developer console.

6.1 Register device token

yuweeClient.registerFirebaseToken(String firebaseToken) 

Parameters

Parameters name Type Description
firebaseToken String This is the unique firebase device token generated by FirebaseInstanceId object

Usage

String token = FirebaseInstanceId.getInstance().getToken();   
yuweeClient.registerFirebaseToken(token).setUpdateTokenListener(new YuWee.OnRegisterFirebaseTokenListener() 
	{     
		@Override 
			public void onRegisterTokenSuccess(String message)
		   { 
 
    		} 
 
    	@Override 
        	public void onRegisterTokenFail(String message) 
        	{ 
 
    		} 
	}); 

6.2 Pass Push Notification data to SDK for processing

yuweeClient.getNotificationManager().process(remoteMessage.getData());

Above method should be invoked inside “onMessageReceived()” method of FirebaseMessagingService class to pass the incoming data for further processing

6.3 Receive Notifications via SDK

yuweeClient.getNotificationManager().setYuWeeNotificationListener() 

This listener is set to receive the processed push notification from SDK.

Event listeners

Event name Parameter Description
onReceiveCallFromPush JSONObject jsonObject This listener method is invoked when app receives a new incoming call notification via PUSH notification
onChatMessageReceivedFromPush JSONObject jsonObject This listener method is invoked when app receives a new incoming chat notification via PUSH notification
onNewSchdeuleMeetingFromPush JSONObject jsonObject This listener method is invoked when the app receives a new scheduled call notification via PUSH notification
onNewScheduleMeetingFromPush JSONObject jsonObject This listener method is invoked when the app receives a notification for a scheduled call activation via PUSH notification

Usage

  yuweeClient.getNotificationManager().setYuWeeNotificationListener(new YuWee.OnYuWeeNotificationListener()  
  {
    @Override             
      public void onNewScheduleMeetingFromPush(JSONObject jsonObject)
      {                 
  		  // when a new scheduled meeting notification  is received             
      } 
 
    @Override
      public void onScheduleMeetingJoinFromPush(JSONObject jsonObject)
      {                 
   		 // when a particular scheduled meeting gets activated             

      } 
 
    @Override     
      public void onChatMessageReceivedFromPush(JSONObject jsonObject) 
      { 
    	 // when a new chat is received             
                    }  
  });