Dismiss an already delivered UILocalNotification?

后端 未结 6 1439
无人及你
无人及你 2020-12-20 14:40

Is it possible to do this? UIApplication\'s scheduledLocalNotifications doesn\'t seem to return notifications that have already been delivered to t

6条回答
  •  独厮守ぢ
    2020-12-20 15:10

    You can do it when you schedule the notification if you also save it in NSUserDefaults, using NSKeyedArchiver to convert it to NSData.

    To get it back as UILocalNotification you use NSKeyedUnarchiver. Then you're able to delete it using the cancelLocalNotification method.

    Fully explained here (Swift version + link to original Obj-C solution)

提交回复
热议问题