[iOS & Android] App Background / Foreground Events

Godot Version

v4.2.1

Question

I’m working on a mobile game and I need an event when the app enters the foreground after previously background. I need to be able to detect this on iOS and Android.

I’m having trouble with iOS specifically, and I’ve tried the following:

  • MainLoop.NOTIFICATION_APPLICATION_RESUMED
  • MainLoop.NOTIFICATION_APPLICATION_FOCUS_IN

I need something equivalent to applicationDidBecomeActive applicationDidBecomeActive(_:) | Apple Developer Documentation

Does this already exist somewhere? Or would it be easy to add to the engine / would it be possible to handle in a plugin?

Thanks

Similar issue: How to detect the app enter into the background or become foreground on mobile device? - #2 by system

This looks like it should work, but it’s not working for me on a TestFlight build on my iPhone.

Looks like the fix is in 4.3 :+1:

1 Like