use of com.cometchat.pro.core.Call in project android-java-chat-push-notification-app by cometchat-pro.
the class MyFirebaseMessagingService method onMessageReceived.
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
try {
count++;
json = new JSONObject(remoteMessage.getData());
Log.d(TAG, "JSONObject: " + json.toString());
JSONObject messageData = new JSONObject(json.getString("message"));
BaseMessage baseMessage = CometChatHelper.processMessage(new JSONObject(remoteMessage.getData().get("message")));
if (baseMessage instanceof Call) {
call = (Call) baseMessage;
isCall = true;
}
showNotifcation(baseMessage);
} catch (JSONException e) {
e.printStackTrace();
}
}
use of com.cometchat.pro.core.Call in project android-java-chat-push-notification-app by cometchat-pro.
the class Utils method getDirectCallData.
public static Call getDirectCallData(BaseMessage baseMessage) {
Call call = null;
String callType = CometChatConstants.CALL_TYPE_VIDEO;
try {
if (((CustomMessage) baseMessage).getCustomData() != null) {
JSONObject customObject = ((CustomMessage) baseMessage).getCustomData();
String receiverID = baseMessage.getReceiverUid();
String receiverType = baseMessage.getReceiverType();
call = new Call(receiverID, receiverType, callType);
if (customObject.has("sessionID")) {
String sessionID = customObject.getString("sessionID");
call.setSessionId(sessionID);
Log.e(TAG, "startDirectCallData: " + call.toString());
} else {
call.setSessionId(receiverID);
}
}
} catch (Exception e) {
Log.e(TAG, "startDirectCallData: " + e.getMessage());
}
return call;
}
use of com.cometchat.pro.core.Call in project android-java-chat-push-notification-app by cometchat-pro.
the class CallHistoryAdapter method update.
/**
* This method is used to update call in callList.
*
* @param call is an object of Call. It is used to update the previous call
* in list
* @see Call
*/
public void update(Call call) {
if (callList.contains(call)) {
Call oldCall = (Call) callList.get(callList.indexOf(call));
callList.remove(oldCall);
callList.add(0, call);
} else {
callList.add(0, call);
}
notifyDataSetChanged();
}
use of com.cometchat.pro.core.Call in project android-java-chat-push-notification-app by cometchat-pro.
the class CallUtils method initiateCall.
/**
* This method is used to initiate a call for user or a group.
* @param context is a object of Context
* @param recieverID is String - It can be either uid or guid
* @param receiverType is String - It can be either user or group
* [<code>CometChatConstants.RECEIVER_TYPE_USER</code> or
* <code>CometChatConstants.RECEIVER_TYPE_GROUP</code>]
* @param callType is String - It can be either audio or video
* [<code>CometChatConstants.CALL_TYPE_AUDIO</code> or
* <code>CometChatConstants.CALL_TYPE_VIDEO</code>]
*
* @see CometChat#initiateCall(Call, CometChat.CallbackListener)
*/
public static void initiateCall(Context context, String recieverID, String receiverType, String callType) {
Call call = new Call(recieverID, receiverType, callType);
CometChat.initiateCall(call, new CometChat.CallbackListener<Call>() {
@Override
public void onSuccess(Call call) {
if (receiverType.equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.RECEIVER_TYPE_USER))
startCallIntent(context, ((User) call.getCallReceiver()), call.getType(), true, call.getSessionId());
else if (receiverType.equalsIgnoreCase(com.cometchat.pro.constants.CometChatConstants.RECEIVER_TYPE_GROUP))
startGroupCallIntent(context, ((Group) call.getCallReceiver()), call.getType(), true, call.getSessionId());
}
@Override
public void onError(CometChatException e) {
Log.e(TAG, "onError: " + e.getMessage());
Snackbar.make(((Activity) context).getWindow().getDecorView().getRootView(), context.getResources().getString(R.string.call_initiate_error) + ":" + e.getMessage(), Snackbar.LENGTH_LONG).show();
}
});
}
Aggregations