Android SDK-API Usage guide

1.1 Setup integration

1.1.1 Register your application with Yuwee

Developers can sign up and register their application on YuWee Developer Console. However, this can be done via the following link: https://www.yuwee.com/login. Developers can then login into the developer console and register their application(s) to get Application Key and Application Secret. Moreover, this can be needed for the next steps of SDK integration.

1.1.2 Setup and configure SDK

The Yuwee SDK library is distributed in the.AAR format. However, this 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') 
}

1.1.3 Permissions

Yuwee SDK requires a minimum set of permissions and features. which needs to be allowed. The same is mentioned below. However, this 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 to run time permission for CAMERA, WRITE_EXTERNAL_STORAGE, RECORD_AUDIO

1.1.4 Initialize YuWee Client (yuweeClient):

Yuwee is the core class to leverage the YuWee SDK. A global Yuwee Client (yuweeClient) can be instantiated. After that, it is initialized in the onCreate() method of the Application Class in the following described way.  Moreover, 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); 
	}

Description and Usage

yuweeClient.init(context, appKey, appSecret)

Parameter

Parameter Name
Type
Description
Context Android context Global application context
appkey String Application key obtained from dev console
appSecret String Application key obtained from dev console

1.1.5 Create/Register User

yuweeClient.createUser (name, email, password)

Description

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

Parameter

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     
   } 
   
});

1.1.6 Create Session

yuweeClient.createSessionViaCredentials(email, password)

Parameter

Parameter Name
Type
Description
Email String A valid Email
Password String 6-20 chars limit

Event listeners

Even listeners
Parameter
Description
onSessionCreateSuccess Success message This listener is invoked when the account has been successfully created in YuWee
onSessionCreateFailure Error message This listener method is invoked whensession 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     
    } 
});

1.1.7 Logout/Destroy Session

yuweeClient.logout()

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.

1.1.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.

1.1.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.

1.1.7.1 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.

1.1.7.2 FORCE RECONNECT

yuweeClient.getConnectionController().forceConnect();
While the connection automatically tries to reconnect whenever there is a network fluctuation, however at certain situations the developer needs to force connect the connection to maintain the functionality of the app. e.g. when application goes to the background, the connection drops. It needs to be force connected via above API for YuWee SDK to keep functioning in background.

1.2 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: a. setRemoteVideoView() b. 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.

1.3 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

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 String Its value will be AUDIO for an audio call type,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.       
      } 
  });

1.4 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 anew 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’send when the callee accepts the call
onIncomingCallRejectSuccess callType, list of busy users This listener method is invoked at the caller’send 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     
    }
     });

1.5 Accept a call

yuweeClient.acceptIncomingCall();

1.6 Reject a call

yuweeClient.rejectIncomingCall();

1.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

1.7.0.1 Switch camera

yuweeClient.
​ getCallController().switchCamera();
This method toggles the front and rear camera during a call.

1.7.0.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 eithet 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     
     } 
 });

1.7.0.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.SPEAKER String Audio output changes to speaker
AudioOutputType.EARPIECE String Audio output changes to earpiece
AudioOutputType.WIRED_HEADSET String Audio output changes to wired headset

1.7.0.4 Call hangup

yuweeClient.getCallController().hangUpCall(); 

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

Event listener

Event listener
Parameter
Description
onCallHangUpSuccess nil This listener method is invoked when participant has successfully ends the call
onRemoteCallHangUp Remote user info{userId,name, email} This listener method is invoked for a participant of a call, when some otherparticipant has ended/left the call
onCallEnded nil This listener method is invoked when a call has ended, i.e all the participantshave left it successfully
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 onRemoteCallHangUp (JSONObject userInfo)
          {
    	       //Remote user up hung the call
          } 
 
 @Override     '
 public void onCallEnded() 
 {
  	//call Ended     
 } 
 
 @Override     
 public void onError(String error)
  {      
  // Error     
  } 
 
});

1.7.1 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 listener
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     
    }
     });

1.7.2 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
Parameter
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)
	    { 
 
    } 
});

1.7.3 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
Parameter 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 becauseyou want to get 29 recents most calls. To get next 29 calls, value of skipCount should be 20

Event listeners

 

Event listener
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! 
          } 
      });

1.7.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.

Parameter
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 listener
Parameter
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.
     } 
    });

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

Event listener
Parameter
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     
          }
         });

Get Upcoming Call List

yuweeClient.getAllUpcomingCalls()

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

Event listeners

 

Event listener
Parameter
Description
onGetUpcomingCallSuccess JSONObject response This listener method is invoked when the list of upcoming calls has been fetched successfully
onGetUpcomingCallError Error message 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     
     }
    });

Delete an upcoming/scheduled call

yuweeClient.deleteMeeting(JSONObject object)

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

Event listeners

Event listener
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

Join an Active upcoming/scheduled cal

yuweeClient.joinMeeting(groupId, callId, conferenceId , MediaType.VIDEO);
This API is used to join a particular upcoming or scheduled call.

Event listeners

Event listener
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(groupId, callId, conferenceId, MediaType.VIDEO).setOnJoinCallListener(new YuWee.OnSetUpCallListener()  
{    
 @Override
      public void onJoinSuccess() 
      {
               //Success     
      } 
 
    @Override 
        public void onError(String message)
         {          
            // some error occurred! Check message.     
         } 
     });

1.8 Chat

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).setFetchChatRoomLi stener(new YuWee.ChatController.OnFetchChatRoomListener()  
	{  
	   @Override
	    public void onFetchChatRoomSuccess(yuweeRoomodel room)
	     {                
	     	// response containing room details     
	     } 
 
    @Override
         public void onFetchChatRoomFailed(String error)
          {            
          	//Error     
          }
         });

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

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     
      }
     });

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     
     } 
 });

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) { 
 
    } 
});

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
Parameter
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 29 recent most messages. To get next 29 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)
     {       
     
     }
    });

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 readhas failed

Usage

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

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

Delete Message in a Conversation

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

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)
	  {               

	   }        
	 });

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
onClearChatRoomSuccess 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) 
            { 
            	
            	}         
            });

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) 
                    {    

                      } 

                });

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

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
onDeleteChatRoomFailed String error This listener method is invoked when the method to delete the conversation room has failed

Usage

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

1.9 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.

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) 
        { 
 
    } 
});

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

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             
                    }  
                });