Notice: This method is undocumented and only for tweaks or apps that will not be submitted to AppStore.
This article will introduce a way to read (or add, but not included here) alarms in iOS. There is a private framework (MobileTimer.framework) originally provided for iOS stock app, Clock to manipulate clocks and system alarms.
Obviously, we will only use two classes when dealing with alarms, AlarmManager and Alarm. First, we have to get the singleton instance of AlarmManager.
AlarmManager *manager = [AlarmManager sharedManager];
Before accessing the alarms, it is required to load alarms first.
[manager loadAlarms];
Then, you can access the array containing all available alarms (Alarm) in Clock app.
NSArray *alarms = [manager alarms];
However, there is a problem in the framework when loading the alarms. For example, the code is running in SpringBoard, while at the same time the alarms are being modified in stock Clock app. Even if you load alarms in SpringBoard again, the alarm data returned are still outdated. To fix this, hook a class method in AlarmManager to force synchronizing the preference values before the original method read from the preference.
%hook AlarmManager + (id)copyReadAlarmsFromPreferences { CFPreferencesAppSynchronize(CFSTR("com.apple.mobiletimer")); return %orig; } %end
is there a way to read whether the alarm is enabled or not? I’ve tried the “isActive” method, but it always return NO.
Have you tried calling “refreshActiveState” before “isActive”?
Did you ever figure this out? I’m trying to determine if an Alarm is enabled or disabled.
Hi, Quick question. I’m trying to do this myself for my own personal use project (the 30 sec UILocalNotification sounds is not long enough). My project is compiling fine; I’ve added MobileTimer framework and headers to my project, but [manager alarms] keeps coming back as an empty NSArray. Do I need to be jailbroken? Shouldn’t this work without jailbreak (assuming i don’t use hook)
Thanks!