Firebase
project at Firebase Console.
If you have previously not created a Firebase project for your app Click Add project. If you already have created a project for your app in which you wish to integrate CometChat, select the same project and download the config file.
google-services.json
file.GoogleServices-Info.plist
file.google-services.json
file.GoogleServices-Info.plist
file.AppID_user_UID
AppID_group_GUID
CustomMessage
, you need to set metadata while sending the CustomMessage
.
google-services plugin
to your Gradle files.
In your root-level (project-level) Gradle file (build.gradle), Check that you have Google’s Maven repository.
In your module (app-level) Gradle file (usually app/build.gradle), apply the Google Services Gradle plugin and add the dependencies for the Firebase Cloud Messaging.
AppID_user_UID
AppID_group_GUID
onMessageReceived (RemoteMessage remoteMessage)
.
CallNotificationAction.java
is a Broadcast Receiver which is used to handle call events when app is in the background.
Since Android O, there have been certain restrictions added for background tasks and users cannot launch intent directly from the service. More details can be found here.
AndroidManifest.xml
to make Push notification work in Background as well.
Cloud Messaging
tab.AppDelegate
:
application:didFinishLaunchingWithOptions
AppID_user_UID_ios
AppID_group_GUID_ios
CustomMessage
, you need to set the metadata
while sending the CustomMessage
:
google-services.json
file and place it inside of your project at the following location: /android/app/google-services.json.
Configure Firebase in Android:
To allow Firebase on Android to use the credentials, the google-services plugin must be enabled on the project. This requires modification to two files in the Android directory.
Add the google-services plugin as a dependency inside of your /android/build.gradle
.
Execute the plugin by adding the following to your /android/app/build.gradle
file.
GoogleService-Info.plist
file from your computer, and ensure the “Copy items if needed” checkbox is enabled.
didFinishLaunchingWithOptions
method, add the following to the top of the method:
CometChat.CometChatHelper.processMessage()
to convert the message JSON to the corresponding object of TextMessage
, MediaMessage
, CustomMessage
, Action
or Call
.
This code needs to be added to the onMessageReceived()
method of the FirebaseMessagingService
class.
CometChatConstants.MESSAGE_TYPE_IMAGE
CometChatConstants.MESSAGE_TYPE_VIDEO
CometChatConstants.MESSAGE_TYPE_AUDIO
CometChatConstants.MESSAGE_TYPE_FILE