mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-19 21:15:21 +00:00
COVIDSafe code from version 1.5 (#5)
This commit is contained in:
parent
6b262be150
commit
149daee2e9
21 changed files with 825 additions and 652 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue