From 7089e480aeb1bcef4a4fbf367929949cd757a585 Mon Sep 17 00:00:00 2001 From: Hykilpikonna Date: Wed, 27 Jan 2021 18:30:08 -0500 Subject: [PATCH] [+] Check if accelerometer is available --- ProjectClock/AlarmActivationViewController.swift | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/ProjectClock/AlarmActivationViewController.swift b/ProjectClock/AlarmActivationViewController.swift index 3baecbd..e0244d1 100644 --- a/ProjectClock/AlarmActivationViewController.swift +++ b/ProjectClock/AlarmActivationViewController.swift @@ -87,8 +87,16 @@ class AlarmActivationViewController: UIViewController */ func runAlarm() { + // Check if the device has accelerometer + var wvm = currentAlarm.wakeMethod.name + if wvm == "Shake" && !motion.isAccelerometerAvailable + { + msg("Error", "Accelerometer is not available on your device, so shaking your phone wouldn't work.") + wvm = "Factor" + } - switch currentAlarm.wakeMethod.name + // Initialize alarm + switch wvm { case "Factor": initFactorProblem()