Added WakeMethod differentiation
This commit is contained in:
@@ -11,11 +11,24 @@ import AVFoundation
|
||||
class AlarmActivationViewController: UIViewController
|
||||
{
|
||||
var timer: Timer?
|
||||
var currentAlarm: Alarm?
|
||||
|
||||
init?(coder: NSCoder, currentAlarm: Alarm)
|
||||
{
|
||||
self.currentAlarm = currentAlarm
|
||||
//print(currentAlarm.wakeMethod)
|
||||
super.init(coder: coder)
|
||||
}
|
||||
|
||||
required init?(coder: NSCoder) {
|
||||
fatalError("init(coder:) has not been implemented")
|
||||
}
|
||||
|
||||
override func viewDidLoad()
|
||||
{
|
||||
super.viewDidLoad()
|
||||
timer = Timer.scheduledTimer(timeInterval: 1, target: self, selector: #selector(AlarmActivationViewController.playSound), userInfo: nil, repeats: true)
|
||||
setAlarmType()
|
||||
}
|
||||
|
||||
@objc func playSound()
|
||||
@@ -23,4 +36,23 @@ class AlarmActivationViewController: UIViewController
|
||||
AudioServicesPlayAlertSound(SystemSoundID(1005))
|
||||
AudioServicesPlayAlertSound(kSystemSoundID_Vibrate)
|
||||
}
|
||||
|
||||
func setAlarmType()
|
||||
{
|
||||
if let alarm = currentAlarm
|
||||
{
|
||||
switch alarm.wakeMethod.name {
|
||||
case "Walk":
|
||||
walkAction()
|
||||
case "Jump":
|
||||
jumpAction()
|
||||
case "Puzzle":
|
||||
puzzleAction()
|
||||
case "Smash":
|
||||
print("")
|
||||
default:
|
||||
print("Invalid alarm type")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user