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

objective-c - 向 LocalNotifications 发出振动和声音


                                            <p><p>如何为 LocalNotifaction 添加振动和声音</p>

<p>代码:</p>

<pre><code>UILocalNotification *notification = [init];

NSDate *firedate = settime.date;
;
;
;



[scheduleLocalNotification:notification];
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>你可以设置声音:</p>

<pre><code>notification.soundName = @&#34;yourSound.aiff&#34; ;   // see also UILocalNotificationDefaultSoundName
</code></pre>

<p>但振动不在你的控制范围内:</p>

<p></p>

<blockquote>
<p>Unfortunately, if you want a sound, you can&#39;t disable vibration unless the user has went into the General Settings and disabled vibration themselves.
<a href="https://stackoverflow.com/a/9451489/1523962" rel="noreferrer noopener nofollow">-shabzco</a></p>
</blockquote>

<p></p>

<blockquote>
<p>The UILocalNotification API lets you set the system default sound, choose a sound, or have no sound, and if you have some sound, it will vibrate under the right circumstances (i.e., the user has enabled vibration). But beyond that, you have no control over whether vibration occurs or how long it lasts.
<a href="https://stackoverflow.com/a/9320512/1523962" rel="noreferrer noopener nofollow">-yuji</a></p>
</blockquote></p>
                                   
                                                <p style="font-size: 20px;">关于objective-c - 向 LocalNotifications 发出振动和声音,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/14084175/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/14084175/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: objective-c - 向 LocalNotifications 发出振动和声音