When we send messages and initiate calls or receive calls then any notification is not coming. we are also upgrade the extension v1 & v2, and we are also sending the firebase token as well
implementation ‘com.cometchat:pro-android-chat-sdk:3.0.4’
implementation ‘com.cometchat:pro-android-calls-sdk:2.1.0’
Log.d(TAG, "Initialization completed successfully")
CometChat.login(UID, apiKey, object : CometChat.CallbackListener<User>() {
override fun onSuccess(user: User) {
Log.d(TAG, "Login Successful : $user")
val messagesRequest =
MessagesRequestBuilder().setUID(receiverID!!).setLimit(50).build()
messagesRequest.fetchPrevious(object :
CometChat.CallbackListener<List<BaseMessage>>() {
override fun onSuccess(list: List<BaseMessage>) {
token = MyFirebaseMessagingService.token
Log.e("token", token.toString())
if (MyFirebaseMessagingService.token==null) {
FirebaseMessaging.getInstance().token.addOnCompleteListener {
if(it.isComplete){
token = it.result.toString()
id?.let { it1 -> registerPushNotification(it1,token) };
}
}
}else id?.let { registerPushNotification(it,token) };
rivate fun registerPushNotification(uid: String, token: String) {
Log.e(TAG, “onComplete: $token”)
CometChat.registerTokenForPushNotification(
token,
object : CometChat.CallbackListener<String?>() {
override fun onSuccess(s: String?) {
Toast.makeText(this@NewChatActivity, s, Toast.LENGTH_LONG).show()
Log.e("onSuccessPN: ", s!!)
}
override fun onError(e: CometChatException) {
Log.e("onErrorPN: ", e.message!!)
Toast.makeText(this@NewChatActivity, e.message, Toast.LENGTH_SHORT).show()
}
})
val str = uid + "_progressbar"
val id = resources.getIdentifier(str, "id", packageName)}