How to send notification based on role. For example if I have 5 different roles I select only one role then that role people should get notifications using FCM and remaining role should not get for this. Do we need to write service in back-end(using SPRING,PHP)?
The easiest way to accomplish this is to subscribe each client to a topic based on their role. For example in the Android app:
FirebaseMessaging.getInstance().subscribeToTopic("myRole");
Then you can send a message to all users in a role with the Firebase Admin SDK with:
admin.messaging().sendToTopic("myRole", {
"notification" : {
"body" : "great match!",
"title" : "Portugal vs. Denmark"
}
})
A few things to note: