Skip to content
This repository has been archived by the owner on Oct 1, 2018. It is now read-only.

Update work after restart the App #187

Closed
davidellolio opened this issue Jul 16, 2016 · 13 comments
Closed

Update work after restart the App #187

davidellolio opened this issue Jul 16, 2016 · 13 comments

Comments

@davidellolio
Copy link

Hi guys,

I have used javascript chcp support for the update the ionic project.
The update works only restart the app.

Steps to reproduce

-auto-download set to true in config.xml
-auto-install set to false in config.xml
-Functions used :

checkForUpdate: function() {
chcp.fetchUpdate(app.fetchUpdateCallback);
},

fetchUpdateCallback: function(error, data) {
if (error) {
console.log('Failed to load the update with error code: ' + error.code);
console.log(error.description);
return;
}
console.log('Update is loaded, running the installation');

chcp.installUpdate(app.installationCallback);

},

installationCallback: function(error) {
if (error) {
console.log('Failed to install the update with error code: ' + error.code);
console.log(error.description);
} else {
console.log('Update installed!');
}
}

  • In installationCallback I have put a $state.go("tabsController.home") to go in my homepage.

When the installation is terminated the installationCallback function is called and angular view my old homepage and not new homepage.
If i want see the new homepage i must restart the app.

Could you help me?

Thank you,
Davide

@gareth-ferneyhough
Copy link

Possible dup of #140. Are you deploying to a device via cordova? If so, what device type?

@davidellolio
Copy link
Author

Hi @gareth-ferneyhough
I use Ionic framework and have this problem in ios and android Device.

D.

@nikDemyankov
Copy link
Member

@davidellolio can you share, what plugins are installed in your project?

Also, what version of Ionic platform?

@davidellolio
Copy link
Author

Hi @nikDemyankov,

I used this plugins:
"cordova-plugin-badge"
"cordova-plugin-camera"
"cordova-plugin-console"
"cordova-plugin-contacts"
"cordova-plugin-device"
"cordova-plugin-device-orientation"
"cordova-plugin-dialogs"
"cordova-plugin-file"
"cordova-plugin-file-transfer"
"cordova-plugin-geolocation"
"cordova-plugin-inappbrowser"
"cordova-plugin-network-information"
"cordova-plugin-screen-orientation":
"cordova-plugin-splashscreen"
"cordova-plugin-whitelist"
"ionic-plugin-keyboard"
"phonegap-plugin-push"
"uk.co.workingedge.phonegap.plugin.launchnavigator"
"cordova-plugin-x-socialsharing"
"cordova-plugin-actionsheet"
"cordova-hot-code-push-plugin"
"cordova-hot-code-push-local-dev-addon"
"de.appplant.cordova.plugin.local-notification"
"cordova-plugin-x-toast"
"dependent_plugins": {
"cordova-plugin-app-event"
"cordova-plugin-compat"
}

ionic-version : 1.7.16

This is a log after installed:

07-18 10:17:50.284 12085-12214 D/CHCP: Dispatching Before install event
07-18 10:17:52.286 12085-16526 D/CHCP: Update is installed
07-18 10:17:52.299 12085-12085/ D/CHCP: Loading external page: /data/user/0/it.project/files/cordova-hot-code-push-plugin/2016.07.15-18.24.31/www/index.html
07-18 10:17:52.328 12085-12085/ D/JsMessageQueue: Set native->JS mode to null
07-18 10:17:52.412 12085-12214/ D/CordovaBridge: Ignoring exec() from previous page load.
07-18 10:17:52.454 12085-12085/ W/cr.BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 12085
07-18 10:17:52.458 12085-12085/ W/cr.BindingManager: Cannot call determinedVisibility() - never saw a connection for the pid: 12085

Thank you

@nikDemyankov
Copy link
Member

Hi,

Thanks! Will try to reproduce that.

@davidellolio
Copy link
Author

I add more information:

  • The app, when the installation is terminated, redirect the user on the page viewed before the installation. The page is cached ?

Thank you,
D.

@nikDemyankov
Copy link
Member

In installationCallback I have put a $state.go("tabsController.home") to go in my homepage.

Actually, this line would be, probably, ignored. When update has been installed - plugin should reload webview to the index page. And the index page is the one, that is defined in config.xml:

<content src="index.html" />

So, it will take this url and load it in the view.

@nikDemyankov
Copy link
Member

Haven't got time to play with your setup yet, sorry...

@nikDemyankov
Copy link
Member

@davidellolio Tried it out for Android and worked fine. This is what I did:

  1. Created a tabbed Ionic project:

    ionic start Test tabs
    cd Test
    ionic platform add android
    ionic plugin add cordova-hot-code-push-plugin
    ionic plugin add <ALL_YOUR_OTHER_PLUGINS>

    The only plugin I skipped is cordova-hot-code-push-local-dev-addon, since you do the installation and download manually.

  2. Launched local server to ship files and generate configs:

    cordova-hcp server
  3. Configured config.xml:

    <chcp>
      <auto-download enabled="false" />
      <auto-install enabled="false" />
      <config-file url="https://18efd8cd.ngrok.io/chcp.json"/>
    </chcp>

    Again, I disabled both auto-install and auto-download, since you do it from JS code. As a config-url I set a local server's url.

  4. Added update code to www/js/app.js:

    angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
      .run(function($ionicPlatform) {
      $ionicPlatform.ready(function() {
        if (window.cordova && window.cordova.plugins && window.cordova.plugins.Keyboard) {
          cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
          cordova.plugins.Keyboard.disableScroll(true);
        }
        if (window.StatusBar) {
          StatusBar.styleDefault();
        }
    
        // CHCP update code
        chcp.fetchUpdate(function(err, data) {
          if (err) {
            return;
          }
          console.log('Fetched update');
          chcp.installUpdate(function(err) {
            if (err) {
              console.log(err);
              return;
            }
            console.log('Installed');
          });
        });
      });
    })
    // the rest of the default project angular code
  5. Launched the app:

    ionic emulate android

    App started fine, but since I didn't change anything - no updates were downloaded.

  6. Updated text in www/templates/tab-dash.html and launched the app again. After a few moments update was downloaded and app reloaded to the index page, so I could see the changes.

System:

  • ionic v1.7.16
  • ionic android platform 5.1.1
  • node v4.2.2
  • android emulator API 19

Can you try to do the same steps in your app and see, if it works? Maybe all you need is to remove cordova-hot-code-push-local-dev-addon from the project and set auto-install and auto-download to false? Also, check that there are no JS errors in the project, because this can lead to the issue you are having.

@davidellolio
Copy link
Author

Thank you @nikDemyankov

I will check if have any issue in javascript and follow your steps.

@davidellolio
Copy link
Author

@nikDemyankov I have deleted $state.go row in installationCallback function and now I don't have update problem. I have checked js files and I don't have error. Maybe this command is not accepted.

Thank you for your support.

@nikDemyankov
Copy link
Member

Good :) Please, close the issue, if it is solved :)

@davidellolio
Copy link
Author

Yes. Thank you

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

No branches or pull requests

3 participants