Is there a way to read the contents of app.json programmatically from within you app, so you could for example get the current version number and show it within an About screen?
Is there a way to read the contents of app.json programmatically from within you app, so you could for example get the current version number and show it within an About screen?
For Expo SDK 35, I did this:
expo install expo-constants
in your .js:
import Constants from "expo-constants";
<Text> {Constants.manifest.description} </Text>
For expo SDK 33 use:
import Constants from "expo-constants";
{`v${Constants.manifest.version}`}
Newer versions of expo (I'm on 36) now import the variable differently
import Constants from 'expo-constants';
Read all about it here on the expo documentation site
npm:
npm install expo-constants
OR
expo:
expo install expo-constants
About.js
import Constants from "expo-constants";
<Text>Version {Constants.manifest.version} </Text>
When trying to use this line
import { Constants } from 'expo-constants';
Constants was showing up as undefined when logged to the console.
However, this code worked to display the app's version:
<template>
<text>version: {{ appVersion }}</text>
</template>
<script>
import * as Constants from 'expo-constants';
export default {
data() {
return {
appVersion: Constants['default']['manifest']['version']
}
}
}
</script>