Accessing and setting the default alarm for iphone

I want to access the iphone default alarm and set the alarm according to the date provided by the user. I also want the user to change the alarm sound. Is it possible to do this, and if possible, how can I do it? Is this some kind of code for this? Please help me get me out of this.

-Thanks in advance.

+2


source to share


2 answers


If you think you have access to iphone by default . there is no way to do it. In any case, if you find a way to do this, you definitely won't be able to get into the App Store.



If you want to create an alarm clock app ... you must use Scheduling Local Notifications

+2


source


You might be able to read the iOS default alarm with this code, but this is an undocumented method and won't be allowed in the App Store.

Below is Alan Ip's post copied from http://blog.alanyip.me/read-alarms-in-ios/



There is a private framework ( MobileTimer.framework ) natively for the iOS app for stock, a clock to manage the clock and the alarm system.

Obviously, we will only use two classes when dealing with alarms, AlarmManager and Alarm . First, we need to get a singleton instance of the AlarmManager .

AlarmManager *manager = [AlarmManager sharedManager];

      

Before accessing the alarms, you must first download the alarms.

[manager loadAlarms];

      

You can then access an array containing all the available alarms ( Alarm ) in the watch app.

NSArray *alarms = [manager alarms];

      

However, there is a problem when loading alarm messages. For example, the code runs in SpringBoard, while at the same time when alarms change in the watch clock app. Even if you upload the alarms to SpringBoard again, the returned alarms are out of date. To fix this, hook up a class method in AlarmManager to force the preference values ​​to sync before the original method read from preference.

%hook AlarmManager

+ (id)copyReadAlarmsFromPreferences {
  CFPreferencesAppSynchronize(CFSTR("com.apple.mobiletimer"));
  return %orig;
}

%end

      

Finally, calling refreshActiveState

up isActive

can be a way to read whether the alarm is on or not.

+2


source







All Articles