A
A
adilka2017-05-30 21:18:44
Android
adilka, 2017-05-30 21:18:44

How to solve the problem about firebase tokens?

Hello, I had some error: on some versions of api, mostly old ones, the application crashes, complains about this line, where I connect to the firebase database to save information on the user's registration token:

databaseReference = FirebaseDatabase.getInstance().getReference(FirebaseInstanceId.getInstance().getToken());

writes that
Argument 'FirebaseInstanceId.getInstance().getToken()' might be null

As I understand it, at the moment the program accesses this line, databaseRefernce returns an empty value, please tell me how to solve the problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
adilka, 2017-05-31
@adilka

I had to add a simple check:

String token = FirebaseInstanceId.getInstance().getToken();
        if (token == null) return;
        databaseReference = FirebaseDatabase.getInstance().getReference(token);

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question