Now, you are all set from the Firebase Console side. Select the Cloud Messaging tab and copy the Server key to some temporary place.
Now, click on the small gear icon beside the Overview button, and select Project Settings button. Back to the Firebase Console, click the Next button and then continue to the console. Press Sync Now button and this will be a successful build. Implementation ":firebase-messaging:20.0.0"Īpply plugin: '-services' Implementation "com.cometchat:pro-ext-pn:1.0.+"
Implementation "com.cometchat:pro-android-chat-sdk:1.8.+" Implementation fileTree(dir: 'libs', include: ) apply plugin: ''Īpply plugin: 'kotlin-android-extensions' In this case, it was like the code below. in the individual module adle filesĪnd in your app’s adle file, add Google Services plugin (line #24), Firebase Messaging dependency (line #23), CometChat Push Notification extension (line #20 & #21) and change the applicationId to the package name you added in the Firebase Console when creating the project (line #8). NOTE: Do not place your application dependencies here they belong Now, in your project’s root adle file, copy this line (#12) in the dependencies section like this: // Top-level build file where you can add configuration options common to all sub-projects/modules.Ĭlasspath ':gradle:3.4.0'Ĭlasspath ":kotlin-gradle-plugin:$kotlin_version"Ĭlasspath ":google-services:4.3.2"
Click on the Download google-services.json button and save it in the app directory of your app code. In your case, that service is going to Firebase Messaging Service. This file is the configuration to integrate your app and Firebase and use any Firebase services from your app. This will allow you to download the google-services.json file. You can skip the App Name, Debug Signing Certificate SHA-1 here.
You will be presented with a registration form now.
add add a new Android app by clicking on the android robot icon. Now, as your project becomes ready, you will be redirected the project overview page. On the step 2, uncheck the Enable Google Analytics for this project and click Create Project. Set the name of the project to M圜hatApp or anything you like. Once inside Firebase console, add a new project by clicking on the + Add project button. Go to Firebase Console and create a new account if you don’t have one. To integrate Firebase Messaging, you will need to create a project in Firebase Console.
This tutorial will show you on how to integrate Firebase Messaging Service (FCM) service in your chat apps in a very easy way. There are many different APIs for sending push notifications in Android such OneSignal, Firebase Messaging Service (FCM) etc.
You should update this with your own keys now before moving further with this article.īeside these classes, there are some model files for data holding and some Kotlin extensions to make utility methods easier to use. Strings.xml file contains the CometChat API key and App ID. This is responsible for sending and receiving messages between the users.ĬhatyApp.kt is the main Application class of the whole app and is responsible for initializing the CometChat SDK when the app launches. This also manages the logout functionality of the user.ĬhatActivity.kt handles the chat session of the users. ProfileActivity.kt displays the profile screen with the current logged in user’s name, email, avatar etc.
It fetches all other users data from CometChat Pro and shows in the screen. Once the user is successfully logged in, it opens the Contacts screen.ĬontactsActivity.kt represents the Contacts screen. LoginActivity.kt manages the user login functionality. And if you have your own chat app with your custom code, then you can skip this section.
User can mute or unmute any specific user’s notifications at anytime.īefore getting started, if you have followed the Chaty article, then here’s a basic overview of the code and parts where you will be working in. User don’t receive notifications when the chat between sending user and receiving user is already open. User can receive notifications while app is active and in foreground and either Contacts or Profile or any other chat conversation screen are open. User can receive notifications when app is in background or completely removed from the Recent Apps in Android device. Rather than just simply explaining the basic send/receive push notification, this article is going to explain some practical use-cases implemented in modern chat apps. You can see in the demo GIF that Captain America (left) & Cyclops (right) are sending messages to each other and those messages are being delivered through push notifications of Android devices.