Skip to content

Instantly share code, notes, and snippets.

@ssniks
ssniks / Curl Request
Created May 6, 2022 14:44
Sending push notification by fcm api
curl --location --request POST 'https://fcm.googleapis.com/fcm/send' \
--header 'Authorization: key=XXX' \
--header 'Content-Type: application/json' \
--data-raw '{
"notification" : {
"title": "Title of Your Notification",
"body" : "Body of Your Notification"
},
"data": {
"custom_key": "XXXX"
import android.app.NotificationChannel
import android.app.NotificationManager
import android.content.Context
import android.os.Build
import android.util.Log
import androidx.core.app.NotificationCompat
import com.google.firebase.messaging.FirebaseMessagingService
import com.google.firebase.messaging.RemoteMessage
class MyFirebaseMessagingService : FirebaseMessagingService() {
@ssniks
ssniks / build.gradle
Last active May 6, 2022 14:27
App level gradle
//project/appmodule/build.gradle
// Add this line
apply plugin: 'com.google.gms.google-services'
dependencies {
implementation("com.google.firebase:firebase-messaging:20.0.0")
}
@ssniks
ssniks / build.gradle
Last active May 6, 2022 14:25
Project level gradle
buildscript {
repositories {
// Check that you have the following line (if not, add it):
google() // Google's Maven repository
}
dependencies {
...
// Add this line
classpath 'com.google.gms:google-services:4.3.10'
}