mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-19 21:15:21 +00:00
COVIDSafe code from version 2.0 (#37)
This commit is contained in:
parent
cf93ea43c0
commit
8b75c1fc6f
55 changed files with 4624 additions and 1117 deletions
45
CovidSafe/RegistrationIntroViewController.swift
Normal file
45
CovidSafe/RegistrationIntroViewController.swift
Normal file
|
@ -0,0 +1,45 @@
|
|||
//
|
||||
// RegistrationIntroViewController.swift
|
||||
// CovidSafe
|
||||
//
|
||||
// Copyright © 2020 Australian Government. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import SafariServices
|
||||
import KeychainSwift
|
||||
|
||||
class RegistrationIntroViewController: UIViewController {
|
||||
|
||||
let keychain = KeychainSwift()
|
||||
|
||||
override func viewWillAppear(_ animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
switch UIApplication.shared.isProtectedDataAvailable {
|
||||
case true :
|
||||
checkToken()
|
||||
break
|
||||
case false:
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(setKeychainAvailable(_:)), name: UIApplication.protectedDataDidBecomeAvailableNotification, object: nil)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@objc
|
||||
func setKeychainAvailable(_ notification: Notification) {
|
||||
NotificationCenter.default.removeObserver(self, name: UIApplication.protectedDataDidBecomeAvailableNotification, object: nil)
|
||||
checkToken()
|
||||
}
|
||||
|
||||
func checkToken() {
|
||||
let isLoggedIn: Bool = (keychain.get("JWT_TOKEN") != nil)
|
||||
|
||||
if isLoggedIn {
|
||||
DispatchQueue.main.async {
|
||||
let homeVC = HomeViewController(nibName: "HomeView", bundle: nil)
|
||||
self.navigationController?.setViewControllers([homeVC], animated: true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue