Firebase android观众

问题描述:

如果我对用户是否希望启用通知有所偏好。我应该发送哪个事件,以便在发送通知时排除此用户?Firebase android观众

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

+0

现在看来,这是对前景的使用,如果应用程序是在后台将无法正常工作。我决定改用用户段,使用setUserProperty(“ifNotification”,“false”); – ywj7931