1.1.6 • Published 5 years ago
react-native-app-version-update-new2 v1.1.6
react-native-app-version-update-new2
This project will check that app needs an update or not. It will do calculation based on version of App and will show a popup based on below 3 condition.
- App needs a force update
- App needs a update but with remind me later option
- App is updated
Installation
react-native-device-info
This package has a dependency with react-native-device-info. If your project doesn't have a dependency with this package already, please refer to their installation instructions.
$ npm install react-native-app-version-update-new2 --save
Usage
import {checkForVersion} from 'react-native-app-version-update-new2';
checkForVersion(API_RESPONSE, DATE_FORMAT, APP_URL, STYLE);
Params | Usage | Required |
---|---|---|
API_RESPONSE | Api response which should be same as defined at apiRespone.json in src folder | Yes |
DATE_FORMAT | date formate which we show as a title | Yes |
APP_URL | Platform specific app url | Yes |
STYLE | Custom style for popup | Optional |
Example
import {checkForVersion} from 'react-native-app-version-update-new2';
import apiRespone from './src/apiRespone.json';
const iosUrl = "ios app-store url";
const androidUrl = "android play-store url";
class Demo extends React.Component {
componentDidMount(){
checkForVersion(apiRespone, 'DD-MM-YYYY', Platform.OS === 'ios' ? iosUrl : androidUrl);
}
render() {
return (
<View>
<Text style={{}}>Hello World!</Text>
</View>
)
}
}
How to redesign style ?
We can pass the styles prop to cover default style. See Example below.
const styleobj = {
mainViewStyle : {
backgroundColor: 'rgba(0, 50, 60, 0.9)',
},
titleStyle:{
color: 'rgba(255,255,255,0.8)',
},
descTextStyle :{
color:'rgba(255,255,255,0.8)',
},
updateBtnStyle : {
color:'rgb(255,255,255)'
},
remindMeLaterBtnStyle : {
color:'rgba(255,255,90,0.6)',
},
closeBtnStyle:{
tintColor:'white'
}
};
checkForVersion(apiRespone, 'DD-MM-YYYY', Platform.OS === 'ios' ? iosUrl : androidUrl, styleobj);