From 391023fe4bb7099cfaacafc6f55f3535cf235d22 Mon Sep 17 00:00:00 2001 From: Tom Sightler Date: Mon, 24 Jun 2024 23:32:20 -0400 Subject: [PATCH] Don't send old FCM tokens --- packages/ring-client-api/api.ts | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/packages/ring-client-api/api.ts b/packages/ring-client-api/api.ts index fd6d14c9..a609cb3e 100644 --- a/packages/ring-client-api/api.ts +++ b/packages/ring-client-api/api.ts @@ -232,17 +232,16 @@ export class RingApi extends Subscribed { cameras: RingCamera[], intercoms: RingIntercom[], ) { - const credentials = - this.restClient._internalOnly_pushNotificationCredentials?.config && - this.restClient._internalOnly_pushNotificationCredentials, - pushReceiver = new PushReceiver({ + const pushReceiver = new PushReceiver({ firebase: { apiKey: 'AIzaSyCv-hdFBmmdBBJadNy-TFwB-xN_H5m3Bk8', projectId: 'ring-17770', messagingSenderId: '876313859327', // for Ring android app. 703521446232 for ring-site appId: '1:876313859327:android:e10ec6ddb3c81f39', }, - credentials, + credentials: + this.restClient._internalOnly_pushNotificationCredentials?.config && + this.restClient._internalOnly_pushNotificationCredentials, debug: false, }), devicesById: { [id: number]: RingCamera | RingIntercom | undefined } = {}, @@ -359,8 +358,11 @@ export class RingApi extends Subscribed { }) // If we already have credentials, use them immediately - if (credentials) { - onPushNotificationToken.next(credentials.fcm.token) + if (this.restClient._internalOnly_pushNotificationCredentials?.fcm?.token) { + // Use the source in case credentials were updated prior to + onPushNotificationToken.next( + this.restClient._internalOnly_pushNotificationCredentials.fcm.token, + ) } }