Skip to content

Commit

Permalink
refactor(react-native): remove device info lib (#1056)
Browse files Browse the repository at this point in the history
  • Loading branch information
santhoshvai authored Sep 5, 2023
1 parent 2eecce6 commit 5f7662d
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ yarn add @stream-io/video-react-native-sdk
Stream Video React Native SDK requires installing some peer dependencies to provide you with a great calling experience. You can run the following command to install them:

```bash title=Terminal
yarn add @stream-io/react-native-webrtc react-native-device-info \
yarn add @stream-io/react-native-webrtc \
react-native-incall-manager react-native-svg \
@react-native-community/netinfo @notifee/react-native
npx pod-install
Expand All @@ -31,7 +31,6 @@ So what did we install precisely?

- `@stream-io/video-react-native-sdk` (SVRN) is Stream's Video SDK which contains UI components, hooks and util functions that will enable audio/video calls.
- `@stream-io/react-native-webrtc` is a WebRTC module for React Native, SVRN depends on this dependency, it's components and utilities to render audio/video tracks and interact with the phone's media devices.
- `react-native-device-info` is responsible for retrieving device info and sending it to the Stream Video servers.
- `react-native-incall-manager` handles media-routes/sensors/events during an audio/video call.
- `react-native-svg` provides SVG support to React Native, SVRN's components and it's icons are reliant on this dependency.
- `@react-native-community/netinfo` - is used to detect the device's connectivity state, type and quality.
Expand Down
2 changes: 0 additions & 2 deletions packages/react-native-sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@
"react": ">=17.0.0",
"react-native": ">=0.67.0",
"react-native-callkeep": ">=4.3.11",
"react-native-device-info": ">=10.6.0",
"react-native-gesture-handler": ">=2.8.0",
"react-native-incall-manager": ">=4.1.0",
"react-native-reanimated": ">=2.7.0",
Expand Down Expand Up @@ -104,7 +103,6 @@
"jest": "^29.5.0",
"react-native": "0.71.8",
"react-native-callkeep": "4.3.11",
"react-native-device-info": "^10.6.0",
"react-native-gesture-handler": "2.8.0",
"react-native-incall-manager": "^4.0.0",
"react-native-reanimated": "2.7.0",
Expand Down
41 changes: 32 additions & 9 deletions packages/react-native-sdk/src/utils/setClientDetails.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import {
} from '@stream-io/video-client';
import { Platform } from 'react-native';
import { version } from '../../version';
import RNDeviceInfo from 'react-native-device-info';

const [major, minor, patch] = version.split('.');

Expand All @@ -18,19 +17,43 @@ export const setClientDetails = () => {
patch,
});

const deviceInfo = RNDeviceInfo;
let osName: string = Platform.OS;
if (Platform.OS === 'ios') {
// example: "iOS" | "iPadOS"
osName = Platform.constants.systemName;
}

let osVersion = '';
if (Platform.OS === 'android') {
// example: "33" - its more OS API level than consumer version
osVersion = Platform.constants.Version.toString();
} else if (Platform.OS === 'ios') {
// example: "16.2"
osVersion = Platform.constants.osVersion;
}

setOSInfo({
name: Platform.OS,
version: deviceInfo.getSystemVersion(),
architecture: deviceInfo.supportedAbisSync().join(','),
name: osName,
version: osVersion,
architecture: '',
});

let deviceName = '';
if (Platform.OS === 'android') {
// Example: "Google Pixel 7"
const prefix =
Platform.constants.Manufacturer.toLowerCase() ===
Platform.constants.Brand.toLowerCase()
? Platform.constants.Manufacturer
: `${Platform.constants.Manufacturer} ${Platform.constants.Brand}`;
deviceName = `${prefix} ${Platform.constants.Model}`;
} else if (Platform.OS === 'ios') {
// note: osName check is necessary because Platform.isPad is not reliable
deviceName = Platform.isPad || osName === 'iPadOS' ? 'iPad' : 'iPhone';
}

setDeviceInfo({
// Apple iPhone SE Handset, Google sdk_gphone64_x86_64 Handset
name: `${deviceInfo.getManufacturerSync()} ${
deviceInfo.getModel() ?? deviceInfo.getDeviceId()
} ${deviceInfo.getDeviceType()}`,
name: deviceName,
version: '',
});
};
10 changes: 2 additions & 8 deletions sample-apps/react-native/dogfood/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -526,8 +526,6 @@ PODS:
- React
- RNCClipboard (1.11.2):
- React-Core
- RNDeviceInfo (10.6.0):
- React-Core
- RNFBApp (17.5.0):
- Firebase/CoreOnly (= 10.7.0)
- React-Core
Expand Down Expand Up @@ -601,7 +599,7 @@ PODS:
- stream-react-native-webrtc (104.0.1):
- React-Core
- WebRTC-SDK (= 104.5112.17)
- stream-video-react-native (0.0.1):
- stream-video-react-native (0.0.4):
- React-Core
- stream-react-native-webrtc
- TOCropViewController (2.6.1)
Expand Down Expand Up @@ -684,7 +682,6 @@ DEPENDENCIES:
- ReactNativeIncallManager (from `../node_modules/react-native-incall-manager`)
- RNCallKeep (from `../node_modules/react-native-callkeep`)
- "RNCClipboard (from `../node_modules/@react-native-clipboard/clipboard`)"
- RNDeviceInfo (from `../node_modules/react-native-device-info`)
- "RNFBApp (from `../node_modules/@react-native-firebase/app`)"
- "RNFBMessaging (from `../node_modules/@react-native-firebase/messaging`)"
- RNFS (from `../node_modules/react-native-fs`)
Expand Down Expand Up @@ -823,8 +820,6 @@ EXTERNAL SOURCES:
:path: "../node_modules/react-native-callkeep"
RNCClipboard:
:path: "../node_modules/@react-native-clipboard/clipboard"
RNDeviceInfo:
:path: "../node_modules/react-native-device-info"
RNFBApp:
:path: "../node_modules/@react-native-firebase/app"
RNFBMessaging:
Expand Down Expand Up @@ -930,7 +925,6 @@ SPEC CHECKSUMS:
ReactNativeIncallManager: 2385505fa5dfdbbc78925e3b8d23b30ce0cde40e
RNCallKeep: 7bfa8f502067be6650eeca5ec0ebbf795314c5c3
RNCClipboard: 3f0451a8100393908bea5c5c5b16f96d45f30bfc
RNDeviceInfo: 475a4c447168d0ad4c807e48ef5e0963a0f4eb1b
RNFBApp: d59efa0872fff4e27de03cca3c528c203a436ae5
RNFBMessaging: 216693dd5ba4f18ba65fb39fc73a44a23c26190f
RNFS: 4ac0f0ea233904cb798630b3c077808c06931688
Expand All @@ -946,7 +940,7 @@ SPEC CHECKSUMS:
RNVoipPushNotification: 1617f5a07be24066830213ae9252cb790b53886f
SocketRocket: fccef3f9c5cedea1353a9ef6ada904fde10d6608
stream-react-native-webrtc: 3e45950d539248d24c1a0a3eafa0f98b5a343ab3
stream-video-react-native: 7bc1439dd1be7a0ef8e17227d8f6881b7f0319c9
stream-video-react-native: 92e1aea0964d810af81ddc6f5359c182eb3a0fd9
TOCropViewController: edfd4f25713d56905ad1e0b9f5be3fbe0f59c863
WebRTC-SDK: 082ae4893212534a779ca233f19a9df8efd5f3bd
Yoga: f7decafdc5e8c125e6fa0da38a687e35238420fa
Expand Down
1 change: 0 additions & 1 deletion sample-apps/react-native/dogfood/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
"react": "18.2.0",
"react-native": "0.71.11",
"react-native-callkeep": "4.3.11",
"react-native-device-info": "^10.6.0",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.12.0",
"react-native-haptic-feedback": "^2.0.3",
Expand Down
12 changes: 0 additions & 12 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -6869,7 +6869,6 @@ __metadata:
react: 18.2.0
react-native: 0.71.11
react-native-callkeep: 4.3.11
react-native-device-info: ^10.6.0
react-native-fs: ^2.20.0
react-native-gesture-handler: ^2.12.0
react-native-haptic-feedback: ^2.0.3
Expand Down Expand Up @@ -6919,7 +6918,6 @@ __metadata:
lodash.merge: ^4.6.2
react-native: 0.71.8
react-native-callkeep: 4.3.11
react-native-device-info: ^10.6.0
react-native-gesture-handler: 2.8.0
react-native-incall-manager: ^4.0.0
react-native-reanimated: 2.7.0
Expand All @@ -6941,7 +6939,6 @@ __metadata:
react: ">=17.0.0"
react-native: ">=0.67.0"
react-native-callkeep: ">=4.3.11"
react-native-device-info: ">=10.6.0"
react-native-gesture-handler: ">=2.8.0"
react-native-incall-manager: ">=4.1.0"
react-native-reanimated: ">=2.7.0"
Expand Down Expand Up @@ -22842,15 +22839,6 @@ __metadata:
languageName: node
linkType: hard

"react-native-device-info@npm:^10.6.0":
version: 10.6.0
resolution: "react-native-device-info@npm:10.6.0"
peerDependencies:
react-native: "*"
checksum: 7a7cc438844552aef687b4a5b8efd0cd0a2959e0a3b771febfbe0b6a9ca8ff05a563e2912b30b83523bd3d5143d6616ca8fac0476abf01936a726e1578211ebb
languageName: node
linkType: hard

"react-native-fs@npm:^2.20.0":
version: 2.20.0
resolution: "react-native-fs@npm:2.20.0"
Expand Down

0 comments on commit 5f7662d

Please sign in to comment.