-1

I want to send notification using firebase to only one user and his token is saved in firebase batabase. I will retrieve data this token from database but how can send notification to that user.

 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) {

        }
    });

If someone know other technique to send notification rather than firebase he/she can tell me.

Atif Rizwan
  • 645
  • 2
  • 8
  • 17

1 Answers1

1

You can't use the the Firebase Auth uid as a target for FCM. You have to use the registration token.

What I would do is use Firebase DB, save the uid along with the token in a push_tokens node like:

push_tokens
    - <uid>: <registration_token>

Having only the corresponding users to read the tokens (like your server), and use it accordingly.

AL.
  • 36,815
  • 10
  • 142
  • 281