私はSwift3を使ってIOSアプリを開発しています。ユーザーが認証されると、私はsessionTokenを取得しています。私は、ユーザがバックグラウンドでアプリケーションを置いて再度開くときに、ユーザがログオンしているかどうかをチェックしたい。これらの小切手はどこで扱いますか?これらを検証するために、AppDelegate.swiftオーバーライドメソッドを使用する必要がありますか?それとも別の場所で行うべきですか?セッションの検証/管理のベストプラクティス?
また、私はユーザーの不活性をどのように処理するか知りたいと思います。ユーザーがアクティブでない場合に自動的にログアウトする方法(アプリのアクティブ状態とバックグラウンド状態の両方でタッチイベントが検出されない)
アプリケーションの構造: 1. LoginViewController(デフォルトのランディング画面) 2. HomeScreen->あなたはライオンのことができます述べたように、2つの方法、
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}
// OR
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}