ywj7931 ywj7931 - 1 year ago 122
Android Question

Firebase android audience

If I have a preference of whether the user wants to enable notification or not. Which event should I send so that I can exclude this user when sending the notification?

Answer Source

On the onMessageReceived method, try to validase if in SharedPReferences has a notifications (bool) = true.

public void onMessageReceived(RemoteMessage remoteMessage) {
// ...

// TODO(developer): Handle FCM messages here.
// Not getting messages here? See why this may be
Log.d(TAG, "From: " + remoteMessage.getFrom());

// Check if message contains a data payload.
if (remoteMessage.getData().size() > 0) {
    Log.d(TAG, "Message data payload: " + remoteMessage.getData());

// Check if message contains a notification payload.
if (remoteMessage.getNotification() != null) {
    Log.d(TAG, "Message Notification Body: " + remoteMessage.getNotification().getBody());

// Also if you intend on generating your own notifications as a result of a received FCM
// message, here is where that should be initiated. See sendNotification method below.

From: https://firebase.google.com/docs/notifications/android/console-audience

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download