Ionic deploy not working after editing ionic.project file

Hi all,

Yesterday for unknown reason my ionic deploy was no longer working, I always had some “unexpected token” written in red in my cmd when I launched the command ionic upload --deploy (never happened before)

I read online that to solve this I could regenerate another ionic.project by emptying the “app_id” value (“app_id”: “”)
This worked, the ionic -upload --deploy was now pushing the update to https://apps.ionic.io.

However, I can no longer fetch that update from my project!
I tried removing and readding the platform, rebuilding, putting back my old value in ionic.project, nothing works anymore, I just get "Ionic Deploy: no updates available " from the console log when I try to fetch it…

Here is the code to fetch that update (always worked before)

var deploy = new Ionic.Deploy();
$scope.progress = "0";
$scope.doUpdate = function() {
  deploy.check().then(function(hasUpdate) {
if (hasUpdate) {
	openModalProg();
	deploy.update().then(function(res) {
	  console.log('Ionic Deploy: Update Success! ', res);
	  closeModalProg();
	}, function(err) {
	  alert('Error loading update...');
	  console.log('Ionic Deploy: Update error! ', err);
	}, function(prog) {
	  $scope.progress = prog;
	   console.log('Ionic Deploy: Progress... ', prog);
	});
  }
}, function(err) {
  console.error('Ionic Deploy: Unable to check for updates', err);
});

};

Can anyone help please?

What changed after you “emptied” the app_id inionic.project?
With what value did it get replaced? New ID? Same ID?

A new ID got generated.
And I can see the new app on apps.ionic.io as well, with the deployed update everytime I push them.

I just cant fetch them from the app now…

Is the app trying to fetch the update for the same app_id?
(Use a proxy like Charles Web Proxy to check which URL the deploy.update call on the device is fetching)

My current theory on your problems: There are multiple places where app_id are placed, and probably you missed one (or better: deleting it from ionic.project wasn’t enough).

My theory is the same as yours, but shouldn’t removing platform and readding fix this already?
I even went to the ionic.io.bundle.min.js to make sure it was the correct app_id added, and it was.

Also, maybe it’s not connected, but I feel like my bower.json is out of date, I can see in it some old versions for my plugins and even some plugin that I already deleted. Maybe it’s calling the wrong ionic-service-core & deploy? How can I update its content?

I will make sure it’s fetching from the same app_id with the proxy you mentionned…

I am trying to use charles web proxy, I connected it to my android device, I can see http://apps.ionic.io listed on the left when I check for an update, but where am I supposed to see if it’s calling the right app_id?
The “request” tab in charles is showing me only unreadable characters…
­­

Absolutely, but before you go there better find out if you are really requesting updates for the correct ID. Best way to figure out where to continue.

Ah, Deploy is using SSL: Right click on the request and set “SSL Proxying”. If this doesn’t work instantly, google for how to capture SSL requests using Charles. There are lots of SF posts about this. (I am on an old version of Charles, so I can’t really give you instructions on how to set this up - but shouldn’t be too hard).

Also, did you upload and deploy a new version of the code after you built your current app?

Yes, I did upload and deploy new versions of the code after I build my current app.

I will check the other things you mentionned with Charles web proxy and give you more details.
Thanks a lot for your guidance.

I added apps.ionic.io to my SSL proxy settings, but now when I start a request it “blinks” on the structure tab but disappears right away.
I don’t have time to catch its content, it doesn’t stick around like it does when I remove that SSL proxying… weird. :confused:

EDIT: Okay I got it, I had to add the charles certificate on my android phone to get it working.

So I can now say that yes, it is calling the right app_id…

I noticed something new!

When I change the view, I can then fetch the new deploy! It’s so weird. I will investigate deeper…

Well, then Charles didn’t help to resolve the problem, but you learned an awesome tool to debug stuff like this :smile:

So it only doesn’t work on the inital view that is rendered after app start? Where do you call doUpdate()?

Yes, it is indeed an awesome tool. It even helped me realize that an app I was using was connecting to my email address using my password not encrypted… I could see it in the header of the request. Thank you for that. :slight_smile:

Anyway, I call doUpdate() in my Appctrl which wraps the whole app (it’s the controller of my sidemenu)
So I can go to another view and go back to the first one, it will work.
The only problem is the view when I just launched my app.

Do I need to call the doUpdate() on device ready or something?

[quote=“pierro, post:13, topic:37669”]
Do I need to call the doUpdate() on device ready or something?
[/quote] Yes, as it uses the deploy plugin to do the request to the ionic.io backend servers, waiting for device ready seems like a good idea:

$ionicPlatform.ready(function() { … }

Alright, adding document.addEventListener("deviceready", function () {...}) fixed this!

It’s weird though, I never needed this line before I edited the ionic.project. It worked great without it.

Anyway, thanks a lot for your help @Sujan12 ! :smile:

Awesome :smile:

(The code I posted is more or less the Ionic way of doing the code you posted - but I also mix both in my current project… so I better be quiet :stuck_out_tongue: )

That’s an interesting point, is$ionicPlatform.ready(function() {...} doint exactly the same as document.addEventListener("deviceready", function () {…}) ?

Because I have in my app.js the second one INSIDE the ionicplatform.ready… Would that be useless?

I was under the impresson they are identical. But I’m not sure - best create a new topic and ask exactly this question.