added NSBluetoothPeripheralUsageDescription to info.plist and code cleanup for self.requestNotificationAuthorization
This commit is contained in:
parent
5df1e75a17
commit
ac288f973e
|
@ -17,11 +17,13 @@
|
|||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>2.0.0</string>
|
||||
<string>2.0.1</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>2.0.0</string>
|
||||
<string>2.0.1</string>
|
||||
<key>LSRequiresIPhoneOS</key>
|
||||
<true/>
|
||||
<key>NSBluetoothPeripheralUsageDescription</key>
|
||||
<string>Connect to CGM Transmitter</string>
|
||||
<key>UIBackgroundModes</key>
|
||||
<array>
|
||||
<string>audio</string>
|
||||
|
|
|
@ -42,9 +42,6 @@ final class RootViewController: UIViewController {
|
|||
/// for logging
|
||||
private var log = OSLog(subsystem: Constants.Log.subSystem, category: Constants.Log.categoryFirstView)
|
||||
|
||||
/// did user authorize notifications ?
|
||||
private var notificationsAuthorized:Bool = false;
|
||||
|
||||
/// coreDataManager to be used throughout the project
|
||||
private var coreDataManager:CoreDataManager?
|
||||
|
||||
|
@ -127,18 +124,14 @@ final class RootViewController: UIViewController {
|
|||
// check if app is allowed to send local notification and if not ask it
|
||||
UNUserNotificationCenter.current().getNotificationSettings { (notificationSettings) in
|
||||
switch notificationSettings.authorizationStatus {
|
||||
case .notDetermined:
|
||||
self.requestNotificationAuthorization(completionHandler: { (success) in
|
||||
guard success else {
|
||||
os_log("failed to request notification authorization", log: self.log, type: .info)
|
||||
return
|
||||
case .notDetermined, .denied:
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (success, error) in
|
||||
if let error = error {
|
||||
os_log("Request Notification Authorization Failed : %{public}@", log: self.log, type: .error, error.localizedDescription)
|
||||
}
|
||||
self.notificationsAuthorized = true
|
||||
})
|
||||
case .denied:
|
||||
os_log("notification authorization denied", log: self.log, type: .info)
|
||||
}
|
||||
default:
|
||||
self.notificationsAuthorized = true
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -202,17 +195,6 @@ final class RootViewController: UIViewController {
|
|||
|
||||
}
|
||||
|
||||
/// request notification authorization to the user for alert, sound and badge
|
||||
private func requestNotificationAuthorization(completionHandler: @escaping (_ success: Bool) -> ()) {
|
||||
// Request Authorization
|
||||
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .sound, .badge]) { (success, error) in
|
||||
if let error = error {
|
||||
os_log("Request Notification Authorization Failed : %{public}@", log: self.log, type: .error, error.localizedDescription)
|
||||
}
|
||||
completionHandler(success)
|
||||
}
|
||||
}
|
||||
|
||||
private func processNewCGMInfo(glucoseData: inout [RawGlucoseData], sensorState: SensorState?, firmware: String?, hardware: String?, transmitterBatteryInfo: TransmitterBatteryInfo?, sensorTimeInMinutes: Int?) {
|
||||
|
||||
// check that calibrations and coredata manager is not nil
|
||||
|
|
Loading…
Reference in New Issue