0
如果我對用戶是否希望啓用通知有所偏好。我應該發送哪個事件,以便在發送通知時排除此用戶?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
現在看來,這是對前景的使用,如果應用程序是在後臺將無法正常工作。我決定改用用戶段,使用setUserProperty(「ifNotification」,「false」); – ywj7931