菜鸟教程小白 发表于 2022-12-13 00:40:08

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


                                            <p><p>我想访问iphone默认闹钟并根据用户提交的日期设置闹钟。我还希望用户更改闹钟的声音。
是否有可能做到这一点,如果有可能我该怎么做?
那有任何可用的代码吗?
请帮助我摆脱困境。</p>

<p>-提前致谢。</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>您可以使用此代码<em>读取</em> iOS 默认警报,但这是一种未记录的方法,在 App Store 中是不允许的。</p>

<p>以下是 Alan Yip 的帖子,抄自 <a href="http://blog.alanyip.me/read-alarms-in-ios/" rel="noreferrer noopener nofollow">http://blog.alanyip.me/read-alarms-in-ios/</a> </p>

<blockquote>
<p>There is a private framework (<a href="https://github.com/caughtinflux/iOS6-Private-Frameworks/tree/master/MobileTimer.framework" rel="noreferrer noopener nofollow">MobileTimer.framework</a>) originally
provided for iOS stock app, Clock to manipulate clocks and system
alarms.</p>

<p>Obviously, we will only use two classes when dealing with alarms,
<a href="https://github.com/caughtinflux/iOS6-Private-Frameworks/blob/master/MobileTimer.framework/AlarmManager.h" rel="noreferrer noopener nofollow">AlarmManager</a> and <a href="https://github.com/caughtinflux/iOS6-Private-Frameworks/blob/master/MobileTimer.framework/Alarm.h" rel="noreferrer noopener nofollow">Alarm</a>. First, we have to get the singleton
instance of <strong>AlarmManager</strong>.</p>

<pre><code>AlarmManager *manager = ;
</code></pre>

<p>Before accessing the alarms, it is required to load alarms first.</p>

<pre><code>;
</code></pre>

<p>Then, you can access the array containing all available alarms
(<strong>Alarm</strong>) in Clock app.</p>

<pre><code>NSArray *alarms = ;
</code></pre>

<p>However, there is a problem in the framework when loading the alarms.
For example, thecode 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 <strong>AlarmManager</strong> to
force synchronizing the preference values before the original method
read from the preference.</p>

<pre><code>%hook AlarmManager

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

%end
</code></pre>

<p>Lastly, calling <code>refreshActiveState</code> before <code>isActive</code> may be a way to
read whether the alarm is enabled or not.</p>
</blockquote></p>
                                   
                                                <p style="font-size: 20px;">关于iphone - 访问和设置 iphone 默认闹钟,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/14494890/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/14494890/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: iphone - 访问和设置 iphone 默认闹钟