【问题标题】:Send notification to only one user using his Firebase Auth id使用 Firebase Auth id 仅向一位用户发送通知
【发布时间】:2017-07-22 16:40:21
【问题描述】:

我想使用 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 的其他技术,他/她可以告诉我。

【问题讨论】:

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


    【解决方案1】:

    您不能将 Firebase 身份验证 uid 用作 FCM 的目标。您必须使用注册令牌

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

    push_tokens
        - <uid>: <registration_token>
    

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

    【讨论】:

    • 但是如何使用这个令牌发送通知
    • 就像我在回答中所说,你不能
    • 注册令牌在哪里找到?
    猜你喜欢
    • 2019-11-20
    • 1970-01-01
    • 2023-03-29
    • 2017-12-21
    • 2019-08-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多