Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

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

— asked March 16th 2010 by scott castov
  • iphone
  • properties
  • startup
0 Comments

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);
    }
    
    — answered March 16th 2010 by Rob Edgell
    permalink
    0 Comments
  • 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

    — answered March 16th 2010 by Mark Poston
    permalink
    0 Comments
  • 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

    — answered March 16th 2010 by scott castov
    permalink
    0 Comments
  • 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.

    — answered March 17th 2010 by Mark Burggraf
    permalink
    0 Comments
  • No problem

    — answered March 17th 2010 by Rob Edgell
    permalink
    0 Comments
  • @Rob, this is outstanding sir thank you.

    — answered March 17th 2010 by scott castov
    permalink
    0 Comments
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.