Skip to content
This repository has been archived by the owner on Aug 11, 2020. It is now read-only.

Full working sample #137

Open
ghost opened this issue Jul 9, 2016 · 17 comments
Open

Full working sample #137

ghost opened this issue Jul 9, 2016 · 17 comments
Labels

Comments

@ghost
Copy link

ghost commented Jul 9, 2016

Can anyone give an full working example for downloading, extracting und redirecting to the extracted content?

@imhotep
Copy link
Collaborator

imhotep commented Jul 11, 2016

Yes here

@ghost
Copy link
Author

ghost commented Jul 11, 2016

It work's finde, but when i restart the app, the old local content appears.

@macdonst
Copy link
Member

@realn3rd correct. In the app start up you'd need to check if there is content at the synched location and load your app from there instead.

@imhotep
Copy link
Collaborator

imhotep commented Jul 11, 2016

Right. The plugin doesn't manage content for you. It just syncs content to store it to some permanent location. There are different ways you can manage content and it's up to you how you want to do that.

@macdonst macdonst added the docs label Jul 11, 2016
@ghost
Copy link
Author

ghost commented Jul 11, 2016

How can I add a simple test routine to the app?

@ghost
Copy link
Author

ghost commented Jul 14, 2016

any idea?

@imhotep
Copy link
Collaborator

imhotep commented Jul 14, 2016

@realn3rd what do you mean by simple test routine ?

@ghost
Copy link
Author

ghost commented Jul 14, 2016

A simple way to test on app start if content were already downloaded und redirect to this content.

@ghost
Copy link
Author

ghost commented Jul 14, 2016

Maybe something at device-ready-event?

@imhotep
Copy link
Collaborator

imhotep commented Jul 14, 2016

@realn3rd Yes you can call something when deviceready fires

For example:

document.addEventListener('deviceready', function() {
   // this downloads your app if it doesn't exist OR immediately returns a path to your app if it had been previously downloaded
   // the `src` option is not required if you know that your app was previously downloaded.
   var sync = ContentSync({src: "...", id: "...", type: "local"});
   sync.on('complete', function(data) {
      // data.localpath will point to your app
   });
});

@ghost
Copy link
Author

ghost commented Jul 14, 2016

Nice, but it doesn't work :/

@imhotep
Copy link
Collaborator

imhotep commented Jul 15, 2016

What doesn't work ? Could you be more specific ?

@ghost
Copy link
Author

ghost commented Jul 15, 2016

The App shows only the local content, not the cached after restarting it.

@imhotep
Copy link
Collaborator

imhotep commented Jul 15, 2016

@realn3rd did you set document.location=data.localpathin the complete callback ?

@ghost
Copy link
Author

ghost commented Jul 15, 2016

Yes
http://pastebin.com/hsRCNKzA

@ghost
Copy link
Author

ghost commented Jul 23, 2016

Any idea?

@imhotep
Copy link
Collaborator

imhotep commented Aug 2, 2016

@realn3rd sorry for delay. You can try to use the following (on iOS 9+ and above) if you're using WKWebView:

ContentSync.loadUrl(YOUR_URL)

I've updated the sample in the repository to reflect this.

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

No branches or pull requests

2 participants