iOS Tutorial Application life cycle

Discussion in 'iOS Tutorials' started by Erel, Oct 22, 2014.

  1. Erel

    Erel Administrator Staff Member Licensed User

    The life cycle of iOS applications is quite simple.

    The two most important events are Application_Start and Application_Background.

    The standard way to start an application is by clicking on its icon.
    This will cause Application_Start to run. Application_Start only runs once when the process starts.
    It is always the first sub to run.
    You will usually load the layout in this sub and optionally restore the state.
    Note that at this point the actual page size is not known.

    The process will continue running until the user closes the application. This happens when the user presses on the home button.

    Application_Background will be called when the application is moving to the background. This is the place to save the user data and also to save the state. You should assume that the process will be killed shortly after this sub.

    Normal applications do not run in the background. There are no services in iOS.

    Application_Active will be raised when the app is active. Which means that the user can interact with it. It will follow Application_Start and Application_Foreground events.

    Application_Inactive will be raised when the app is still in the foreground but the user cannot interact with it. It will be raised before Application_Background. It can also be raised when there is an interruption such as a phone call. In this case Application_Inactive will be raised and if the user doesn't answer the call Application_Active will be raised.

    Application_Foreground will be called after the app transitions from the background to the foreground. This event will only fire if the process was not killed while the app was in the background.

    The last event is Application_OpenUrl. This event is fired when another app sends a URL to the system that your app is registered to. This is another way to start applications. This is how for example B4i-Bridge launches the apps during debugging.
     
  2. tuhatinhvn

    tuhatinhvn Active Member Licensed User

    I saw some app can play music when i press home button?
    How do they do? can we make with B4I?
     
  3. Erel

    Erel Administrator Staff Member Licensed User

    lemonisdead, Jmu5667 and moster67 like this.
  4. ArminKH

    ArminKH Well-Known Member

    Thanks erel :)
     
  5. tufanv

    tufanv Expert Licensed User

    how do we end an application
    like in b4a : activity.finish or exitapplication
     
  6. Erel

    Erel Administrator Staff Member Licensed User

    There are ways to kill an app however Apple will not accept your app to the app store if you use those APIs.
     
  7. tufanv

    tufanv Expert Licensed User

    no i just want to end applciation when the user clicks exit button ?
     
  8. Erel

    Erel Administrator Staff Member Licensed User

    As I wrote there is no legitimate way to programmatically close an app in iOS.
     
  9. omidaghakhani1368

    omidaghakhani1368 Well-Known Member Licensed User

    Thank you Erel.I would like to successfully
     
  10. tufanv

    tufanv Expert Licensed User


    I forgot to implement to check the subscription status in one of my apps on application_foreground. It only checks at appication_start

    is this means that my app will always use app_foreground sub until user double clicks on home and closes app OR as you wrote above the process is killed shortly after app_background and for example 3 hours later when it is opened again it will use app_start instead of app_foreground ?

    ty
     
  11. Erel

    Erel Administrator Staff Member Licensed User

    You do not need to check it in application_foreground. The process will be killed a few minutes after the app is in the background. A new process always starts from Application_Start.
     
  12. tufanv

    tufanv Expert Licensed User

    Erel,

    I leave the app in background for 1-2 hours and when i click on the app icon again , it starts from where i left the app. It does not execute anything from the applicaiton_start
     
  13. JonPM

    JonPM Well-Known Member Licensed User

    I think what Erel was trying to say is that it isn't necessary to check subscription status every time your so app is brought to the foreground. Just check it once on app start like you are already doing, that is sufficient.
     
Loading...
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice