gpt4 book ai didi

iphone - 访问和设置 iphone 默认闹钟

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:47:42 26 4
gpt4 key购买 nike

我想访问 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 before isActive may be a way to read whether the alarm is enabled or not.

关于iphone - 访问和设置 iphone 默认闹钟,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14494890/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com