From 6f77eb088120c799fb735ff1b1a62f1206041ee3 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Thu, 28 Jan 2021 02:05:08 -0500 Subject: [PATCH] [O] Put notification permission request in the correct location --- ProjectClock/AlarmActivator.swift | 12 ++++++++++++ ProjectClock/AlarmViewController.swift | 9 --------- ProjectClock/DebugViewController.swift | 9 --------- 3 files changed, 12 insertions(+), 18 deletions(-) diff --git a/ProjectClock/AlarmActivator.swift b/ProjectClock/AlarmActivator.swift index 2f48d1b..8f757d4 100644 --- a/ProjectClock/AlarmActivator.swift +++ b/ProjectClock/AlarmActivator.swift @@ -25,9 +25,21 @@ class AlarmActivator: UITabBarController /// Timer for getting family alarm updates var familyTimer: Timer? + /** + Called when the app started + */ override func viewDidLoad() { start() + + // Get notification permissions from user + UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in + if success { + print("All set!") + } else if let error = error { + print(error.localizedDescription) + } + } } /** diff --git a/ProjectClock/AlarmViewController.swift b/ProjectClock/AlarmViewController.swift index 64090eb..46019fa 100644 --- a/ProjectClock/AlarmViewController.swift +++ b/ProjectClock/AlarmViewController.swift @@ -8,15 +8,6 @@ class AlarmViewController: UIViewController override func viewDidLoad() { super.viewDidLoad() - - //Get notification permissions from user - UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in - if success { - print("All set!") - } else if let error = error { - print(error.localizedDescription) - } - } // Assign table delegate and data source AlarmViewController.staticTable = table diff --git a/ProjectClock/DebugViewController.swift b/ProjectClock/DebugViewController.swift index 19af623..fc788f3 100644 --- a/ProjectClock/DebugViewController.swift +++ b/ProjectClock/DebugViewController.swift @@ -21,15 +21,6 @@ class DebugViewController: EndEditingOnReturn super.viewDidLoad() wvmStepper.maximumValue = Double(wvms.count - 1) - // Request notification permission - UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { success, error in - if success { - print("All set!") - } else if let error = error { - print(error.localizedDescription) - } - } - // End editing on return wvmInput.delegate = self }