diff --git a/.changeset/beige-pianos-double.md b/.changeset/beige-pianos-double.md new file mode 100644 index 00000000..1273c13b --- /dev/null +++ b/.changeset/beige-pianos-double.md @@ -0,0 +1,6 @@ +--- +'homebridge-ring': patch +'ring-client-api': patch +--- + +Handle push-receiver credentials upon first startup after upgrading diff --git a/packages/ring-client-api/api.ts b/packages/ring-client-api/api.ts index d6d577fc..d57f196d 100644 --- a/packages/ring-client-api/api.ts +++ b/packages/ring-client-api/api.ts @@ -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: { @@ -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 } = {}, @@ -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) } }