Discussion Forums  >  Images, Documents, File Locations

Replies: 15    Views: 73

RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
06/13/13 05:39 AM (11 years ago)

Can I auto-load all my Data URLs from Main Menu?

I have an app that is intended to be used during emergencies, when network access is likely to be gone. It loads in content from dozens of pages (mostly HTML docs and PDF doc screens) using Data URLs. This content is frequently updated. But users now need to load each screen one by one to get the latest content. Is there a way, when the Main Menu loads, to go through the entire app and check for updated content in all the Data URLs, and download them? Since all my screens allow caching, this would insure the freshest content is on their device.
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
06/13/13 05:44 AM (11 years ago)
One more thing, the app also has other functionality which users use daily, so getting them to load the Main Menu is not the issue. It's the content above that users don't need until an emergency arises, and then it's too late for them to refresh with latest content on the various screens.
 
Jake Chasan
Veteran developer
Profile
Posts: 1685
Reg: May 13, 2011
location unknow...
29,650
like
06/13/13 11:02 AM (11 years ago)
Here is an idea. (a little complex but will have amazing results) You can write a script (probably php) to download all of the pdf and html documents when the app loads. Then in the Plugin Control Panel, instead of using "Data URL" you will use "Local File Name" Here is how it works: In iOS, when content is downloaded inside your app, it is put into the same folder as the assets (images, documents) that were compiled with the app from Xcode. When you download these emergency files in the beginning when the app is launching (or anytime during the run of the app), it will save them to the assets folder. Then in the plugin control panel, you can load a local file name, because iOS has already downloaded your file. Here is how I would recommend approaching this: Use Chris's HTML Pro plugin to load a "Home Screen" of an HTML document that you include in the Xcode build that has a button that says enter app. When the HTML plugin loads, you could either place download links in the html (not recommended) or have a simple script that would download the files. Jake
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
06/13/13 11:11 AM (11 years ago)
Long story short, the only way I know to be certain the data is in the app when there is not network coverage is to include the html files in the build. Not sure if that helps you though.
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
06/13/13 11:36 AM (11 years ago)
Thanks Jake, like the way you think. I'm already using the HTML Pro plugin so will look into that approach. Also, could be a cool "refresh all content" plugin, especially if it could search out all Data URL paths, and check/update if necessary.
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
06/13/13 11:40 AM (11 years ago)
Alan, I need to keep the content management system flexibility of frequent updates, but I'm trying to get these page updates down to the device as easy as possible. If I can use the "easy button" approach on the main page, or kick it off at initial load, then the content is there when they need it (during the next emergency situation)
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
06/13/13 01:42 PM (11 years ago)
Another option is this: Use php to generate all your JSON. You need to be pretty familiar with JSON, and you lose control panel functionality, but you gain the ability to do exactly what you want. Here's how I do it in my apps: I have a database where content resides. My clients use my website to make changes to that database based on what they want in their app. It might be turning a certain feature (aka plugin screen) on or off. Or it might be adding a document to be displayed in one of the screens (e.g., Word, PDF, HTML). Then my php script analyzes my database for the current client (i.e., the app ID) and builds a complete BT_config.txt file on the fly. In a sense, I've duplicated a lot of the efforts that went into the current Buzztouch control panel. But by doing so I gained tremendous flexibility and gave my clients something much simpler to use. (They can now use a simple on/off switch to turn add or delete an entire plugin screen).
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
06/13/13 04:51 PM (11 years ago)
That sounds incredibly powerful. But I still have a question. Even after your customer designates a new PDF file to be loaded, does your PHP script ensure that it is actually downloaded to the device without them having to go into that part of the app, load the screen and and activate the data load URL?
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
06/13/13 04:57 PM (11 years ago)
Here's an example of what I'm talking about. Let's say I have a menu item which loads an HTML page called Alert one.html via the data URL. The actual content of Alert one.html changes pretty regularly, and I need to make sure that the latest version of that HTML page is cashed on the device. Currently my users have to go into each menu item and open the page to load and cache the latest content.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
06/13/13 07:14 PM (11 years ago)
Ah, no my solution doesn't go that far. My clients don't update to that kind of frequency and their users generally have Internet access. However, you could do what you need. Here's one way: Assuming your home screen will always be the same plugin, modify the code so it loops through the entire bt_config.txt file, looking for certain itemTypes, and grabbing their dataURL's. Tgen download the referenced files and save them according to the same naming convention as each plugin uses when caching data.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
06/14/13 01:48 AM (11 years ago)
@RonBo, in simple terms, I think your requirements are 1) The app content to be available if the user is offline. 2) All the app content to be automatically refreshed when the user opens the app and is on-line. Have you seen this 'howto' on automatic refresh? I don't know if it solves everything, but it may be a part of the puzzle. http://www.buzztouch.com/files/howtos/AutomaticRefresh.pdf
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
06/14/13 01:50 AM (11 years ago)
@chris1, your solutions sound incredibly powerful. I just about understand json but can't do php and I am not much of a programmer. Are there any examples you can point us to that explain this in baby steps?
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
06/14/13 03:45 AM (11 years ago)
@chris - you are spot on! This is exactly what I need to do: "Assuming your home screen will always be the same plugin, modify the code so it loops through the entire bt_config.txt file, looking for certain itemTypes, and grabbing their dataURL's. Then download the referenced files and save them according to the same naming convention as each plugin uses when caching data." Any details on approach or coding examples would be very helpful.
 
