Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get Android Version number in React-Native? (not API level number)

I want to display the Android Version in my app (like 8.0, 9.0...). For now I am using: Platform.Version But this returns the API version (24, 25...).

I would like an option that's more elegant than just creating a mapping, and that does not require republishing every time there is a new android release. Is there a way to do that without an external library?

like image 667
NilVS Avatar asked Apr 17 '19 06:04

NilVS


2 Answers

you can :

import { Platform } from 'react-native';

const OsVer = Platform.constants['Release'];
like image 140
PurTahan Avatar answered Sep 21 '22 01:09

PurTahan


You can use this library,

react-native-device-info

import DeviceInfo from "react-native-device-info";
DeviceInfo.getSystemVersion()

apart from version, it has lots of methods which are much handy for getting device specific information.

EDIT: It is getSystemVersion()

like image 43
Jaydeep Galani Avatar answered Sep 21 '22 01:09

Jaydeep Galani