Reputation: 5004
I've been googling for a way to force users to update a react native application before allowing them to use it any further. I have not implemented this before and am searching for a way to approach this.
any insight is appreciated, thank you!
Upvotes: 2
Views: 9190
Reputation: 7463
You can do this with CodePush. More specifically you will need to give the codePush options to install immediately.
codePush({
checkFrequency: codePush.CheckFrequency.ON_APP_RESUME,
installMode: codePush.InstallMode.IMMEDIATE
})
Upvotes: 3
Reputation: 1155
If you want to force users to update, You can change the main screen to update screen. For example in the main Component (Provider
for me), I can do this:
export default class Provider extends Component {
constructor(){
super()
}
componentDidMount = () => {
this.checkUpdate()
}
checkUpdate = () => {
// Request last version number from your server
// And compare with current version.
// You can save this number in device storage with AsyncStorage
// At last:
this.setState({
checked: true,
updated: true // Or false
})
}
render() {
let {checked, updated} = this.state
if(checked){
if(updated) return <App />
else return <PleaseUpdate />
}
else return <Loading />
}
}
Upvotes: 2