-
-
Notifications
You must be signed in to change notification settings - Fork 660
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
userAgent [nfc]: Use RN's
Platform
API; drop react-native-device-info
Oddly, on Android, react-native-device-info brings in some Firebase dependencies that we don't need: https://github.com/react-native-device-info/react-native-device-info/blob/v8.7.1/android/build.gradle#L54-L64 Also this dependency seems to have needed a bit of complexity to keep around; see the output of git log --grep='react-native-device-info' Remove it, since we can get the same information in the same form from RN's Platform API. To verify that it's all the same: - For the "system name" piece (given previously by r-n-device-info's `getSystemName`): - iOS: - r-n-device-info was using Apple's UIDevice.systemName: https://github.com/react-native-device-info/react-native-device-info/blob/v8.7.1/ios/RNDeviceInfo/RNDeviceInfo.m#L142 - `Platform.constants.systemName` uses the same thing: https://github.com/facebook/react-native/blob/v0.68.5/React/CoreModules/RCTPlatform.mm#L68 - Android: - r-n-device-info was using the string 'Android': https://github.com/react-native-device-info/react-native-device-info/blob/v8.7.1/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java#L195 - (so, copy that) - For the "system version" piece (given previously by r-n-device-info's `getSystemVersion`: - iOS: - r-n-device-info was using Apple's UIDevice.systemVersion: https://github.com/react-native-device-info/react-native-device-info/blob/v8.7.1/ios/RNDeviceInfo/RNDeviceInfo.m#L147 - `Platform.constants.osVersion` uses the same thing: https://github.com/facebook/react-native/blob/v0.68.5/React/CoreModules/RCTPlatform.mm#L67 - Android: - r-n-device-info was using Android's Build.VERSION.RELEASE: https://github.com/react-native-device-info/react-native-device-info/blob/v8.7.1/android/src/main/java/com/learnium/RNDeviceInfo/RNDeviceModule.java#L196 - `Platform.constants.Release` uses the same thing: https://github.com/facebook/react-native/blob/v0.68.5/ReactAndroid/src/main/java/com/facebook/react/modules/systeminfo/AndroidInfoModule.java#L69
- Loading branch information
1 parent
cab2167
commit d42e3d0
Showing
6 changed files
with
39 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,28 @@ | ||
/* @flow strict-local */ | ||
import DeviceInfo from 'react-native-device-info'; | ||
import { nativeApplicationVersion } from 'expo-application'; | ||
import { Platform } from 'react-native'; | ||
|
||
const { getSystemName, getSystemVersion } = DeviceInfo; | ||
import { androidRelease } from '../reactNativeUtils'; | ||
|
||
const systemName = | ||
// prettier-ignore | ||
Platform.OS === 'ios' | ||
// Probably "iOS" on all iOS devices we support (was "iPhone OS" long ago): | ||
// https://github.com/facebook/react-native/blob/v0.68.5/React/CoreModules/RCTPlatform.mm#L68 | ||
// https://developer.apple.com/documentation/uikit/uidevice/1620054-systemname?language=objc | ||
? Platform.constants.systemName | ||
: 'Android'; | ||
|
||
const systemVersion = | ||
// prettier-ignore | ||
Platform.OS === 'ios' | ||
// E.g. "16.4" for iOS 16.4: | ||
// https://github.com/facebook/react-native/blob/v0.68.5/React/CoreModules/RCTPlatform.mm#L67 | ||
// https://developer.apple.com/documentation/uikit/uidevice/1620043-systemversion?language=objc | ||
? `${Platform.constants.osVersion}` | ||
// (E.g. '13' for Android 13 Tiramisu) | ||
: androidRelease(); | ||
|
||
export default `ZulipMobile/${ | ||
nativeApplicationVersion ?? '?.?.?' | ||
} (${getSystemName()} ${getSystemVersion()})`; | ||
} (${systemName} ${systemVersion})`; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters