Page 1 of 1

first run & subsequent run initialization, persistence, and js functions

Posted: Sun Jun 15, 2014 2:27 am
by GordonG

Hi all,
Excuse my lack of knowledge here. I've made a lot of progress working with appery.io in a short time, but there is a lot I do not understand:

I need to get some idea of the program flow/logic of how an app can be initialized when it is first run/installed, and then on subsequent runs how to determine what needs to be set up. Part of this question has to do with the persistence of local storage, both SQLite and key-value storage variables.

1.) first run/installation - how can I determine whether or not the app is run for the very first time. Normally I would check whether or not a stored value is "first run" or something effectively similar, but I'm not sure how to implement that here. Can I check if a key-value local variable is null, or empty or something?

2.) persistence - when an app is quit, will all of the defaults and settings I want to save in local storage will be there? Are there any conditions under which these are lost? Should I save them to an appery.io cloud database?

3.) There are certain blocks of code I need to call at first-run, subsequent-run, and also as a result of specific user actions. How do I create named javascript functions that can be run/invoked from anywhere? (Ive tried creating a javascript in the project tab on the left, but when I try to call it from another script the console logs flags it as undefined.)

Thanks for your ideas and help!


first run & subsequent run initialization, persistence, and js functions

Posted: Sun Jun 15, 2014 2:37 am
by GordonG

scratch #3 - I figured out I have to wrap my code in a named function - the .js item created in the project tab is a file name. so that one is answered.


first run & subsequent run initialization, persistence, and js functions

Posted: Sun Jun 15, 2014 2:43 am
by Alena Prykhodko

Hi,

  1. You can use logic based on DeviceID value. Once app is installed, DeviceID is stored to Devices data collection (http://devcenter.appery.io/documentat...).
  2. Yes, please find more about localStorage here http://devcenter.appery.io/documentat...
  3. I was typing when you replied :)

first run & subsequent run initialization, persistence, and js functions

Posted: Sun Jun 15, 2014 2:53 am
by GordonG

Thank you for the links, Alena.

I'm working on a mission-critical app, and as much as possible it must not rely on retrieving information from the cloud because if the network is down for any reason, that cannot stop my app from working. I envision network access necessary only for synchronizing backups, and for everything it needs to rely on local storage.

Now, at installation time I could require cloud access as a prerequisite - of course, they have to have network access to install it, but on subsequent runs I cannot have the app refuse to run because there is no network or related access issues.

Any comments on my needs or relevant ideas?


first run & subsequent run initialization, persistence, and js functions

Posted: Sun Jun 15, 2014 3:07 am
by Alena Prykhodko

That's fine, it's possible, depends only on your app custom logic.

I suggest that you read tutorial http://devcenter.appery.io/tutorials/..., probably you will find something interesting to benefit from.


first run & subsequent run initialization, persistence, and js functions

Posted: Mon Jun 16, 2014 12:17 pm
by Andrew Peacock

Hi Gordon,

This might be useful:
http://devcenter.appery.io/tutorials/...

Just check about app compatibility - local SQLIte is not always available or is not future-proof (I think).

Another option is to look at shared preferences, if you're comfortble with adding Phonegap plugins: https://github.com/macdonst/AppPrefer...

Hope that helps,
Andy


first run & subsequent run initialization, persistence, and js functions

Posted: Mon Jun 16, 2014 4:23 pm
by GordonG

Thanks, Andrew.
I need a (nearly) full fledged SQL database. SQLite is working well now in my forays with appery.io.

I'm not new to development, web development, or general programming in many languages and development systems, but I am new to app development, so I am quickly assimilating many pieces - but I still do not have much of the full picture.

I've looked for information about installing various plugins with appery.io, but even with my experience it seems like a poorly documented hack. I can't find any clear instructions on how to install them. - I was looking at a cordova plugin for a UIViewPicker and how to install it... but google isn't useful these days in returning meaningful search results, it seems. In the end I found a javascript version I could implement easily.

It is my understanding that appery.io's SQLite is a phone gap plugin, or at least the documentation cited in some of the tutorials links to some phonegap doc site...

Ultimately I need to create, at the very least, a native iOS app. Now, if I can easily port that to other platforms, then that is the direction I need to go.

At the moment I understand what I am creating with appery.io is a Web App. Perhaps I should not be using it if a native app is my goal? I thought appery.io would allow native apps to be produced, in the end.

It is also my understanding that for iOS app development, SQLite is the db system used by the OS.

If you can correct my understandings... or add anything that might help me, that would be great, because right now I am making a lot of progress hacking in a fog. I appreciate your comments.