Start up /Run Once
is there anyway to detect if its the first time this app was launched?
(iphone)
Reason being I want to use:Titanium.App.Properties.setString('String,mystring')
if this is the first time it was ever ran.
please please help this is a headache
6 Answers
-
Accepted Answer
Try something like this:
if (Ti.App.Properties.getString("first_run") == null) { // first run, do something /** * Code you want to run if this is the first run * */ // Now set first_run so that this won't run again Ti.App.Properties.setString("first_run", 0); }
-
Hi,
You should be able to test with Ti.App.Properties.getString("String") first. Then use setString("String","myString") based on your result from getString().
Regards
Mark -
example please Im not lazy just cant get my head around it..
I know it has somthing to do with a IF statement dont know synax
-
If I recall, this will crash Android:
if (Ti.App.Properties.getString("first_run") == null) {
What works on both Android and iPhone is this:
if (Ti.App.Properties.getString("first_run","yes") == "yes") {
Then just set the property to "no" on the first run.
-
No problem
-
@Rob, this is outstanding sir thank you.