diff --git a/lib/4nk/MessageBus.ts b/lib/4nk/MessageBus.ts index 9f3d5a1..adae0ff 100644 --- a/lib/4nk/MessageBus.ts +++ b/lib/4nk/MessageBus.ts @@ -61,8 +61,19 @@ export default class MessageBus { } unsubscribe(); this.destroyMessageListener(); + + // Connect with tokens first UserStore.getInstance().connect(accessToken, refreshToken); - resolve(); + + // Then get and set the pairing ID + this.getUserPairingId().then((pairingId: string) => { + UserStore.getInstance().pair(pairingId); + resolve(); + }).catch((error: string) => { + console.error('Failed to get pairing ID after authentication:', error); + // Still resolve since the main authentication succeeded + resolve(); + }); }); const unsubscribeError = EventBus.getInstance().on('ERROR_LINK_ACCEPTED', (responseId: string, error: string) => {