如果我偏好用户是否要启用通知。我应该发送哪个事件,以便在发送通知时可以排除此用户?
答案 0 :(得分:0)
在 onMessageReceived 方法上,尝试验证在SharedPReferences中是否有通知(bool)= true。
@Override
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.
}
来自:https://firebase.google.com/docs/notifications/android/console-audience