Nominate our 2022 Qt Champions!

Re-initializing an iOS app

  • I have noticed that many apps for iOS which require external network services will re-initialize themselves upon waking up from a suspended state, up to and including bringing up the initial splash screen. Is there any trick to this, other than manually cleaning up the app?

  • Lifetime Qt Champion


    Depending on what you want to do you will have to do some native code. Have a look at QIOSViewController and particularly viewDidLoad. You'll need to add an observer for the UIApplicationDidBecomeActiveNotification notification.

  • @SGaist Looking at

    I don't really see anything there that's relevant to my question. I'm trying to figure out if there is a way to re-initialize my iOS app when it gets foreground context back. I see other apps do it. For example, Clash of Clans. When it gets suspended, and you bring the app back to the foreground, it comes back up with the last screen shown and then within a second or two, it goes back to the splash screen sequence and re-initializes the app. Our app is written as if it were a pretty non-tablet app, so I was wondering if there were a "trick" for doing stuff like that on tablets, such as a state machine, etc, to make that initialization happen, or is it done the traditional way.

    I apologize if my question is not clear. I am not sure I a communicating well

  • Lifetime Qt Champion

    Well, that's the starting point. You have to catch the notifications and act accordingly. viewDidLoad is called when your view comes to life and UIApplicationDidBecomeActiveNotification is what you will receive to tell you that the application became active so you can do what you want e.g. reinitialize stuff etc.

  • @SGaist OK, I understand now. Thanks!

Log in to reply