Pausing game in iphone when changing the current running app

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cmdrsteel

How would I get a game to pause when changing the current running app from godot to something else such as the home screen on the iphone? Is it also similar with andriod?

:bust_in_silhouette: Reply From: andersmmg

On any OS, you can use both NOTIFICATION_WM_FOCUS_IN and NOTIFICATION_WM_FOCUS_OUT.
Example:

func _notification(what):
	match what:
		MainLoop.NOTIFICATION_WM_FOCUS_OUT:
			pass # Pause the game
		MainLoop.NOTIFICATION_WM_FOCUS_IN:
			pass # Continue game

More info: Handling quit requests