删除推送通知Remove Push Notifications from Notification Center in iOS

If the notification is local, it’s easy by

如果是本地通知,下面的代码就解决了。

[[UIApplication sharedApplication] cancelAllLocalNotifications];

But if the notifications come from the push notification, this does’t work.

但是如果是来自于推送的话,这不管用。

After search and try, only the third method in a blog works, although it’s weird.

搜了很久发现有一个办法可以解决,虽然这个办法非常怪异。

UIApplication* application = [UIApplication sharedApplication];

NSArray* scheduledNotifications = [NSArray arrayWithArray:application.scheduledLocalNotifications];

application.scheduledLocalNotifications = scheduledNotifications;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容