Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

checkupdate after app installed,but It always rollback after restart #1564

Closed
gwl002 opened this issue Apr 17, 2019 · 23 comments
Closed

checkupdate after app installed,but It always rollback after restart #1564

gwl002 opened this issue Apr 17, 2019 · 23 comments
Assignees

Comments

@gwl002
Copy link

gwl002 commented Apr 17, 2019

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 react-native@0.47.1 react-native-code-push@5.0.0-beta 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
Copy link
Author

gwl002 commented Apr 17, 2019

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.

@yuri-kulikov
Copy link
Contributor

Hey @gwl002
Thanks for the question!

You can just use it like this:

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

@InformaticaComergrup
Copy link

InformaticaComergrup commented Apr 17, 2019

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

@yuri-kulikov
Copy link
Contributor

yuri-kulikov commented Apr 17, 2019

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
Copy link
Contributor

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.

@rmamtaventures
Copy link

Same issue in android in react native version 0.60.4.

@mcruz20
Copy link

mcruz20 commented Jan 31, 2020

Same issue in iOS in react native v0.61.5

@Cchumi
Copy link

Cchumi commented Mar 3, 2020

Same issue on Android and iOS on 0.61.5

@dmydry
Copy link

dmydry commented Mar 17, 2020

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.

@sephiroth56
Copy link

Same issue on Android 0.59.9

@yadimuhammad
Copy link

any updates?

@knifedge
Copy link

Same issue here. Any updates?

@AnkitPandey14ap
Copy link

AnkitPandey14ap commented Oct 8, 2020

Same issue on android, any update?

@hongsa
Copy link

hongsa commented Jan 13, 2021

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

@benorgan
Copy link

We are also having this issue on Android with RN 0.63.4

@hfarhanahmed
Copy link

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?

@DeMeng33
Copy link

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

@shllg
Copy link

shllg commented Feb 23, 2022

Still the same issue with latest CodePush / ReactNative

@MAKARD
Copy link
Contributor

MAKARD commented Apr 13, 2022

The same issue for me.
image
image

@ahmadsyed
Copy link

Same issue , Please reopen this ticket

@Kunal-Airtel2022
Copy link

Same issue on codepush version 7.0.4

@TacticCoder
Copy link

Same here

@roger-ngx
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests