菜鸟教程小白 发表于 2022-12-11 20:25:49

ios - 如何设置 UILocalNotification 的过期时间?


                                            <p><p>我想显示一个 <code>UILocalNotification</code>,但它只会在 24 小时内有效。在 24 小时结束时,我希望通知“过期”;即:用户不能再看到过时的通知。我该怎么做?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>要取消已发送的通知,请使用</p>

<p><code>UNUserNotificationCenter.current().removeDeliveredNotifications(withIdentifiers: ["myidentifier"])</code></p>

<p>或</p>

<pre><code>UNUserNotificationCenter.current().removeAllDeliveredNotifications()
</code></pre>

<p>此答案中的示例代码:<a href="https://stackoverflow.com/a/45218609/2650588" rel="noreferrer noopener nofollow">https://stackoverflow.com/a/45218609/2650588</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 如何设置 UILocalNotification 的过期时间?,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/7957502/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/7957502/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 如何设置 UILocalNotification 的过期时间?