From e197e7edadacbeacf3506e35438f48aac2945454 Mon Sep 17 00:00:00 2001 From: Jeff Swartz Date: Wed, 6 Mar 2024 11:26:56 -0800 Subject: [PATCH 1/2] Fix TypeScript definitions (issue #725) --- @types/index.d.ts | 6 +++--- CHANGELOG.md | 4 ++++ package-lock.json | 4 ++-- package.json | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/@types/index.d.ts b/@types/index.d.ts index 88996909..b96dc71a 100644 --- a/@types/index.d.ts +++ b/@types/index.d.ts @@ -475,7 +475,7 @@ declare module "opentok-react-native" { /** * Sent when the publisher stops sending video because of publisher audio fallback (see https://tokbox.com/developer/guides/audio-fallback). */ - videoDisabled?: CallbackWithParam<{reason: string}>; + videoDisabled?: CallbackWithParam<{reason: string}, any>; /** * Sent when the publisher is close to going to audio-only fallback becuase of declining network conditions (see https://tokbox.com/developer/guides/audio-fallback). @@ -637,12 +637,12 @@ declare module "opentok-react-native" { /** * This message is sent when the OpenTok Media Router determines that the stream quality has degraded and the video will be disabled if the quality degrades further. If the quality degrades further, the subscriber disables the video and the videoDisabled message is sent. If the stream quality improves, the videoDisableWarningLifted message is sent. */ - videoDisableWarning?: CallbackWithParam<{stream: Stream}); + videoDisableWarning?: CallbackWithParam<{stream: Stream}, any>; /** * This message is sent when the subscriber’s video stream starts (when there previously was no video) or resumes (after video was disabled). Check the reason parameter for the reason why the video started (or resumed). */ - videoDisableWarningLifted?: CallbackWithParam<{stream: Stream}); + videoDisableWarningLifted?: CallbackWithParam<{stream: Stream}, any>; /** * This message is sent when the subscriber’s video stream starts (when there previously was no video) or resumes (after video was disabled). Check the reason parameter for the reason why the video started (or resumed). diff --git a/CHANGELOG.md b/CHANGELOG.md index 65082d12..4a4de56b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +# 2.27.1 (March 2024) + +- [Fix]: Fixes some TypeScript definitions (issue #725). + # 2.27.0 (March 2024) - [Update]: Update OpenTok Android SDK and OpenTok iOS SDK to version 2.27.0. diff --git a/package-lock.json b/package-lock.json index 7e41b213..32cd06db 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "opentok-react-native", - "version": "2.27.0", + "version": "2.27.1", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "opentok-react-native", - "version": "2.27.0", + "version": "2.27.1", "license": "MIT", "dependencies": { "axios": "^1.6.5", diff --git a/package.json b/package.json index 3d0bfd31..aecfde99 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "opentok-react-native", - "version": "2.27.0", + "version": "2.27.1", "description": "React Native components for OpenTok iOS and Android SDKs", "main": "src/index.js", "homepage": "https://www.tokbox.com", From 0322ac5c196b43e740d35da3267e923c84c18df8 Mon Sep 17 00:00:00 2001 From: Jeff Swartz Date: Thu, 14 Mar 2024 10:23:53 -0700 Subject: [PATCH 2/2] Fix Android publisher permissions and videoTrack setting (issue #652) (#727) * Fix OTPublisher permissions issue on Android * Fix OTPublisher videoTrack property in Android (issue #652) --- CHANGELOG.md | 17 +++++++++++++++++ .../opentokreactnative/OTSessionManager.java | 2 +- src/OT.js | 10 ++++++---- src/OTPublisher.js | 11 ++++++----- 4 files changed, 30 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4a4de56b..c7b28ccb 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,22 @@ # 2.27.1 (March 2024) +- [Fix]: On Android, OTPublisher components failed with an error when either `PermissionsAndroid.PERMISSIONS.CAMERA` or `PermissionsAndroid.PERMISSIONS.RECORD_AUDIO` were not `true`. This version fixes that, by having audio-only or video-only publishers skip the `PermissionsAndroid.PERMISSIONS.CAMERA` or `PermissionsAndroid.PERMISSIONS.RECORD_AUDIO` check if the `videoTrack` or `audioTrack` property of the `properties` prop of the OTPublisher component is set to `false`. You can set these props to `false` based on these permissions: + +```jsx +import { PermissionsAndroid } from 'react-native'; +// ... + + +``` + +*Note:* In Android 6.0 (`API Level 23`) and higher, the OpenTok React Native SDK automatically adds these permissions. However, an app or user can disable them independently of the SDK. + +- [Fix]: On Android, setting the `videoTrack` property of the `properties` prop of the OTPublisher component `false` resulted in the app to crash. This version fixes the issue (issue #652). + - [Fix]: Fixes some TypeScript definitions (issue #725). # 2.27.0 (March 2024) diff --git a/android/src/main/java/com/opentokreactnative/OTSessionManager.java b/android/src/main/java/com/opentokreactnative/OTSessionManager.java index 8b43f9b6..226206b9 100644 --- a/android/src/main/java/com/opentokreactnative/OTSessionManager.java +++ b/android/src/main/java/com/opentokreactnative/OTSessionManager.java @@ -202,7 +202,7 @@ public void initPublisher(String publisherId, ReadableMap properties, Callback c if (cameraPosition.equals("back")) { mPublisher.cycleCamera(); } - if (mPublisher.getCapturer() != null) { + if (videoTrack && mPublisher.getCapturer() != null) { mPublisher.getCapturer().setVideoContentHint(Utils.convertVideoContentHint(properties.getString("videoContentHint"))); } } diff --git a/src/OT.js b/src/OT.js index 9fd74e90..ed0ad59c 100644 --- a/src/OT.js +++ b/src/OT.js @@ -4,10 +4,12 @@ import { each } from 'underscore'; const OT = NativeModules.OTSessionManager; const nativeEvents = new NativeEventEmitter(OT); -const checkAndroidPermissions = () => new Promise((resolve, reject) => { - PermissionsAndroid.requestMultiple([ - PermissionsAndroid.PERMISSIONS.CAMERA, - PermissionsAndroid.PERMISSIONS.RECORD_AUDIO]) +const checkAndroidPermissions = (audioTrack, videoTrack) => new Promise((resolve, reject) => { + const permissionsToCheck = [ + ... audioTrack ? [PermissionsAndroid.PERMISSIONS.RECORD_AUDIO] : [], + ... videoTrack ? [PermissionsAndroid.PERMISSIONS.CAMERA] : [], + ]; + PermissionsAndroid.requestMultiple(permissionsToCheck) .then((result) => { const permissionsError = {}; permissionsError.permissionsDenied = []; diff --git a/src/OTPublisher.js b/src/OTPublisher.js index 4bec9574..c73fcd2e 100644 --- a/src/OTPublisher.js +++ b/src/OTPublisher.js @@ -99,20 +99,21 @@ class OTPublisher extends Component { } }; createPublisher() { + const publisherProperties = sanitizeProperties(this.props.properties); if (Platform.OS === 'android') { - checkAndroidPermissions() + const { audioTrack, videoTrack } = publisherProperties; + checkAndroidPermissions(audioTrack, videoTrack) .then(() => { - this.initPublisher(); + this.initPublisher(publisherProperties); }) .catch((error) => { this.otrnEventHandler(error); }); } else { - this.initPublisher(); + this.initPublisher(publisherProperties); } } - initPublisher() { - const publisherProperties = sanitizeProperties(this.props.properties); + initPublisher(publisherProperties) { OT.initPublisher( this.state.publisherId, publisherProperties,