2017-06-07 18 views
0

私は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. 
} 

答えて

0

両方の機能を処理します。リクエストしたユースケースを完了します。

ケース1:アプリが終了しているとき。

func applicationDidBecomeActive(_ application: UIApplication) { 
    } 

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { 
} 

でタイマーを無効

func applicationWillResignActive(_ application: UIApplication) { 

     //Start a timer to invoke a method and handle your session clear and local notification to inform user in that method. 

    } 

・ホープ、このことができます:

func applicationWillTerminate(_ application: UIApplication) { 
} 

ケース2にハンドル。

0

以下を見てとることができます2.1のUserList

関連する問題