Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.grameenphone.chitchat.utility;
- import android.content.ComponentName;
- import android.content.Context;
- import android.content.Intent;
- import android.content.ServiceConnection;
- import android.os.Bundle;
- import android.os.IBinder;
- import android.util.Log;
- import com.applozic.mobicomkit.Applozic;
- import com.applozic.mobicomkit.api.account.register.RegisterUserClientService;
- import com.applozic.mobicomkit.api.account.register.RegistrationResponse;
- import com.applozic.mobicomkit.api.account.user.MobiComUserPreference;
- import com.applozic.mobicomkit.api.notification.MobiComPushReceiver;
- import com.applozic.mobicomkit.uiwidgets.call.CallActivity;
- import com.applozic.mobicomkit.uiwidgets.call.CallService;
- import com.applozic.mobicomkit.uiwidgets.call.CallingClient;
- import com.google.firebase.messaging.RemoteMessage;
- import com.sinch.android.rtc.SinchHelpers;
- import com.sinch.android.rtc.calling.Call;
- import com.sinch.android.rtc.calling.CallClient;
- import java.util.HashMap;
- import java.util.Map;
- import static android.content.Context.BIND_AUTO_CREATE;
- import static com.android.volley.VolleyLog.TAG;
- public class FCMHelper {
- private static String TAG = "FCMHelper";
- public static void onNewToken(Context ctx, String registrationId) {
- Log.e("SDK-Helper-FCM-Token", registrationId);
- Applozic.getInstance(ctx).setDeviceRegistrationId(registrationId);
- if (MobiComUserPreference.getInstance(ctx).isRegistered()) {
- try {
- RegistrationResponse registrationResponse = new RegisterUserClientService(ctx).updatePushNotificationId(registrationId);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- }
- public static void onMessageReceived(final Context context, RemoteMessage remoteMessage) {
- Map data = remoteMessage.getData();
- Log.e("SDK-Helper", "onMessageReceived");
- if (remoteMessage.getData().size() > 0) {
- if (MobiComPushReceiver.isMobiComPushNotification(remoteMessage.getData())) {
- Log.e(TAG, "Applozic notification processing...");
- MobiComPushReceiver.processMessageAsync(context, remoteMessage.getData());
- return;
- }
- }
- if (SinchHelpers.isSinchPushPayload(remoteMessage.getData())) {
- Log.e("Push", " received data: " + remoteMessage.getData());
- StoreData storeData = StoreData.getInstance();
- Bundle bundle = new Bundle();
- bundle.putString("sinch", remoteMessage.getData().get("sinch"));
- Intent localIntent = new Intent("incomingCall");
- localIntent.putExtras(bundle);
- context.sendBroadcast(localIntent);
- // CallingClient.getInstance().initialize(context, storeData.getData(context, StoreData.USER_ID));
- // CallingClient.getInstance().getSinchClient(context).relayRemotePushNotificationPayload(remoteMessage.getData());
- }
- }
- }
- // new ServiceConnection() {
- //
- // private Map payload;
- //
- // @Override
- // public void onServiceConnected(ComponentName componentName, IBinder iBinder) {
- // Log.e(TAG, "onServiceConnected");
- // }
- //
- // @Override
- // public void onServiceDisconnected(ComponentName componentName) {
- // Log.e(TAG, "onServiceDisconnected");
- // }
- //
- // @Override
- // public void onBindingDied(ComponentName name) {
- // Log.e(TAG, "onBindingDied");
- // }
- //
- // @Override
- // public void onNullBinding(ComponentName name) {
- // Log.e(TAG, "onNullBinding");
- // }
- //
- // public void relayMessageData(Map<String, String> data) {
- // payload = data;
- // context.bindService(new Intent(context, CallService.class), this, BIND_AUTO_CREATE);
- // }
- // }.relayMessageData(data);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement