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

I check some similar issues,But just doesn't work!

  1. wrapper the root component with codepush 2.notifyAppReady() ; I don't know where to place it .I tried call it after the status change to installed,it do not work.

gwl002 avatar Apr 17 '19 10:04 gwl002

Hey @gwl002 Thanks for the question!

You can just use it like this:

componentDidMount(){
  codePush.notifyAppReady();
  this.syncImmediate();        
}

yuri-kulikov avatar Apr 17 '19 11:04 yuri-kulikov

I have the same error:

"An update is available, but it is being ignored due to have been previously rolled back."

codePush.checkForUpdate(function (update) {
  if (update) {
    var updateDialogOptions = {
      updateTitle: "Actualitzacio pendent",
      optionalUpdateMessage: "Vols actualitzar ara?",
      optionalIgnoreButtonLabel: "No",
      optionalInstallButtonLabel: "Si"
    };

    var syncStatus = function (status) {
      console.log("SyncStatus =", status);
      switch (status) {
        case SyncStatus.UP_TO_DATE:
          break;
        case SyncStatus.UPDATE_INSTALLED:
          console.log("SyncStatus.UPDATE_INSTALLED");
          Utilitats.pantallaEspera(false);
          codePush.restartApplication();
          break;
        case SyncStatus.DOWNLOADING_PACKAGE:
          Utilitats.pantallaEspera(true);
          console.log("SyncStatus.DOWNLOADING_PACKAGE");
          break;
        case SyncStatus.INSTALLING_UPDATE:
          // Hide "downloading" modal
          console.log("SyncStatus.INSTALLING_UPDATE");
          break;
        case SyncStatus.ERROR:
          // Hide "downloading" modal
          console.log("SyncStatus.ERROR");
          Utilitats.pantallaEspera(false);
          break;
      }
    };
    codePush.sync(syncStatus, { updateDialog: updateDialogOptions });
  }
})

image

InformaticaComergrup avatar Apr 17 '19 13:04 InformaticaComergrup

Hi @InformaticaComergrup

I have the same error:

"An update is available, but it is being ignored due to have been previously rolled back."

There is a good comment on how rollbacks work.

You need to wrap your App in codePush or use notifyAppReady if you only use codePush.sync.

yuri-kulikov avatar Apr 17 '19 15:04 yuri-kulikov

Hi @gwl002,

I'm going to close this issue for now as I haven't heard from you in a while, unfortunately. I hope your issue is resolved! Please feel free to reopen it if you have any questions.

yuri-kulikov avatar Apr 29 '19 08:04 yuri-kulikov

Same issue in android in react native version 0.60.4.

rmamtaventures avatar Oct 31 '19 12:10 rmamtaventures

Same issue in iOS in react native v0.61.5

mcruz20 avatar Jan 31 '20 10:01 mcruz20

Same issue on Android and iOS on 0.61.5

Cchumi avatar Mar 03 '20 16:03 Cchumi

Same issue on both platforms. Updates with codepush.sync() method are all installed successfully, but after restart our app launches with an initial bundle and codePush.checkForUpdate() method returns an update object again (instead of null) with failedInstall: true.

dmydry avatar Mar 17 '20 20:03 dmydry

Same issue on Android 0.59.9

sephiroth56 avatar Mar 25 '20 08:03 sephiroth56

any updates?

yadimuhammad avatar Apr 08 '20 04:04 yadimuhammad

Same issue here. Any updates?

knifedge avatar Jul 24 '20 18:07 knifedge

Same issue on android, any update?

AnkitPandey14ap avatar Oct 08 '20 17:10 AnkitPandey14ap

Same issue on both platform. Any solution?????

hongsa avatar Jan 13 '21 01:01 hongsa

We are also having this issue on Android with RN 0.63.4

benorgan avatar Jan 20 '21 20:01 benorgan

We are also having the same issue on IOS with React Native 0.63.4

Did anyone resolved this issue or know why this is happening?

hfarhanahmed avatar Jan 21 '21 11:01 hfarhanahmed

Same issue on both platform with ionic cordova. Any solution???

DeMeng33 avatar Mar 23 '21 06:03 DeMeng33

Still the same issue with latest CodePush / ReactNative

shllg avatar Feb 23 '22 08:02 shllg

The same issue for me. image image

MAKARD avatar Apr 13 '22 19:04 MAKARD

Same issue , Please reopen this ticket

ahmadsyed avatar Aug 17 '22 11:08 ahmadsyed