Tag: uilocalnotification

UILocalNotification iOS

本地通知使您的应用可以通知用户有关不需要使用服务器的内容的信息。 与从服务器触发的远程通知不同,本地通知是在应用内安排和触发的。 通常,通知的目标是增加用户与应用程序的交互,从而邀请或诱使用户打开并与其交互。 iOS 10中已弃用UILocalNotification。请改用UserNotifications框架。 安排本地通知 确保您看到注册本地通知以使其正常运行: 迅速 让通知= UILocalNotification() notification.alertBody =“您好,本地通知!” notification.fireDate = NSDate()。dateByAddingTimeInterval(10)// 10秒后 UIApplication.sharedApplication()。scheduleLocalNotification(通知) 目标C UILocalNotification * notification = [[UILocalNotification alloc] init]; notification.alertBody = @“您好,本地通知!” notification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10]; //现在10秒钟后[[UIApplication sharedApplication] scheduleLocalNotification:notification]; 要在iOS模拟器中查看通知,请键入^⌘H(control-command-H)返回首页,然后键入⌘L(command-L)以锁定设备。 等待几秒钟,然后将出现通知(此外观将根据“注册本地通知”中讨论的通知类型而有所不同): 在通知上滑动即可返回到应用程序(请注意,如果您在第一个视图控制器的viewDidLoad,viewWillAppear,viewDidAppear等中调用了此方法,则会再次安排该通知)。 立即显示本地通知 如果要立即显示本地通知,请致电: 迅捷3 UIApplication.shared.presentLocalNotificationNow(notification) 迅捷2 UIApplication.sharedApplication()。presentLocalNotificationNow(通知) 目标C [[UIApplication sharedApplication] presentLocalNotificationNow:notification]; 使用此方法的一个优点是您不必设置自己的fireDate和timeZone属性。

如何快速设置每周本地通知

