react-nativecode-push

How do i show the current CodePush Version label in my React Native Android app?


Looking for something like: <Text>VERSION={CodePush.VersionLabel}</Text>

Where CodePush.VersionLabel is something like "v6" that is displayed in code-push deployment ls <MyApp>

I'd like to show this at the bottom my login screen.


Solution

  • componentDidMount(){
        codePush.getUpdateMetadata().then((metadata) =>{
          this.setState({label: metadata.label, version: metadata.appVersion, description: metadata.description});
        });
    }
    
    render() {
        return(
            <Text>{this.state.version}.{this.state.label}</Text>
        );
    }
    

    Note: The .label property is the internal build number used by CodePush (e.g. v24)