Ionic Deploy Infinite App Reboot


#1

Hi,

I have tested the ionic-deploy tutorial (from scratch) and it works very well.
I am able to upload new versions of the app and download/install them from within the app using the button.

Console output:

Ionic Core: init
ionic-core.js?ionicCachebuster=98197:145 Ionic Core: searching for cordova.js
ionic-core.js?ionicCachebuster=98197:259 Ionic Core: injecting cordova.js
Navigated to file:///data/data/com.ionicframework.deploytutorial347428/app_13f5160e126b11e59acfba0c3d89b3f2/index.html
ionic-deploy.js?ionicCachebuster=98197:270 Ionic Deploy: Init
controllers.js?ionicCachebuster=98197:18 Ionic Deploy: Checking for updates
ionic-deploy.js?ionicCachebuster=98197:128 DEBUG DEPLOY: false
controllers.js?ionicCachebuster=98197:20 Ionic Deploy: Update available: false

Now the problem is when I try to do the same in my existing app… my app keeps restarting.

My app currently is defined (and working) as follows:

<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
<script src="lib/ionic-service-core/ionic-core.js"></script>
<script src="js/app.js"></script>

I need ngCordova for my app, and it needs to be loaded between angular and cordova.
Angular being built-in Ionic Bundle and Cordova being loaded by Ionic Core, I have it in between both.
And that works fine.

Overview of the structure of my app :

angular.module('myApp.services', [] )
angular.module('myApp.controllers', [ 'ngCordova', 'myApp.services' ])
angular.module('myApp', ['ionic', 'ionic.service.core', 'myApp.controllers'])
  .run(...) {
      $log.debug("Starting app...");
      $ionicPlatform.ready(function () {
        $log.debug("Ionic platform ready");
      }
     ...
  }
  .config(...) {
        $ionicAppProvider.identify({
        app_id: 'abc',
        api_key: 'defghi',
      });
  }

That works fine.
Example output from the console:

Ionic Core: init
ionic-core.js:145 Ionic Core: searching for cordova.js
ionic-core.js:259 Ionic Core: injecting cordova.js
ionic.bundle.js:20306 Starting app...
ionic.bundle.js:20306 LoginCtrl
ionic.bundle.js:20306 Ionic platform ready

Now I’m trying to add ionic-service-deploy

Following the doc [http://docs.ionic.io/v1.0/docs/deploy-install]

$ ionic plugin add https://github.com/driftyco/ionic-plugins-deploy
$ ionic add ionic-service-deploy

Then I add ionic-deploy.js into my index.html file right after the ionic-core, so I now have:

<script src="lib/ionic/js/ionic.bundle.js"></script>
<script src="lib/ngCordova/dist/ng-cordova.min.js"></script>
<script src="lib/ionic-service-core/ionic-core.js"></script>
<script src="lib/ionic-service-deploy/ionic-deploy.js"></script>
<script src="js/app.js"></script>

Finally, I inject the service into my main module, which now becomes:
angular.module('myApp', ['ionic', 'ionic.service.core', 'ionic.service.deploy', 'myApp.controllers'])

I do not add anything else (no logic to auto-update, nothing) and re-build / re-run my app like that…

Ionic Deploy: Init
ionic-deploy.js?ionicCachebuster=60072:128 DEBUG DEPLOY: false
ionic-core.js?ionicCachebuster=60072:433 Ionic Core: init
ionic-core.js?ionicCachebuster=60072:145 Ionic Core: searching for cordova.js
ionic-core.js?ionicCachebuster=60072:259 Ionic Core: injecting cordova.js
ionic.bundle.js?ionicCachebuster=60072:20306 LoginCtrl
Navigated to file:///data/data/com.me.myApp/app_12a33ccc126611e59fec66a442301b05/index.html

ionic-deploy.js?ionicCachebuster=60072:270 Ionic Deploy: Init
ionic-deploy.js?ionicCachebuster=60072:128 DEBUG DEPLOY: false
ionic-core.js?ionicCachebuster=60072:433 Ionic Core: init
ionic-core.js?ionicCachebuster=60072:145 Ionic Core: searching for cordova.js
ionic-core.js?ionicCachebuster=60072:259 Ionic Core: injecting cordova.js
ionic.bundle.js?ionicCachebuster=60072:20306 LoginCtrl
Navigated to file:///data/data/com.me.myApp/app_12a33ccc126611e59fec66a442301b05/index.html

ionic-deploy.js?ionicCachebuster=60072:270 Ionic Deploy: Init
ionic-deploy.js?ionicCachebuster=60072:128 DEBUG DEPLOY: false
ionic-core.js?ionicCachebuster=60072:433 Ionic Core: init
Navigated to file:///data/data/com.me.myApp/app_12a33ccc126611e59fec66a442301b05/index.html
ionic-core.js?ionicCachebuster=60072:145 Ionic Core: searching for cordova.js
ionic-core.js?ionicCachebuster=60072:259 Ionic Core: injecting cordova.js
ionic.bundle.js?ionicCachebuster=60072:20306 LoginCtrl
Navigated to file:///data/data/com.me.myApp/app_12a33ccc126611e59fec66a442301b05/index.html

I don’t know why, but it keeps reloading the app (keep navigating back to index.html)…
This is quite annoying as I cannot use the feature because of that…

Anyone has an idea why it’s behaving like that?
I was thinking one possibility is because Ionic Deploy seems to execute before Ionic Core.
In the original deploy-tutorial, we have the Ionic Core statements showing before the Ionic Deploy ones, as shown at the top of this message.
But when running in my app, the Ionic Deploy statements are showing before the Ionic Core ones…

In my index.html file, core is defined before deploy in both cases, and when checking the network, it loads it in the right order in both cases:

deploy-tutorial:

myApp:

So that looks fine to me and I have no idea what’s making the app infinitely reloading at startup…


#2

Remove else condition if your app already loaded.

        if (response) {
            // Download the updates, etc
        } else {
            $ionicDeploy.load();
        }

#3

I don’t even have any $ionicDeploy.load().
I go into an infinite reload as soon as I add the feature to the project, without even using it yet…


#4

Hello, we are seeing same infinite loop problem. Dis you get this fixed by any chance?
@mhartington


#5

If you guys are having some issues, feel free to ask in our IO gitter chat room

https://gitter.im/driftyco/ionic-io-testers