Skip to content

Commit

Permalink
Don't send old FCM tokens when new token is generated during startup (#…
Browse files Browse the repository at this point in the history
…1440)

Co-authored-by: Tom Sightler <[email protected]>
  • Loading branch information
tsightler and Tom Sightler authored Jul 23, 2024
1 parent cd6be9a commit 39536a7
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/ring-client-api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ export class RingApi extends Subscribed {
intercoms: RingIntercom[],
) {
const credentials =
this.restClient._internalOnly_pushNotificationCredentials?.config &&
this.restClient._internalOnly_pushNotificationCredentials,
pushReceiver = new PushReceiver({
firebase: {
Expand All @@ -241,7 +242,7 @@ export class RingApi extends Subscribed {
messagingSenderId: '876313859327', // for Ring android app. 703521446232 for ring-site
appId: '1:876313859327:android:e10ec6ddb3c81f39',
},
credentials: credentials?.config ? credentials : undefined,
credentials,
debug: false,
}),
devicesById: { [id: number]: RingCamera | RingIntercom | undefined } = {},
Expand Down Expand Up @@ -358,8 +359,11 @@ export class RingApi extends Subscribed {
}
})

// If we already have credentials, use them immediately
if (credentials) {
// If we already have credentials and they haven't been changed during registration, use them immediately
if (
credentials?.fcm?.token ===
this.restClient._internalOnly_pushNotificationCredentials?.fcm?.token
) {
onPushNotificationToken.next(credentials.fcm.token)
}
}
Expand Down

0 comments on commit 39536a7

Please sign in to comment.