chris1
Code is Art
Profile
Posts: 3862
Reg: Aug 10, 2012
Austin, TX
50,120
like
06/14/13 06:16 AM (11 years ago)
Well I'm always for hire... ;) I would start by analyzing the code in the search plugin. It loops through the entire bt_config.txt file and looks for certain plugin types. Then I would pay attention to the downloader methods in the plugins you need to download files for. You'll want to run the download methods in the background, as it could take a bit to download everything. You'll also want to start the activity out of viewDidLoad, not viewWillAppear, so that it doesn't re-download every time the user presses the home key. Or ... Connect it to the splash screen.
 
WebNevees
Code is Art
Profile
Posts: 206
Reg: Oct 28, 2012
KL
11,660
like
06/24/13 11:49 AM (11 years ago)
Hi RonBo, As I see you've been struggling with this automatic content refresh vs the automatic (configuration) refresh that is currently available, I will share some highlights of my experience in the same field. Since you're having most of your content served on html, I think it would be easiest and best to work on localstorage instead of working on a plugin which will need an ios, and an android version, and will need to be updated everytime Buzztouch code is updated. This is my experience. Localstorage is available on more than 95% of mobile devices and browsers now, so don't hesitate. The only problem is that in my configuration, I need to load any one page of my html documents (which are served locally on and inside the application) once to update the content, then it will be available offline to any one of the other html doc pages in my app. So just loading the app and entering the main menu screen is not enough. If this is what you need I propose loading the first web page inside a webview window the size of an itsy bitsy window (!) on the main menu page whatever it is. This way you would load the window each time your app loads and you'll download the content you need from a url from inside an html doc locally stored, all in an invisible window (and maybe even asynchronously and in the background if you're feeling like it). There you have it. You're actually synching your content and putting it into localstorage each time you load your menu. Then whenever your app is offline, you'll just read your content from LocalStorage and create your page on the fly. This is best when you only update content and not the styling or page layout. So here's what I'm currently doing: I have a rates page which is an html file in my app, put into the bundle with all its images and files. It checks for internet connectivity each time it is loaded. If it is not connected, it uses content (rates) stored in a LocalStorage dictionary array and builds the page, also displaying the latest time of sync. If connected, it makes a call to an xml file on the web and retrieves and parses the data and then stores it into the LocalStorage variables, overwriting the previous values. It also saves a timestamp which is unique to each rate update on the xml file. Then it loads the the values into the html using LocalStorage. This technique only uses javascript, html, and LocalStorage which is available on most devices now. Feel free to take a look into one of the apps using this system which has been published into both stores. It's not in english, but it's pretty straightforward and by clicking the first icon from the left, you'll see the rates page. Let me know what you think and put down a good word for me. It's actually published under my client's name. Check out the details and urls here: <a href="https://www.buzztouch.com/forum/thread.php?tid=9F3C7CBFDA33699D3E5A35F&sortColumn=FT.id&sortUpDown=DESC&currentPage=1" target="_blank" rel="nofollow">https://www.buzztouch.com/forum/thread.php?tid=9F3C7CBFDA33699D3E5A35F&sortColumn=FT.id&sortUpDown=DESC&currentPage=1</a> Now if you need to auto load the content without using the trick above, I would suggest Chris's method. But I think he's overdoing it. You can make a list of files you need to always load into your app, pass them in from your theme data, and autoload only them without doing all the cycling and finding and stuff. He's thinking of giving you the whole solution, which is too complete! Chris the man! Nevertheless, as he said, you'll have to look into how the html doc plugin downloads files from a remote url and uses them when needed and just replicate the code from within your main menu screen, or even your splash screen. If you find this solution can answer your needs, let me know so I can send you a some sample code to get working on. Basically you'll be using my code then editing it to your own needs. You'll also have to do some small adjustments in your html doc plugins to get things going, but it will work quite easily, and you'll get both android and iOS done at the same time, cause you're using javascript instead (!). Note to self: I think it's time for me to write out a nice guide on LocalStorage, maybe with a video tutorial and some template code. Maybe I'll make it into a plugin instead...
 
RonBo
buzztouch Evangelist
Profile
Posts: 167
Reg: Feb 26, 2012
Raleigh, NC
5,220
like
06/24/13 08:05 PM (11 years ago)
Webneeves - thanks for the detailed response, and it will take me some time to go through it, but I get the gist of it. Please send me your sample code so I can see how you to get working with local storage. I've started to review the logic of how the HTML doc plugin download files from remote URL. I like the idea of the tiny webview window, so will want to see how your pull that off! My content sounds great for this technique. Thanks again
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.