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 <tom.sightler@veeam.com>
  • Loading branch information
2 people authored and dgreif committed Jul 23, 2024
1 parent cd6be9a commit 0d93c93
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/beige-pianos-double.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'homebridge-ring': patch
'ring-client-api': patch
---

Handle push-receiver credentials upon first startup after upgrading
11 changes: 8 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,12 @@ 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 &&
credentials?.fcm?.token ===
this.restClient._internalOnly_pushNotificationCredentials?.fcm?.token
) {
onPushNotificationToken.next(credentials.fcm.token)
}
}
Expand Down

0 comments on commit 0d93c93

Please sign in to comment.