ios - 如何防止 ios 中的本地通知重复?

标签 ios notifications local uilocalnotification

  • evenArray[] 包含本地通知列表
  • 我有创建本地通知的功能,但它在编辑和添加模块中调用,所以它多次调用并复制本地通知
  • 请告诉我如何使用我当前的通知检查此数组中的通知的条件,我将仅在它不重复时创建该通知。

这是通知,我需要哪个参数来将我的通知与这个“144=mas”进行比较,144 是唯一的,索引也是唯一的

 "<UIConcreteLocalNotification: 0x118b08c0>{fire date = Monday, September 29, 2014 at 6:12:00 PM India Standard Time, time zone = Asia/Kolkata (GMT+5:30) offset 19800, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Monday, September 29, 2014 at 6:12:00 PM India Standard Time, user info = {\n    144 = mas;\n    index = 63;\n    userid = \"821e25e7-d76c-4328-bbba-8e367dc70c04\";\n}}",
"<UIConcreteLocalNotification: 0x118b0cc0>{fire date = Monday, September 29, 2014 at 6:12:00 PM India Standard Time, time zone = Asia/Kolkata (GMT+5:30) offset 19800, repeat interval = NSWeekCalendarUnit, repeat count = UILocalNotificationInfiniteRepeatCount, next fire date = Monday, September 29, 2014 at 6:12:00 PM India Standard Time, user info = {\n    153 = mbg;\n    index = 64;\n    userid = \"821e25e7-d76c-4328-bbba-8e367dc70c04\";\n}}"

)

最佳答案

您可以通过使用 [[UIApplication sharedApplication] cancelLocalNotification:(UILocalNotification *)][[UIApplication sharedApplication] cancelAllLocalNotifications] 清除之前的通知来阻止它。

您还可以在 [[UIApplication sharedApplication] scheduledLocalNotifications] 中使用带有计划通知的 NSArray。

通过这些方法,您应该能够管理您的通知。

关于ios - 如何防止 ios 中的本地通知重复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26012515/

相关文章:

ios - 根据通知数量增加角标(Badge)值

ruby - 扩展 ActiveSupport::Notifications.subscribe, instantiation.active_record 钩子(Hook)

对本地 apache 服务器的 Java http 请求 - UnknownHostException

c - c中char的默认值是多少

ios - 如何将 UICollectionViewCell 从一个 UICollectionView 拖到另一个 UICollectionView?

ios - 查找 UIImage 的左边缘颜色

objective-c - 一个 View 中的两个 UIPopover

java - Swift 在 Kotlin(或 Java)中的结构?同一类的多个实例,改变其变量

delphi - 服务器代码在单个 Delphi 应用程序中通知多个客户端数据更改的首选方式是什么?

node.js 管理频繁变化的本地依赖