且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何创建多个本地通知

更新时间:2023-01-14 23:20:02

问题是,您正在覆盖当前通过调用 -setarNotificacao:nome:函数调度的所有本地通知。这一行

The problem is that you're overwriting all of the local notifications currently scheduled with the call to your -setarNotificacao:nome: function. This line

    myapp.scheduledLocalNotifications = arrayOfNOtifications;

将所有当前安排的通知设置为 arrayOfNotifications ;如果当前安排的通知不在该数组中,则会被取消。

sets all of the currently scheduled notifications to arrayOfNotifications; if a notification currently scheduled is not in that array, then it is canceled.

修复方法是使用 - [UIApplication scheduleLocalNotification:] 方法来安排通知,该通知会添加给定的通知而不取消已安排的任何通知:

The fix is to use the -[UIApplication scheduleLocalNotification:] method to schedule the notification, which adds the given notification without canceling any notifications already scheduled:

[myapp scheduleLocalNotification:notification];