使用Firebase身份验证身份仅向一位用户发送通知

时间:2017-07-22 16:40:21

标签: android firebase-authentication firebase-cloud-messaging firebase-notifications

我想使用firebase向一个用户发送通知,他的令牌保存在firebase batabase中。我将从数据库中检索此令牌的数据,但如何向该用户发送通知。

 refForLeaveReq.addValueEventListener(new ValueEventListener() {
        @Override
        public void onDataChange(DataSnapshot dataSnapshot) {
            // Here i want to send Notification to only one user and his id is 7bvftaksdyej2383dnd4jdbek4dksb3kdh
        }

        @Override
        public void onCancelled(DatabaseError databaseError) {

        }
    });

如果有人知道发送通知的其他技巧而不是firebase,他/她可以告诉我。

1 个答案:

答案 0 :(得分:1)

您无法使用Firebase Auth uid作为FCM的目标。您必须使用注册令牌

我要做的是使用Firebase DB,将uid与令牌一起保存在push_tokens节点中,如:

push_tokens
    - <uid>: <registration_token>

只有相应的用户才能阅读令牌(如服务器),并相应地使用它。

相关问题