Skip to content

Commit cabaae6

Browse files
committed
fix(notifications): only add token from Firebase when logged in
Signed-off-by: Brandon McAnsh <git@bmcreations.dev>
1 parent 8728299 commit cabaae6

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

apps/flipcash/shared/notifications/src/main/kotlin/com/flipcash/app/notifications/NotificationService.kt

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -58,13 +58,15 @@ class NotificationService : FirebaseMessagingService(),
5858
super.onNewToken(token)
5959
authenticateIfNeeded {
6060
launch {
61-
pushController.addToken(token)
62-
.onSuccess {
63-
userManager.set(pushToken = token)
64-
trace("push token updated onNewToken", type = TraceType.Silent)
65-
}.onFailure {
66-
trace(message = "Failure updating push token", error = it)
67-
}
61+
if (userManager.state.value.authState.canAccessAuthenticatedApis) {
62+
pushController.addToken(token)
63+
.onSuccess {
64+
userManager.set(pushToken = token)
65+
trace("push token updated onNewToken", type = TraceType.Silent)
66+
}.onFailure {
67+
trace(message = "Failure updating push token", error = it)
68+
}
69+
}
6870
}
6971
}
7072
}

0 commit comments

Comments
 (0)