mirror of
https://github.com/AU-COVIDSafe/mobile-ios.git
synced 2025-04-19 04:55:19 +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
63
CovidSafe/AppSettingsViewController.swift
Normal file
63
CovidSafe/AppSettingsViewController.swift
Normal file
|
@ -0,0 +1,63 @@
|
|||
//
|
||||
// AppSettingsViewController.swift
|
||||
// CovidSafe
|
||||
//
|
||||
// Copyright © 2020 Australian Government. All rights reserved.
|
||||
//
|
||||
|
||||
import UIKit
|
||||
import CoreBluetooth
|
||||
import UserNotifications
|
||||
|
||||
class AppSettingsViewController: UIViewController {
|
||||
private var backupSensorDidUpdateStateCallback: ((SensorState, SensorType?) -> Void)?
|
||||
|
||||
@IBOutlet weak var stepCounterLabel: UILabel!
|
||||
@IBOutlet weak var topContentTextView: UITextView!
|
||||
|
||||
override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
stepCounterLabel.text = String.localizedStringWithFormat( "stepCounter".localizedString(),
|
||||
4,
|
||||
4
|
||||
)
|
||||
topContentTextView.addLink("\(URLHelper.getHelpURL())#location-permission-android", enclosedIn: "*")
|
||||
topContentTextView.addAllBold(enclosedIn: "#")
|
||||
}
|
||||
|
||||
@IBAction func proceedTapped(_ sender: UIButton) {
|
||||
self.backupSensorDidUpdateStateCallback = BluetraceManager.shared.sensorDidUpdateStateCallback
|
||||
BluetraceManager.shared.sensorDidUpdateStateCallback = sensorManagerDidUpdateBluetoothCallback
|
||||
BluetraceManager.shared.turnOnBLE()
|
||||
UserDefaults.standard.set(true, forKey: "turnedOnBluetooth")
|
||||
}
|
||||
|
||||
func sensorManagerDidUpdateBluetoothCallback(_ state: SensorState, type: SensorType?) {
|
||||
DLog("Bluetooth state changed in permission request to \(state.rawValue)")
|
||||
requestPushPermissions()
|
||||
}
|
||||
|
||||
func sensorManagerDidUpdateLocationCallback(_ state: SensorState, type: SensorType?) {
|
||||
DLog("Location state changed in permission request to \(state.rawValue)")
|
||||
|
||||
UserDefaults.standard.set(true, forKey: "allowedPermissions")
|
||||
BluetraceManager.shared.sensorDidUpdateStateCallback = self.backupSensorDidUpdateStateCallback
|
||||
DispatchQueue.main.async {
|
||||
self.performSegue(withIdentifier: "showSuccessSegue", sender: self)
|
||||
}
|
||||
}
|
||||
|
||||
func requestPushPermissions() {
|
||||
|
||||
UNUserNotificationCenter.current()
|
||||
.requestAuthorization(options: [.alert, .sound, .badge]) {
|
||||
granted, error in
|
||||
print("Permissions granted: \(granted)")
|
||||
DispatchQueue.main.async {
|
||||
UIApplication.shared.registerForRemoteNotifications()
|
||||
BluetraceManager.shared.sensorDidUpdateStateCallback = self.sensorManagerDidUpdateLocationCallback
|
||||
BluetraceManager.shared.turnOnLocationSensor()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue