我想访问iphone默认闹钟并根据用户提交的日期设置闹钟。我还希望用户更改闹钟的声音。 是否有可能做到这一点,如果有可能我该怎么做? 那有任何可用的代码吗? 请帮助我摆脱困境。
-提前致谢。
您可以使用此代码读取 iOS 默认警报,但这是一种未记录的方法,在 App Store 中是不允许的。
以下是 Alan Yip 的帖子,抄自 http://blog.alanyip.me/read-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
Lastly, calling
refreshActiveState
beforeisActive
may be a way to read whether the alarm is enabled or not.
关于iphone - 访问和设置 iphone 默认闹钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14494890/
欢迎光临 OStack程序员社区-中国程序员成长平台 (https://ostack.cn/) | Powered by Discuz! X3.4 |