If you are still using old style to get FireBase token, it is time to change it.

Old way

String token = FirebaseInstanceId.getInstance().getToken();

New way

FirebaseInstanceId.getInstance().getInstanceId()
				.addOnCompleteListener(new OnCompleteListener<InstanceIdResult>() {
					@Override
					public void onComplete(@NonNull Task<InstanceIdResult> task) {
						if (!task.isSuccessful()) {
							Log.w("FB token e: ", "getInstanceId failed", task.getException());
							return;
						}

						// Get new Instance ID token
						String token = task.getResult().getToken();
						Log.d("FB token", token);
						if (!token.equals("")) {
// send to your server						}
					}
				});
Spread the love

Leave a comment