aboutsummaryrefslogtreecommitdiff
path: root/juick-notifications/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'juick-notifications/src/main')
-rw-r--r--juick-notifications/src/main/java/com/juick/components/FirebaseManager.java28
1 files changed, 14 insertions, 14 deletions
diff --git a/juick-notifications/src/main/java/com/juick/components/FirebaseManager.java b/juick-notifications/src/main/java/com/juick/components/FirebaseManager.java
index 6bab725a..f88f3201 100644
--- a/juick-notifications/src/main/java/com/juick/components/FirebaseManager.java
+++ b/juick-notifications/src/main/java/com/juick/components/FirebaseManager.java
@@ -9,6 +9,7 @@ import com.google.auth.oauth2.GoogleCredentials;
import com.google.firebase.FirebaseApp;
import com.google.firebase.FirebaseOptions;
import com.google.firebase.messaging.FirebaseMessaging;
+import com.google.firebase.messaging.FirebaseMessagingException;
import com.google.firebase.messaging.Message;
import com.juick.ExternalToken;
import com.juick.User;
@@ -73,21 +74,20 @@ public class FirebaseManager implements NotificationListener {
ApiFutures.addCallback(response, new ApiFutureCallback<String>() {
@Override
public void onFailure(Throwable t) {
- logger.warn("Firebase exception", t);
- /*
- List<Result> results = result.getResults();
- for (int i = 0; i < results.size(); i++) {
- Result currentResult = results.get(i);
- logger.info("RES {}: {}", i, currentResult);
- List<String> errorCodes = Arrays.asList(Constants.ERROR_MISMATCH_SENDER_ID, Constants.ERROR_NOT_REGISTERED);
- if (errorCodes.contains(currentResult.getErrorCodeName())) {
- // assuming results are in order of regids
- // http://stackoverflow.com/a/11594531/1097384
- String currentId = regids.get(i);
- logger.info("{} is scheduled to remove", currentId);
- notificationsManager.addInvalidGCMToken(currentId);
+ if (t instanceof FirebaseMessagingException) {
+ FirebaseMessagingException e = (FirebaseMessagingException) t;
+ if (e.getErrorCode().equals("messaging/invalid-argument")
+ || e.getErrorCode().equals("messaging/registration-token-not-registered")
+ || e.getErrorCode().equals("messaging/invalid-registration-token")) {
+ // invalid token
+ logger.info("{} is scheduled to remove", token);
+ notificationsManager.addInvalidGCMToken(token);
+ } else {
+ logger.warn("Unhandled FirebaseMessaging exception", t);
}
- }*/
+ } else {
+ logger.warn("Unhandled FCM exception", t);
+ }
}
@Override