Quit request on iOS.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By lukas
:warning: Old Version Published before Godot 3 was released.

I have 2 questions related to quitting the game on devices with iOS.

  1. How to quit game on iOS?
    get_tree().quit() doesn’t work for me.

  2. How to get iPhone’s home button press notification?

:bust_in_silhouette: Reply From: lukas

1: It is against Apple’s rule to display quit and close request on iOS. Here is citation from Apple developer’s instruction:

People stop using an app when they switch to another app, return to the Home screen, or put their devices in sleep mode.

2: Using this for other purposes than send signal to save data can be again considered as going against Apple’s conventions because it overrides function of iPhone’s home button.

:bust_in_silhouette: Reply From: volzhs

How to get iPhone’s home button press notification?

func _notification(what):
	if what == MainLoop.NOTIFICATION_WM_FOCUS_IN:
		print("NOTIFICATION_WM_FOCUS_IN")
	elif what == MainLoop.NOTIFICATION_WM_FOCUS_OUT:
		print("NOTIFICATION_WM_FOCUS_OUT")