Read Alarms in iOS

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

Published by

alanyip

My name is Alan Yip, a programmer and security researcher from Hong Kong. I create tweaks for iOS and do security research.

4 thoughts on “Read Alarms in iOS”

  1. 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!

Leave a Reply