ios - 删除应用后是否可以取消所有通知?

标签 ios cocoa-touch notifications uilocalnotification

我正在开发一个提醒到期日期的应用程序。我使用 Uilocanotification 和重复间隔(NSMonthCalendarUnitNSDayCalendarUnitNSDayCalendarUnit)实现了相同的功能。

例如。我已于 03/10/2012 设置了本地通知 如果我从 iPad/iPhone 中删除该应用程序。我再次重新安装应用程序,我仍然收到重新安装之前设置的旧通知。删除应用程序时是否可以cancelallNotification

最佳答案

我的猜测是,您可以在安装应用程序并运行以下命令时进行一次性检查:

- (void)cancelAllLocalNotifications

NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if([defaults objectForKey:@"FIRST-TIME-CHECK"] == null){
      [[UIApplication sharedApplication] cancelAllLocalNotifications];
      [defaults setValue:@"WHATEVER" forKey:@"FIRST-TIME-CHECK"];
}

关于ios - 删除应用后是否可以取消所有通知?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12390655/

相关文章:

android - gcm.notification.e=1 在 Android 上的推送通知负载中代表什么?

android - Firebase 云消息传递 : push notification and navigate to specific page of application

ios - 为什么 MPMusicPlayerController MPMusicPlayerControllerPlaybackStateDidChangeNotification 调用两次?

ios - 点击时突出显示 uicollectionview 单元格

ios - 我们可以在应用程序尚未完成仍在开发时提交 iOS 应用程序以供 facebook 登录审核吗?

iphone - Xcode 3.2 中的 SenTestCase 和 XCBuildLogCommandInvocationSection 错误

ios - 检测 Xcode 中某个对象的触摸

ios - 约束变化不起作用

ios - 仅适用于iOS7用户在App Store上提交现有应用的新版本。可能吗?

ios - 清除 UIWebview 缓存