When ZegoCallPrebuilt receives a message from FCM, it sends a broadcast to the current application with action com.zegocloud.zegouikit.call.fcm when the message is not from Zego SDK, similar to the following code:
Intent intent = new Intent("com.zegocloud.zegouikit.call.fcm");
intent.putExtra("remoteMessage", remoteMessage);
context.sendBroadcast(intent);
Therefore, if you have already integrated Firebase Messaging, you only need to follow these steps to complete the migration:
Create and statically register a BroadcastReceiver in your application:
YourCustomBroadcastReceiver.java.application node of your application's Manifest.xml file, and set the action to "com.zegocloud.zegouikit.call.fcm", for example:<receiver
android:name="com.zegocloud.uikit.demo.calloffline.YourCustomBroadcastReceiver"
android:enabled="true"
android:exported="false">
<intent-filter>
<action android:name="com.zegocloud.zegouikit.call.fcm"/>
</intent-filter>
</receiver>
Remove your original FCM Service in Manifest.xml,it looks like:
<service
android:name=".java.MyFirebaseMessagingService"
android:exported="false">
<intent-filter>
<action android:name="com.google.firebase.MESSAGING_EVENT" />
</intent-filter>
</service>
please remove it to avoid conflict with Zego SDK.
Listen and handle the relevant events:
You have to migrate your logic from MyFirebaseMessagingService to YourCustomBroadcastReceiver as follow.
original code:
public class YourFirebaseMsgService extends FirebaseMessagingService {
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// your custom logic
}
}
please migrate like this,and delete YourFirebaseMsgService.java then:
public class YourCustomBroadcastReceiver extends BroadcastReceiver {
private static final String TAG = "CustomReceiver";
public void onReceive(Context context, Intent intent) {
com.google.firebase.messaging.RemoteMessage remoteMessage = intent.getParcelableExtra("remoteMessage");
// your custom logic
Log.d(TAG, "onReceive.remoteMessage.getData: " + remoteMessage.getData());
}
}
With these steps, you should be able to receive and handle your own FCM messages.
ZegoSendCallInvitationButton will show some error toast by default,you can disable the toast by this:
ZegoSendCallInvitationButton callInviteButton;
// ...
callInviteButton.showErrorToast(false);
callInviteButton.setOnClickListener(new ClickListener() {
@Override
public void onClick(int errorCode, String errorMessage, List<ZegoCallUser> errorInvitees) {
// add you custom logic for request resoult. 0 means send request success,else means failed.When errorCode is 0 , there may still have some error invitess.please check if all invitess receive successed.
}
});
By default,when in a call,if the back button of android was clicked,user will leave the call directly.
if you want to add a confirm Dialog,you can change the callInvitationConfig like this:
ZegoUIKitPrebuiltCallInvitationConfig callInvitationConfig = new ZegoUIKitPrebuiltCallInvitationConfig();
callInvitationConfig.provider = new ZegoUIKitPrebuiltCallConfigProvider() {
@Override
public ZegoUIKitPrebuiltCallConfig requireConfig(ZegoCallInvitationData invitationData) {
ZegoUIKitPrebuiltCallConfig config = null;
boolean isVideoCall = invitationData.type == ZegoInvitationType.VIDEO_CALL.getValue();
boolean isGroupCall = invitationData.invitees.size() > 1;
if (isVideoCall && isGroupCall) {
config = ZegoUIKitPrebuiltCallConfig.groupVideoCall();
} else if (!isVideoCall && isGroupCall) {
config = ZegoUIKitPrebuiltCallConfig.groupVoiceCall();
} else if (!isVideoCall) {
config = ZegoUIKitPrebuiltCallConfig.oneOnOneVoiceCall();
} else {
config = ZegoUIKitPrebuiltCallConfig.oneOnOneVideoCall();
}
config.hangUpConfirmDialogInfo = new ZegoHangUpConfirmDialogInfo();
return config;
}
};
You can adjust the value of the member variable config.hangUpConfirmDialogInfo to change the text of the dialog.
And,You can override BackPressEvent to custom back button event like this:
ZegoUIKitPrebuiltCallService.events.setBackPressEvent(new BackPressEvent() {
@Override
public boolean onBackPressed() {
//returns true means you need to custom back button event,while return false means you don't need to custom back button event,it will behave like default.
return true;
}
});
for example,if you want to miniMize call when you have already added ZegoMenuBarButtonName.MINIMIZING_BUTTON in config,you can call ZegoUIKitPrebuiltCallService.minimizeCall() in the callback:
ZegoUIKitPrebuiltCallService.events.setBackPressEvent(new BackPressEvent() {
@Override
public boolean onBackPressed() {
ZegoUIKitPrebuiltCallService.minimizeCall();
return true;
}
});
We contains three different log dirs:
)
Express SDK logs:
By default, the Express SDK will generate two types of log files:
TXT log files starting with "zegoavlog", with a default maximum size of 5MB (5 * 1024 * 1024 Bytes) per log file.
ZIP compressed files named "zegoavlog{serial number}-{timestamp}". After decompressing the file, you get a TXT log file named "zegoavlog{serial number}-{timestamp}". The "{serial number}" may vary, but the "{timestamp}" is the same. For example, decompressing zegoavlog3-16901111.zip yields the zegoavlog2-16901111.txt log file.
The default storage paths are: Android: "/storage/Android/data/[application package name]/files"
please send all these files to us to help you solve problems.