我的代码有问题。 我想在xcode7中设置一个本地通知,我正在开发一个日历,你可以把你的大学的课程,事情是,我从json数据库得到的时间表,我想通知15分钟之前的课程开始,但我不知道为什么我的代码不工作。 这是我想在每个星期一13:40重复通知的一个例子。 我只能设置date和时间吗? 还是应该指定月份和年份呢? var dateComp:NSDateComponents = NSDateComponents() dateComp.day = 01; dateComp.hour = 13; dateComp.minute = 40; dateComp.timeZone = NSTimeZone.systemTimeZone() var calender:NSCalendar = NSCalendar(calendarIdentifier: NSCalendarIdentifierGregorian)! var date:NSDate = calender.dateFromComponents(dateComp)! let notification = UILocalNotification() notification.fireDate = date notification.alertBody = "Swipe to unlock" notification.alertAction = "You've got a class soon!" notification.soundName = UILocalNotificationDefaultSoundName notification.userInfo = ["CustomField1": […]

取消并重新安排本地通知(Swift)

我试图以1天(24小时)的时间间隔显示本地通知,并且其工作正常,但是现在我想取消特定date的通知。 我试过(今天)这个,但似乎没有工作。 我的通知仍然出现,这是我已经做了取消通知: let appNotification = appDelegate!.notification UIApplication.sharedApplication().cancelLocalNotification(appNotification) 这是如何安排在appDelegate的通知: //scheduling notification dateComp.year = 2015; dateComp.month = 01; dateComp.day = 20; dateComp.hour = 21; dateComp.minute = 05; dateComp.timeZone = NSTimeZone.systemTimeZone() notification.category = "FIRST_CATEGORY" notification.alertBody = "my daily notiification ?" notification.soundName = UILocalNotificationDefaultSoundName notification.fireDate = finalFireDate notification.repeatInterval = NSCalendarUnit.Day let dateNow = NSDate() let noticalendar = NSCalendar.currentCalendar() […]

本地通知

我在我的游戏应用程序中实施了一个本地通知,每天发一次每日奖金。 当我点击通知横幅时,这一切正常,但是,当我从应用程序图标进入应用程序,本地通知不应该像它应该。 这是我的代码: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions{ ……. ……. application.applicationIconBadgeNumber = 0; UILocalNotification *localNotif = [launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey]; if (localNotif) { NSLog(@"recieved notification %@",localNotif); UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Daily Bonus" message:@"You recieved 100 free coins" delegate:nil cancelButtonTitle:nil otherButtonTitles:@"ok", nil]; [alert show]; [alert release]; NSUserDefaults *standardUserDefaults = [NSUserDefaults standardUserDefaults]; float balance = [standardUserDefaults floatForKey:kCurrentScore]; balance +=100.0f; NSLog(@"%g",balance); [standardUserDefaults […]

iOS UILocalNotification声音

即使声音closures,是否有任何方法可以播放UILocalNotification声音。 其实我试图创build一个警报,即使用户已closures声音工作。 或者任何其他的方式来实现这一点。

UILocalNotification始终将date设置为本地时区

我有一个方法,使UILocalNotification的存储: – (void)save:(NSString *)program at:(NSDate*)date { NSLog(@"date to save: %@", date); // NSLog(@"timezone: %@",[date descriptionWithLocale:[NSLocale systemLocale]]); UILocalNotification* localNotification = [[UILocalNotification alloc] init]; NSLog(@"date to fire: %@", date); localNotification.fireDate = date; NSString *s=[program stringByAppendingString:@" is now on "]; NSString *title=[s stringByAppendingString:channel]; localNotification.alertBody = title; localNotification.alertAction = @"Show…"; //localNotification.timeZone = [NSTimeZone localTimeZone]; localNotification.applicationIconBadgeNumber = [[UIApplication sharedApplication] applicationIconBadgeNumber] […]

如何将响应通知的模态视图显示为新窗口? (没有父vc)

我有很多问题处理我的传入本地通知。 我的应用程序正在使用故事板,并有一个tabbarcontroller作为rootviewcontroller。 目前,我通过以下方式从“didReceiveLocalNotification”启动模态视图: MedicationReminderViewController *vc = [[MedicationReminderViewController alloc] initWithNibName:@"MedicationReminderViewController" bundle:nil]; vc.notificationInfo = [[NSDictionary alloc] initWithDictionary:notification.userInfo]; UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:vc]; navController.navigationBar.barStyle = UIBarStyleBlackOpaque; navController.title = @"title"; UITabBarController *tc = (UITabBarController *)self.window.rootViewController; UINavigationController *nc = (UINavigationController *)tc.selectedViewController; [[nc visibleViewController] presentModalViewController:navController animated:YES]; 这有效,但不是在任何场合。 我想在新窗口中显示当时可以显示的任何其他模态视图。 当用户处理传入的通知时,模式视图将自行消除,并且在通知进入之前活动的基础视图将再次可见。 我怎样才能做到这一点?

当应用程序被杀时如何获得准确的位置更新?

我正在开发一个基于位置的应用程序,在这个应用程序中,用户可以存储多个位置,当用户靠近存储位置时,应用程序将通过本地通知通知用户。 我用下面的代码来实现这个function: -(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusDenied){ [self showAlertWithTitle:@"" andMessage:@"The app doesn't work without the Background App Refresh enabled. To turn it on, go to Settings > General > Background App Refresh."]; }else if([[UIApplication sharedApplication] backgroundRefreshStatus] == UIBackgroundRefreshStatusRestricted){ [self showAlertWithTitle:@"" andMessage:@"The functions of this app are limited because the Background […]

每日UILocalNotification不止一次射击

你好,我面临一个奇怪的问题。 其实我想在上午8:00安排每日通知(每天一次)。 以下是我安排每日通知的代码。 NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"HH:mm"]; NSDate *date = [[NSDate alloc] init]; date = [formatter dateFromString:@"08:00"]; UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = date; localNotification.timeZone=[NSTimeZone defaultTimeZone]; localNotification.alertBody = @"You just received a local notification"; localNotification.alertAction = @"View Details"; localNotification.soundName = UILocalNotificationDefaultSoundName; localNotification.repeatInterval = NSDayCalendarUnit; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; [formatter release]; […]

在IOS开发中的视图控制器之间共享对象状态

我的应用程序在主TabViewController上有两个选项卡。 第一个标签显示了我喜欢的水果清单。 第二个选项卡在您键入的同时向api发送请求,searchsearch名称的水果。 如果用户点击任何水果,我会显示一个水果细节视图,在那里可以喜欢水果(如果已经喜欢,你可以不同)。 现在,我试图达到这样的东西: 用户search一个水果 用户喜欢水果 用户导航回到列表 列表显示突出显示“喜欢”图标的水果 我怎样才能通知select行之前的列表,单元格状态的变化(这是不喜欢的,现在是喜欢的)。 我怎样才能通知其他列表(在另一个标签)相同的东西? 多谢你们 编辑 我会试着展示一个真实的样本! 当你去appstore并searchGMAIL 然后你去特色(图表,我不知道你的国家),并寻找同样的应用程序 当您在任何一个视图控制器中下载它时,同时另一个控制器显示相同的状态。 这正是我想要做的。