fix: forcing the registration will cancel and restart the FCM task

This commit is contained in:
jubb 2021-03-03 15:43:51 +11:00
parent 1b417362ae
commit 1ecc87da76

View File

@ -447,7 +447,10 @@ public class ApplicationContext extends MultiDexApplication implements Dependenc
} }
public void registerForFCMIfNeeded(final Boolean force) { public void registerForFCMIfNeeded(final Boolean force) {
if (firebaseInstanceIdJob != null && firebaseInstanceIdJob.isActive()) return; if (firebaseInstanceIdJob != null && firebaseInstanceIdJob.isActive() && !force) return;
if (force && firebaseInstanceIdJob != null) {
firebaseInstanceIdJob.cancel(null);
}
firebaseInstanceIdJob = FcmUtils.getFcmInstanceId(task->{ firebaseInstanceIdJob = FcmUtils.getFcmInstanceId(task->{
if (!task.isSuccessful()) { if (!task.isSuccessful()) {
Log.w("Loki", "FirebaseInstanceId.getInstance().getInstanceId() failed." + task.getException()); Log.w("Loki", "FirebaseInstanceId.getInstance().getInstanceId() failed." + task.getException());