How to create multiple Local Notifications

后端 未结 2 581
北荒
北荒 2021-01-15 15:58

I\'m trying to create multiple local notifications, in my app, but for some reason only the First Notification Pop\'s up, the rest just does not work, this is my code.

2条回答
  •  萌比男神i
    2021-01-15 16:30

    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;
    

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

    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];
    

提交回复
热议问题