- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我有这个本地通知代码,我有一个 scheduleNotification 和 clearNotification 使用我自己的方法。这些是代码:
- (void)clearNotification {
[[UIApplication sharedApplication] cancelAllLocalNotifications];
}
- (void)scheduleNotification {
[reminderText resignFirstResponder];
[[UIApplication sharedApplication] cancelAllLocalNotifications];
Class cls = NSClassFromString(@"UILocalNotification");
if (cls != nil) {
UILocalNotification *notif = [[cls alloc] init];
notif.fireDate = [[datePicker date] dateByAddingTimeInterval:-30];
notif.timeZone = [NSTimeZone defaultTimeZone];
notif.alertBody = @"Evaluation Planner";
notif.alertAction = @"Details";
notif.soundName = UILocalNotificationDefaultSoundName;
notif.applicationIconBadgeNumber = 1;
NSDictionary *userDict = [NSDictionary dictionaryWithObject:reminderText.text forKey:kRemindMeNotificationDataKey];
notif.userInfo = userDict;
[[UIApplication sharedApplication] scheduleLocalNotification:notif];
[notif release];
}
}
这些代码运行良好,但现在我想知道如何知道它将删除哪个通知对象。我想为一个通知创建一个ID,也就是说,一个ID相当于一个通知。但我不知道我应该在哪一部分做那件事。另外,我需要找到一种方法将所有这些都包含在一个 plist 中。
希望有人能帮助我。谢谢。
最佳答案
NSArray *notifications = [[UIApplication sharedApplication] scheduledLocalNotifications];
for (UILocalNotification *not in notifications) {
NSString *dateString=[not.userInfo valueForKey:@"EndDate"];
if([dateString isEqualToString:@"CompareString"])
{
[[UIApplication sharedApplication] cancelLocalNotification:not];
}
}
它对我很好。
干杯..
关于iphone - 取消特定的 UILocalNotification,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7186236/
是否可以创建 UILocalNotification 播放自定义声音但不振动手机? 编辑:这是我用来创建 UILocalNotification 的代码,它可以工作,但会振动手机。我不想让手机振动,但
我正在我的应用程序中发送本地通知;如果用户响应通知,应用程序将调用下面的委托(delegate)方法,我可以处理它: - (void)application:(UIApplication *)ap
如果我有两个(或更多)UILcalNotifications 或多或少地同时触发并且应用程序在后台处于事件状态,我发现: 同时向用户显示两个警报,一个覆盖另一个。 当用户触摸顶部提醒上的“查看”时,该
我正在开发一个 iPhone 应用程序,需要使用 UILocalNotifications 提醒用户定期 checkin 。如果他们几个小时没有签到,可能会提醒他们几次,但我只想显示最新的通知。 现在
我对 Cocoa Touch 和 Objective-C 非常陌生,但我已经掌握了相当重要的要点,并且正在尝试 UIKit。我有一个链接到按钮的操作,该按钮更改标签并触发 UILocalNotific
你能帮我吗? 我正在设置 UILocalNotification,当我尝试设置其 userInfo 字典时,它崩溃了。 fetchedObjects 包含 88 个对象。 这是代码: NSDi
所以我基本上是在尝试设置一个不断提供本地通知的应用程序。 到目前为止我已经: - (void)scheduleNotification { [reminderText resignFirstR
我已经寻找解决方案几个小时了..运气绝对为零。 我设置了本地通知: UILocalNotification *notif = [[cls alloc] init]; [dateComp setDay:
我的 UILocalNotification 有问题。 我正在用我的方法安排通知。 - (void) sendNewNoteLocalReminder:(NSDate *)date alrt:(NS
我希望有一个 UILocalNotification 在被触发时执行一个操作。我真正想做的是以编程方式更新 application.applicationIconBadgeNumber 。现在,每当用
我可以启用 UILocalNotification在我的应用程序中,我是这样进行的: 在我的UIViewController if(_endDate){ UILocalNotif
概述: 我正在复制UILocalNotification的实例并将其更改为新创建的实例 然后安排新创建的UILocalNotification实例 我如何复制 我正在通过调用UILocalNotifi
我正在使用 UILocalNotification但它没有按时触发,而是在指定时间后 8-10 分钟通知我。这是我正在使用的代码 UILocalNotification *localNotif
我开发了 IBeacon 应用程序。当应用程序处于后台模式并且我进入信标区域时,会触发 UILocalNotification。但问题是,如果我终止应用程序,通知仍然会触发。我用 locationMg
我正在尝试合并在特定时间间隔后触发的本地通知,但是,在使用模拟器进行测试时,我似乎无法在任何时候显示通知。 我只想在创建后 10 秒显示本地通知,但是,在模拟器中运行应用程序时,无论应用程序是在前台还
我创建了一个 UILocationNotification,其中有两个操作按钮,一个调用 sleep ,一个调用立即唤醒。因此,一旦用户看到通知,如果他们现在按下唤醒,应用程序将启动并执行一些代码由于
在我的一个应用程序中,我想显示本地通知,一旦它显示在通知中心,我想更新其内容。 在 Swift 中可以吗? 谢谢 惠普。 最佳答案 不完全是。但您可以删除它并添加一个包含新文本的新文本。 关于ios
我正在尝试发送如下所示的 UILocalNotification: func sendNotifiaction() { let notification = UILocalNotifi
我的应用程序上有几条通知。我想要做的是,当本地通知到达时,它会从通知中心删除另一个先前已显示的通知。 我正在使用以下代码。 static func unscheduleNotification(use
我在特定日期安排了一个 UILocalNotification,并且通知被正确触发,但问题是我在随机日期收到多个针对相同通知的警报,即使通知没有重复(repeatInterval = 0 ). 另外请
我是一名优秀的程序员,十分优秀!