Send a notification from one user to another using Firebase.
Add firebase messaging library:
implementation 'com.google.firebase:firebase-messaging-ktx:23.0.0'
Add this lines:
biuld.gradle(app)
plugins {
...
id 'com.google.gms.google-services'
}
biuld.gradle(Project)
plugins {
...
id 'com.google.gms.google-services' version '4.3.10' apply false
}
To use Firebase in your Android app, you need to register your app with your Firebase project. Registering your app is often called "adding" your app to your project.
Download and put google-serveces.json into project:
Get your Server key from firebase console and put here.
interface ApiService {
@Headers(
"Content-Type:application/json",
"Authorization:key=your_Server_key"
@POST("fcm/send")
fun sendNotifcation(@Body body: Response?): Call<MyResponse?>?
}