Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -85,25 +85,25 @@ public void onRun() throws Exception {

Log.i(TAG, "Reregistering FCM...");

int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
Optional<String> token = FcmUtil.getToken(context);

if (result != ConnectionResult.SUCCESS) {
notifyFcmFailure();
} else {
Optional<String> token = FcmUtil.getToken(context);

if (token.isPresent()) {
String oldToken = SignalStore.account().getFcmToken();
if (token.isPresent()) {
String oldToken = SignalStore.account().getFcmToken();

if (!token.get().equals(oldToken)) {
int oldLength = oldToken != null ? oldToken.length() : -1;
Log.i(TAG, "Token changed. oldLength: " + oldLength + " newLength: " + token.get().length());
} else {
Log.i(TAG, "Token didn't change.");
}
if (!token.get().equals(oldToken)) {
int oldLength = oldToken != null ? oldToken.length() : -1;
Log.i(TAG, "Token changed. oldLength: " + oldLength + " newLength: " + token.get().length());
} else {
Log.i(TAG, "Token didn't change.");
}

NetworkResultUtil.toBasicLegacy(SignalNetwork.account().setFcmToken(token.get()));
SignalStore.account().setFcmToken(token.get());
NetworkResultUtil.toBasicLegacy(SignalNetwork.account().setFcmToken(token.get()));
SignalStore.account().setFcmToken(token.get());
} else {
int result = GoogleApiAvailability.getInstance().isGooglePlayServicesAvailable(context);
if (result != ConnectionResult.SUCCESS) {
Log.w(TAG, "FCM token retrieval failed, and Play Services are not available. Code: " + result);
notifyFcmFailure();
} else {
throw new RetryLaterException(new IOException("Failed to retrieve a token."));
}
Expand Down