Created
July 22, 2021 20:41
-
-
Save SergLam/fdc4876802630cd9a426a1467250eca4 to your computer and use it in GitHub Desktop.
CloseAppElegantly.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
func quit() { | |
// home button pressed programmatically - to thorw app to background | |
DispatchQueue.main.async { | |
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil) | |
// terminaing app in background | |
DispatchQueue.main.asyncAfter(deadline: .now() + .seconds(1), execute: { | |
exit(EXIT_SUCCESS) | |
}) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment