Marco
Marco

Reputation: 560

FCM sending notification to specific device from server without client code modification

I'm using FirebaseAdmin and FirebaseMessaging on my server to send notification to specific devices with an Fcm Token

 Message message = Message.builder()
                             .putData("body", "Body)
                             .putData("title", "Title")
                             .setToken(fcmToken).build();
  FirebaseMessaging.getInstance().sendAsync(message).get();

Server side the notification is sent correctly, no error however client side the notification does not pop-up.

Is it mandatory client side to implement the "com.google.firebase.MESSAGING_EVENT" when sending notification to specific devices ?

Because I do not need to add anything when I send notification from the Firebase Cloud Messaging screen.

Upvotes: 1

Views: 543

Answers (1)

Kushan
Kushan

Reputation: 5984

You will need to implement the FirebaseMessagingService in order to receive the notification. You can avoid this by sending a Notification tag instead of the data tag that you are currently using.

Note: if it's a notification tag push, it will be handled by system only if the application is not in foreground. If the app is in foreground, you will have to again handle it manually using your own code in the above mentioned service

Upvotes: 1

Related Questions