Skip to content

buildVersion is not a string on Android #57

Description

@haileyok

buildVersion is typed as ?string in the JS code.

https://github.com/APSL/react-native-version-number/blob/master/index.js#L7

type VersionObject = {
  appVersion: ?string,
  buildVersion: ?string,
  bundleIdentifier: ?string
};

However, in the Android code, versionCode from PackageInfo is used, which is a Java int

https://developer.android.com/reference/android/content/pm/PackageInfo#versionCode
https://github.com/APSL/react-native-version-number/blob/master/android/src/main/java/com/apsl/versionnumber/RNVersionNumberModule.java#L41

constants.put(APP_BUILD, packageManager.getPackageInfo(packageName, 0).versionCode);

This usually doesn't present itself as a problem, but in some cases - such as when passing this value back across the bridge - there can be problems. Probably would be best to convert it to a string before passing it over the bridge the first time.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions