Browse Source
Merge pull request #10679 from thingsboard/fix/firebase-senderid-mismatch
Improve mobile notifications stability
pull/10683/head
Viacheslav Klimov
2 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with
2 additions and
1 deletions
-
application/src/main/java/org/thingsboard/server/service/notification/channels/MobileAppNotificationChannel.java
|
|
|
@ -105,9 +105,10 @@ public class MobileAppNotificationChannel implements NotificationChannel<User, M |
|
|
|
firebaseService.sendMessage(ctx.getTenantId(), credentials, token, subject, body, data, unreadCount); |
|
|
|
} catch (FirebaseMessagingException e) { |
|
|
|
MessagingErrorCode errorCode = e.getMessagingErrorCode(); |
|
|
|
if (errorCode == MessagingErrorCode.UNREGISTERED || errorCode == MessagingErrorCode.INVALID_ARGUMENT) { |
|
|
|
if (errorCode == MessagingErrorCode.UNREGISTERED || errorCode == MessagingErrorCode.INVALID_ARGUMENT || errorCode == MessagingErrorCode.SENDER_ID_MISMATCH) { |
|
|
|
validTokens.remove(token); |
|
|
|
userService.removeMobileSession(recipient.getTenantId(), token); |
|
|
|
log.debug("[{}][{}] Removed invalid FCM token due to {} {} ({})", recipient.getTenantId(), recipient.getId(), errorCode, e.getMessage(), token); |
|
|
|
continue; |
|
|
|
} |
|
|
|
throw new RuntimeException("Failed to send message via FCM: " + e.getMessage(), e); |
|
|
|
|