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

On firstrun/install of app chcp.fetchUpdate() returns nothing does not fire my callback and gives me no error #63

Closed
ennisthemenace opened this issue Dec 9, 2015 · 6 comments

Comments

@ennisthemenace
Copy link

On firstrun/install of app chcp.fetchUpdate() returns nothing does not fire my callback and gives me no errors?
chcp.fetchUpdate(function(error,data){
console.log(error);
console.log(data);
});

Refreshing the page and or start/stopping the app and the callback works fine.

Any thoughts?

using

Cordova version: 5.4.1
cordova-hot-code-push-plugin 1.1.2

iOS platform:
Xcode 7.1.1
Build version 7B1005

@nikDemyankov
Copy link
Member

When are you calling it? On the very first run plugin rejects all the requests from the JS module until he is ready to work. And this means it copied www folder onto external storage. When he does that - it fires chcp_assetsInstalledOnExternalStorage event. After that you can call plugin functions.

It should, probably, instead of silently rejecting the requests - cache them and execute when the time is right.

@ennisthemenace
Copy link
Author

I call it first thing in my onDeviceReady function, and thanks for quick reply.

@nikDemyankov
Copy link
Member

If this happens only on the very first launch - then I guess the problem as I described: plugin is not yet ready to receive requests.

You actually don't need to call fetchUpdate onDeviceReady. Plugin automatically fetches it on every launch. But if you want to control it manually - I would suggest to set:

<chcp>
  <auto-download enabled="false" />
  <auto-install enabled="false" />
</chcp>

But yes, probably that need's to be extended with some error or caching the request.

@ennisthemenace
Copy link
Author

They are already set to false, but will look into it :)
Thanks.

@nikDemyankov
Copy link
Member

If they are already set to false, then good, I was just suggesting )

@ennisthemenace
Copy link
Author

All good I just put a listener on chcp_assetsInstalledOnExternalStorage after my onDeviceReady has been called, and set a localStorage item to let my app know where it was running from.

thanks 👍 :)

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

2 participants