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

Building a code-push feature with this plugin? #335

Closed
Nashorn opened this issue Jul 11, 2019 · 8 comments
Closed

Building a code-push feature with this plugin? #335

Nashorn opened this issue Jul 11, 2019 · 8 comments
Labels

Comments

@Nashorn
Copy link

Nashorn commented Jul 11, 2019

Hi,
Is it possible to build a code push feature for apps using this api? I am not sure where to start/design it. Can anyone chime in?

@janpio
Copy link
Member

janpio commented Jul 11, 2019

Yes, I pretty much assume the existing plugins in that area are already using it.

I would start by looking at the existing plugins from Microsoft and Ionic, they both have working implementations. Maybe you can even reuse them or something similar (which you will surely find by googling).

@Nashorn
Copy link
Author

Nashorn commented Jul 11, 2019

thank you so much @janpio -- Would you believe i have tried a few "code push" plugins and they were not right, abandoned or will be rejected by Apple. I decided to go PhoneGap because the hydration feature was bait, it turns out PhoneGap is just broken, the whole thing feels like a temporary scaffold riddled with problems. Next, i gave MS App Center a try and their code-push plugin completely breaks my app. At 40/month you would think they would offer a clear path. Their code-push plugin renders a white screen of death with 'deviceready' never firing. That was 4 months ago and many trials and errors of removing platforms, re-adding, restoring plugins, in a deep analysis, methodical at first, and with patience. No luck, yesterday, i gave it a go again, i tried to get their plugin to run on 4 different machines with different configurations of dependencies. SO -- code-push is a 0 to 4 win. I don't even know how developers get it to work, i'm no noob either, 24 years engineering, i feel defeated.

I told myself, there's got to be a simple way to write this and hence i landed on this repo looking for answers, not sure where to begin with a design.

@janpio
Copy link
Member

janpio commented Jul 11, 2019

It would go at it this way: Make an archive of the files, upload somewhere, download it into the app, extract it, somehow remodel your app to load theses files on startup instead of the normal index.html.

The most critical part being the remodeeling part - no idea how that could work.

@Nashorn
Copy link
Author

Nashorn commented Jul 11, 2019

Your starting point really helped me visualize things a bit more. I've attached a drawing. The framework i am using, intrinsically has a "shell" setup. There is mainly 1 "src" folder that is the guts of the app. This is the folder i would need to archive/download and replace as you've suggested. So the index.html that is there along with other shell files can remain static and ship with initial app store builds.

Problem is, how would "cordova-plugin-file" help me replace this folder with an updated "src" zip that i downloaded from server xyz?

Or, can you suggest an alternative design to this? If so, it's a W3C-WebComponent meta-framework, not the traditional angular/react blackboxes. I have fully control of the entire life-cycle from "deviceready" all the way to render.

screenshot

@janpio
Copy link
Member

janpio commented Jul 11, 2019

It doesn't really matter what your source looks like, but what the built Cordova project looks like: You have a www folder that contains some files, and index.html (or another files configured in config.xml, read during build time) is loaded into the webview when you start the app. So you have to either replace www (which proabably is not possible as it is read only space in the app installation), or make it load something else than www/index.html (which I can't imagine how that would work), or make index.html recognize that there is another file/folder that should be loaded so it redirects there (Pseudo-Code: If folder exists, redirect to file from folder, otherwise stay on original index.htm).

But I would look at the other plugins how they solve that problem - because that one is the hardest for now I think.

@brodybits
Copy link

What is the status of this query?

@janpio
Copy link
Member

janpio commented Jul 16, 2019

@Nashorn Just stumbled over it when researching something unrelated: https://github.com/ionic-team/cordova-plugin-ionic/blob/8c64b2e42bdbe9f926e696cb93a784e012bfc377/www/common.ts#L359-L360 So Ionic Deploy downloads the files, puts them somewhere, then reloads the webview to that new location's index.html. (Full API: https://github.com/ionic-team/cordova-plugin-ionic/blob/7376de9a402ba0e6ff73dced3c155d3e1edc728b/docs/interfaces/ideploypluginapi.md)

@timbru31
Copy link
Member

Closing due to enough code pointers from Jan and lack of feedback from OP.

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

No branches or pull requests

4 participants