ID by amoのアプリを閉じる挙動を再現
ID by amoにて新着通知を全て確認し終わると、「おわり!」「そっちでも楽しんでね」などのメッセージと共にアプリが終了する
https://scrapbox.io/files/6566b2e4698aa20023c35fd8.mov
これをSwiftでやるには任意の場所で以下を実行する
code:Swift
import Foundation
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
Timer.scheduledTimer(withTimeInterval: 0.2, repeats: false) { _ in
exit(0)
}
UIControl().sendAction(#selector(URLSessionTask.suspend), to: UIApplication.shared, for: nil)
ホーム画面に戻る
exit(0)はCの標準ライブラリに存在する関数
プログラムを正常終了させるもの
引用元
Swift アプリ起動中に、コードによりホーム画面に戻る方法 #Swift - Qiita
ChatGPTに質問してみた
https://chat.openai.com/share/a0083074-a786-4270-b4b4-d7ed4cb14da6