react-native-code-push icon indicating copy to clipboard operation
react-native-code-push copied to clipboard

checkupdate after app installed,but It always rollback after restart

Open gwl002 opened this issue 7 years ago • 23 comments

Thanks so much for filing an issue or feature request! Please fill out the following (wherever relevant):

Steps to Reproduce

1.First open the app,It works fine.Check update and downloading the new version,and then restart,show the newest content successfully. 2. However, quit the app and restart,then the logcat shows "An update is available, but it is being ignored due to having been previously rolled back."

Expected Behavior

What you expected to happen? The second time the app start the checkUpdate function should return null

Actual Behavior

What actually happens? The checkUpdate function return a obj with info about the newest version.

  STACK TRACE AND/OR SCREENSHOTS

Reproducible Demo

  • Download https://github.com/Microsoft/react-native-code-push/archive/master.zip and unzip. From Examples folder run node create-app.js appName [email protected] [email protected] command to generate plain CodePushified React Native app. Please see description on top of create-app.js file content if needed
  • If you can't reproduce the bug on it, provide us as much info as possible about your project

Environment

  • react-native-code-push version: 5.6.0,
  • react-native version: 0.58.6,
  • iOS/Android/Windows version: android
  • Does this reproduce on a debug build or release build? release
  • Does this reproduce on a simulator, or only on a physical device? android phone

` export default class BoardingScreen extends React.Component { static navigationOptions = { header:null };

 constructor(props) {
     super(props);
     this.state = {
        currProgress:0,
        showProgressBar:false,
     };

     this.syncImmediate = this.syncImmediate.bind(this);
     this._immediateUpdate = this._immediateUpdate.bind(this);
 }

 componentDidMount(){
    this.syncImmediate();        
 }

 syncImmediate(){
    CodePush.checkForUpdate().then(update=>{
        SplashScreen.hide();
        console.log(update);
        if(!update){
            this.setState({
                showProgressBar:false
            })
            this.props.navigation.navigate("Main");
        }else{
            this.setState({
                showProgressBar:true
            })
            this._immediateUpdate();
        }
    }).catch(err=>{

    })
    
 }

 _immediateUpdate(){
    CodePush.sync(
        {
            updateDialog:null,
            installMode: CodePush.InstallMode.IMMEDIATE,
        },
        this.handleCodePushStatusChange.bind(this),
        this.handleCodePushProgressChange.bind(this)
    );
 }

 handleCodePushStatusChange(syncStatus){
    let syncMessage;
        switch(syncStatus) {
            case CodePush.SyncStatus.CHECKING_FOR_UPDATE:
              syncMessage = 'Checking for update'
              break;
            case CodePush.SyncStatus.DOWNLOADING_PACKAGE:
              syncMessage = 'Downloading package'
              break;
            case CodePush.SyncStatus.AWAITING_USER_ACTION:
              syncMessage = 'Awaiting user action'
              break;
            case CodePush.SyncStatus.INSTALLING_UPDATE:
              syncMessage = 'Installing update'
              break;
            case CodePush.SyncStatus.UP_TO_DATE:
              syncMessage = 'App up to date.'
              break;
            case CodePush.SyncStatus.UPDATE_IGNORED:
              syncMessage = 'Update cancelled by user'
              break;
            case CodePush.SyncStatus.UPDATE_INSTALLED:
              syncMessage = 'Update installed and will be applied on restart.'
              break;
            case CodePush.SyncStatus.UNKNOWN_ERROR:
              syncMessage = 'An unknown error occurred'
              break;
        this.setState({
            syncMessage
        })
    }
 }

 handleCodePushProgressChange(progress){
    let currProgress = parseFloat(progress.receivedBytes / progress.totalBytes).toFixed(2);
    this.setState({
        currProgress:currProgress,
    })
 }

 render() {
     return (
        <View style={{flex:1}}>
            <Image source={{uri :'asset:/images/launch_screen.png'}} style={{width:"100%",height:"100%"}}/>
            {!this.state.showProgressBar &&
                <View style={{position:"absolute",justifyContent:"center",alignItems:"center",width:winWidth,height:winHeight,backgroundColor:"transparent",}}>
                    <Progress progress={this.state.currProgress} />
                    <Text>{this.state.syncMessage}</Text>
                </View>
            }
        </View>
     );
 }

}

` (The more info the faster we will be able to address it!)

gwl002 avatar Apr 17 '19 09:04 gwl002

Same issue on codepush version 7.0.4

ghost avatar Sep 06 '22 07:09 ghost

Same here

TacticCoder avatar Dec 28 '22 10:12 TacticCoder

for me, that because i forgot to setup at the native side https://github.com/microsoft/react-native-code-push/blob/master/docs/setup-ios.md

roger-ngx avatar Jul 05 '23 12:07 roger-ngx