Reputation: 704
Is there a way to change the notification content before it displays on the device? For example: i have a user named John that is subscribed to a topic named food, i send a push notification to that topic with this title "Good morning username", but the device would display "Good morning John"
I wish to know if that is posible on android or iOS and how
Upvotes: 3
Views: 523
Reputation: 923
For Android,
yes, it is possible by overriding onMessageReceived
of FirebaseMessagingService
@Override
public void onMessageReceived(RemoteMessage remoteMessage) {
// Check your notification is not null and subcribed to `food` topic.
if(remoteMessage.getFrom() == "food" &&
remoteMessage.getNotification() != null){
String title = remoteMessage.getNotification().getTitle(); // Title from the notification. E.g `Good morning`
// Get the `username` of the user stored in the device. Use SharedPreference.
String message = title + " " + username; // "Good morning username"
// Call your notification here.
}
}
Upvotes: 1