【问题标题】:Firebase android audienceFirebase 安卓观众
【发布时间】:2016-11-08 23:21:17
【问题描述】:

如果我偏好用户是否要启用通知。我应该发送哪个事件,以便在发送通知时排除该用户?

【问题讨论】:

    标签: android firebase firebase-notifications


    【解决方案1】:

    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");
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-06-27
    • 2023-03-12
    • 1970-01-01
    • 1970-01-01
    • 2018-06-24
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多