COVIDSafe code from version 1.5 (#5)

This commit is contained in:
COVIDSafe Support 2020-06-05 10:26:40 +10:00 committed by GitHub
parent 6b262be150
commit 149daee2e9
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
21 changed files with 825 additions and 652 deletions

View file

@ -6,11 +6,39 @@
//
import UIKit
import CoreBluetooth
import UserNotifications
class OnboardingStep2ViewController: UIViewController {
private var bluetoothDidUpdateStateCallback: ((CBManagerState) -> Void)?
@IBAction func onBackTapped(_ sender: UIButton) {
self.navigationController?.popViewController(animated: true)
}
@IBAction func proceedTapped(_ sender: UIButton) {
self.bluetoothDidUpdateStateCallback = BluetraceManager.shared.bluetoothDidUpdateStateCallback
BluetraceManager.shared.bluetoothDidUpdateStateCallback = centralDidUpdateStateCallback
BluetraceManager.shared.turnOn()
UserDefaults.standard.set(true, forKey: "turnedOnBluetooth")
}
func centralDidUpdateStateCallback(_ state: CBManagerState) {
DLog("state changed in permission request to \(BluetraceUtils.centralStateToString(state))")
requestPushPermissions()
}
func requestPushPermissions() {
BluetraceManager.shared.bluetoothDidUpdateStateCallback = self.bluetoothDidUpdateStateCallback
UNUserNotificationCenter.current()
.requestAuthorization(options: [.alert, .sound, .badge]) {
granted, error in
UserDefaults.standard.set(true, forKey: "allowedPermissions")
print("Permissions granted: \(granted)")
DispatchQueue.main.async {
self.performSegue(withIdentifier: "showSuccessSegue", sender: self)
}
}
}
}