[+] Start alarm detector on app start

This commit is contained in:
Hykilpikonna
2021-01-17 10:33:29 -05:00
parent 30756d32aa
commit 879689a10a
2 changed files with 16 additions and 14 deletions
+2 -2
View File
@@ -13,7 +13,7 @@ import Foundation
class AlarmActivator
{
/// Interval in seconds
static var interval = 1
static var interval = 1.0
/// Timer for scheduled calls
var timer: Timer?
@@ -24,7 +24,7 @@ class AlarmActivator
func start()
{
if timer != nil { return }
timer = Timer.scheduledTimer(timeInterval: 5, target: self, selector: #selector(AlarmActivator.check), userInfo: nil, repeats: true)
timer = Timer.scheduledTimer(timeInterval: AlarmActivator.interval, target: self, selector: #selector(AlarmActivator.check), userInfo: nil, repeats: true)
}
/**
+14 -12
View File
@@ -8,29 +8,31 @@
import UIKit
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
class AppDelegate: UIResponder, UIApplicationDelegate
{
var alarmActivator: AlarmActivator!
func application(_ app: UIApplication, didFinishLaunchingWithOptions op: [UIApplication.LaunchOptionsKey: Any]?) -> Bool
{
// Override point for customization after application launch.
alarmActivator = AlarmActivator()
alarmActivator.start()
return true
}
// MARK: UISceneSession Lifecycle
func application(_ application: UIApplication, configurationForConnecting connectingSceneSession: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration {
func application(_ app: UIApplication, configurationForConnecting session: UISceneSession, options: UIScene.ConnectionOptions) -> UISceneConfiguration
{
// Called when a new scene session is being created.
// Use this method to select a configuration to create the new scene with.
return UISceneConfiguration(name: "Default Configuration", sessionRole: connectingSceneSession.role)
return UISceneConfiguration(name: "Default Configuration", sessionRole: session.role)
}
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {
func application(_ app: UIApplication, didDiscardSceneSessions sessions: Set<UISceneSession>)
{
// Called when the user discards a scene session.
// If any sessions were discarded while the application was not running, this will be called shortly after application:didFinishLaunchingWithOptions.
// Use this method to release any resources that were specific to the discarded scenes, as they will not return.
}
}