diff --git a/common/config/rush/pnpm-lock.yaml b/common/config/rush/pnpm-lock.yaml index ad41c4653fe4..fadb4fb3cbc9 100644 --- a/common/config/rush/pnpm-lock.yaml +++ b/common/config/rush/pnpm-lock.yaml @@ -134,7 +134,7 @@ packages: dev: false resolution: integrity: sha512-8v+3YtATbaFv5qMGvhFVR+qx1QPc1+NBy2MWWoJ69SmEE1X91ySvXDbEa0Pr7znm/bqbBYWOLJN5L3Aa7Q0fpg== - /@azure/communication-signaling/1.0.0-beta.3: + /@azure/communication-signaling/1.0.0-beta.5: dependencies: '@azure/core-http': 1.2.4 '@azure/core-tracing': 1.0.0-preview.9 @@ -146,7 +146,7 @@ packages: engines: node: '>=8.0.0' resolution: - integrity: sha512-WargzA8PMc9SEvQpjhM0vVq/HB0wGUScplW8Us9nEFLHy/ZvgVjbRHlCALCa/tlU/Pv3RgZhk7XuPfwip17MCQ== + integrity: sha512-pGXI4F5OVzdM9Omg5fiflA/Vvs88qqER/ZxNj3PoWAdaYIPkWGb86OClbB0VsHi6gZ4ZDzyTP/l9hrREBuBYRA== /@azure/core-amqp/2.2.0: dependencies: '@azure/abort-controller': 1.0.4 @@ -8129,7 +8129,7 @@ packages: version: 0.0.0 file:projects/communication-chat.tgz: dependencies: - '@azure/communication-signaling': 1.0.0-beta.3 + '@azure/communication-signaling': 1.0.0-beta.5 '@azure/core-tracing': 1.0.0-preview.11 '@microsoft/api-extractor': 7.7.11 '@rollup/plugin-commonjs': 11.0.2_rollup@1.32.1 @@ -8179,7 +8179,7 @@ packages: dev: false name: '@rush-temp/communication-chat' resolution: - integrity: sha512-msX+ilu4T1qt+42YXKajobqKgqDulCHJhnPH4qRjnQNzWmFUsXjLPp2Zef9QluTUP/i1h4kmBtxQGdjpFE60qA== + integrity: sha512-mIhPKfBG7zkiDNgm9pK3S1QefIz47oyQWoBEF4gCWCsH53eV2p5e+xD+/Vfenj9BAn2rx41TzYUiorYbQgFidg== tarball: file:projects/communication-chat.tgz version: 0.0.0 file:projects/communication-common.tgz: @@ -9062,7 +9062,7 @@ packages: dev: false name: '@rush-temp/cosmos' resolution: - integrity: sha512-/8qOC/V8y69zIekhbyW9qcgapO8Gr4csxVV9jeRJ3bqGevunFJ2wr9DaVxx34ztDmQqvQE5I6L0/lSopgQpMuA== + integrity: sha512-zr5rSxxyf9pXAedweom+O1DR8GDklyAWW4QOyHiqd18Ja4FuQ6dPJiRejNVOyg6SE4xSl6cbf8agjPfG3upEnQ== tarball: file:projects/cosmos.tgz version: 0.0.0 file:projects/data-tables.tgz: diff --git a/sdk/communication/communication-chat/CHANGELOG.md b/sdk/communication/communication-chat/CHANGELOG.md index ba785d1ed976..88d7f4cb7002 100644 --- a/sdk/communication/communication-chat/CHANGELOG.md +++ b/sdk/communication/communication-chat/CHANGELOG.md @@ -2,6 +2,8 @@ ## 1.0.1 (Unreleased) +- Updated to @azure/communication-signaling@1.0.0-beta.5. +- Enabled real-time notification for React Native. ## 1.0.0 (2021-03-29) diff --git a/sdk/communication/communication-chat/package.json b/sdk/communication/communication-chat/package.json index 58b68003fbe9..b7718a5aacce 100644 --- a/sdk/communication/communication-chat/package.json +++ b/sdk/communication/communication-chat/package.json @@ -68,7 +68,7 @@ "dependencies": { "@azure/abort-controller": "^1.0.0", "@azure/communication-common": "^1.0.0", - "@azure/communication-signaling": "1.0.0-beta.3", + "@azure/communication-signaling": "1.0.0-beta.5", "@azure/core-auth": "^1.3.0", "@azure/core-http": "^1.2.0", "@azure/core-tracing": "1.0.0-preview.11", diff --git a/sdk/communication/communication-chat/src/chatClient.ts b/sdk/communication/communication-chat/src/chatClient.ts index a8f32d9f7d2f..0cf6c4e6eb69 100644 --- a/sdk/communication/communication-chat/src/chatClient.ts +++ b/sdk/communication/communication-chat/src/chatClient.ts @@ -251,7 +251,7 @@ export class ChatClient { */ public async startRealtimeNotifications(): Promise { if (this.signalingClient === undefined) { - throw new Error("Realtime notifications are only supported in the browser."); + throw new Error("Realtime notifications are not supported in node js."); } if (this.isRealtimeNotificationsStarted) { @@ -269,7 +269,7 @@ export class ChatClient { */ public async stopRealtimeNotifications(): Promise { if (this.signalingClient === undefined) { - throw new Error("Realtime notifications are only supported in the browser."); + throw new Error("Realtime notifications are not supported in node js."); } this.isRealtimeNotificationsStarted = false; diff --git a/sdk/communication/communication-chat/src/shims.d.ts b/sdk/communication/communication-chat/src/shims.d.ts new file mode 100644 index 000000000000..f17ed26bf186 --- /dev/null +++ b/sdk/communication/communication-chat/src/shims.d.ts @@ -0,0 +1,11 @@ +// Copyright (c) Microsoft Corporation. +// Licensed under the MIT license. + +// d.ts shims provide types for things we use internally but are not part +// of this package's surface area. + +// Shim for DOM's navigator's product status +interface Navigator { + readonly product: string; +} +declare let navigator: Navigator; diff --git a/sdk/communication/communication-chat/src/signaling/signalingClient.ts b/sdk/communication/communication-chat/src/signaling/signalingClient.ts index c26fdf756930..2128c5141b36 100644 --- a/sdk/communication/communication-chat/src/signaling/signalingClient.ts +++ b/sdk/communication/communication-chat/src/signaling/signalingClient.ts @@ -1,13 +1,19 @@ // Copyright (c) Microsoft Corporation. // Licensed under the MIT license. -import { SignalingClient } from "@azure/communication-signaling"; +import { CommunicationSignalingClient, SignalingClient } from "@azure/communication-signaling"; import { CommunicationTokenCredential } from "@azure/communication-common"; import { AzureLogger } from "@azure/logger"; export const getSignalingClient = ( - _credential: CommunicationTokenCredential, - _logger: AzureLogger + credential: CommunicationTokenCredential, + logger: AzureLogger ): SignalingClient | undefined => { + if (typeof navigator !== "undefined" && navigator.product === "ReactNative") { + // In React Native + return new CommunicationSignalingClient(credential, logger); + } + + // In node js return undefined; };