forked from zulip/zulip-mobile
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
deps: Use expo-application for app version number.
Primarily to prove the correctness of our `react-native-unimodules` installation, install expo-application and use it instead of `react-native-device-info` in those places where it reads the application's version. NOTE: After discussing it at https://chat.zulip.org/#narrow/stream/243-mobile-team/topic/unimodules.20unmet.20peer.20dependency/near/849254, we decided to ignore the following warning: warning " > expo-application@2.1.0" has unmet peer dependency "@unimodules/core@~1.0.0". I filed expo/expo#7728 for it, but basically, the latest version of expo-application (2.1.0) declares that it depends on a version of @unimodules/core (1.0.0) that was already several months out-of-date at the time expo-application was first created, and it seems unlikely that this was well-considered. In our testing so far, everything seems to work correctly, and the vast majority of unimodules don't specify a version constraint at all. But this adds to the need to be wary about Expo's handling of version constraints in general; see the notes on the commit, earlier in this series, that introduces unimodules. To choose between `nativeApplicationVersion` and `nativeBuildVersion`, the deciding factor was which one of these more closely mirrors the behavior of `getVersion` from `react-native-device-info`. (`getVersion` isn't documented well enough to give the answer outright.) `react-native-device-info` is missing documentation on where they get the version number, so we dug into the code and found it: - iOS: `CFBundleShortVersionString` from `info.plist` - Android: `PackageInfo#versionName` (doc at https://developer.android.com/reference/android/content/pm/PackageInfo#versionName) From inspecting `expo-application` code, it turns out that these same exact sources are used for their `nativeApplicationVersion`. The `expo-application` doc for Android actually refers to an `app.json`, which we don't have, and it doesn't mention `versionName`. Maintaining an `app.json` is a normal part of development when you're working entirely in the Expo ecosystem (which we're not), and it's documented (https://docs.expo.io/versions/latest/workflow/configuration/#version) that the "version" key there does indeed correspond to the `versionName` we found by looking in the code. So, use `nativeApplicationVersion`. We don't expect `nativeApplicationVersion` to ever be null, but the type annotation indicates it might be, so handle that case with a "?.?.?" string.
- Loading branch information
Showing
9 changed files
with
57 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
// flow-typed signature: bdd6d740ed1472fde8ecf483ba589452 | ||
// flow-typed version: <<STUB>>/expo-application_v2.1.0/flow_v0.92.0 | ||
|
||
/** | ||
* Flowtype definitions for Application | ||
* Generated by Flowgen from a Typescript Definition | ||
* Flowgen v1.10.0 | ||
*/ | ||
declare module 'expo-application' { | ||
declare export var nativeApplicationVersion: string | null; | ||
declare export var nativeBuildVersion: string | null; | ||
declare export var applicationName: string | null; | ||
declare export var applicationId: string | null; | ||
declare export var androidId: string | null; | ||
declare export function getInstallReferrerAsync(): Promise<string>; | ||
declare export function getIosIdForVendorAsync(): Promise<string>; | ||
|
||
declare export var ApplicationReleaseType: {| | ||
+UNKNOWN: 0, // 0 | ||
+SIMULATOR: 1, // 1 | ||
+ENTERPRISE: 2, // 2 | ||
+DEVELOPMENT: 3, // 3 | ||
+AD_HOC: 4, // 4 | ||
+APP_STORE: 5, // 5 | ||
|}; | ||
declare export function getIosApplicationReleaseTypeAsync(): Promise<$Values<typeof ApplicationReleaseType>, >; | ||
declare export function getIosPushNotificationServiceEnvironmentAsync(): Promise<string>; | ||
declare export function getInstallationTimeAsync(): Promise<Date>; | ||
declare export function getLastUpdateTimeAsync(): Promise<Date>; | ||
} |
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
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,10 @@ | ||
/* @flow strict-local */ | ||
import { NativeModules } from 'react-native'; | ||
import DeviceInfo from 'react-native-device-info'; | ||
import { nativeApplicationVersion } from 'expo-application'; | ||
|
||
const { getVersion, getSystemName, getSystemVersion } = DeviceInfo; | ||
const { getSystemName, getSystemVersion } = DeviceInfo; | ||
|
||
export default !NativeModules.RNDeviceInfo | ||
? '' | ||
: `ZulipMobile/${getVersion()} (${getSystemName()} ${getSystemVersion()})`; | ||
: `ZulipMobile/${nativeApplicationVersion ?? '?.?.?'} (${getSystemName()} ${getSystemVersion()})`; |
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