Tag: uilocalnotification

如何在Swift中使用UILocalNotification

我想弄清楚如何设置一个UILocalNotification迅速,但我没有很多运气。 我正在尝试这个: var notification = UILocalNotification() notification.timeZone = NSTimeZone.defaultTimeZone() var dateTime = NSDate.date() notification.fireDate(dateTime) notification.alertBody("Test") UIApplication.sharedApplication().scheduleLocalNotification(notification) 对于初学者,我不确定这是否是获取当前date时间的正确方法。 在.Net中,我只是做DateTime.Now()。 其次,当我尝试这个,我得到一个错误 ,说: '(@lvalue NSDate!) – > $ T3'与'NSDate'不一样 不幸的是,我不知道这意味着什么或如何进行。

有没有办法知道在iOS中删除应用程序的时间?

我的问题是这样的: 我已经在iOS应用程序上安排了一些UILocalNotifications,问题是如果我删除应用程序而不删除与通知关联的对象(并因此从scheduledNotifications数组中删除通知),通知仍会触发。 虽然我没有经历过它们实际上正在触发(他们被设置为在一个星期内重复),我有证据表明,因为NSLog在应用程序启动时调度了scheduledNotifications数组,甚至在删除应用程序并重新安装它(与数据的实体模型消失),仍然显示一些预定的通知。 我已经在苹果的参考库中search了UIApplication和UIApplicationDelegate参考,但是我发现没有方法知道应用程序是否被删除,如果有的话我只是写 [[UIApplication sharedApplication] cancelAllLocalNotifications]; 在所述方法中。 那么,有没有办法知道这个? 预先感谢您的帮助,非常感谢。

我怎样才能访问默认的iOS声音设置为通知声音?

我怎样才能访问默认的iOS声音(三音,钟声,玻璃,喇叭,贝尔,电子…)设置为本地通知声音? 我创build了本地通知,一切正常,但默认声音(这是三音)。 我想用钟声或其他 我只知道如何使用我自己的声音文件: localNotif.soundName = @"sound.wav";

如何识别ios sdk中的特定通知

实际上正在开发一个报警项目,现在我对本地通知有疑问。 我怎样才能确定一个特定的通知。 我们甚至不能将标签设置为本地通知,那么我怎样才能区分它们。 例: 通知:1 UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = selectedDate; localNotification.alertBody = @"you got work"; localNotification.alertAction = @"Snooze"; localNotification.repeatInterval = NSDayCalendarUnit; localNotification.soundName = UILocalNotificationDefaultSoundName; NSDictionary *infoDict = [NSDictionary dictionaryWithObjectsAndKeys:@"setNotificationForEveryDay", @"key", nil]; localNotification.userInfo = infoDict; [[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; [localNotification release]; 通知:2, UILocalNotification *localNotification = [[UILocalNotification alloc] init]; localNotification.fireDate = another selectedDate; localNotification.alertBody […]

如何在不同的时间每天重复本地通知

我正在做一个祈祷应用程序,使用户能够为祈祷时间设置警报(本地通知),即用户设置应用程序通知他每天的祈祷祷告,问题是每个祷告的时间每天都在变化应用程序在星期四通知用户公平的时间将与星期五的时间有所不同,我需要每天重复本地通知,但是根据每天的祷告时间,请有谁能给我一个想法?

通过soundID获取soundName,将其分配给UILocalNotification

我有一个UILocalNotification ,我不想把它设置为使用默认的音色。 我已经使用AudioToolbox.framework,并通过引用这个库有一个SystemSoundID : https : //github.com/TUNER88/iOSSystemSoundsLibrary 。 但是UILocalNotification需要一个UILocalNotification的名字 。 我如何从SystemSoundID获取名称?

当本地通知从iOS的通知中心被解除时,什么方法被触发?

我正在尝试创build一个启动本地通知的应用程序,当通知被点击时,应该打开一个特定的viewcontroller 。 我使用didReceiveLocalNotification方法来显示特定的视图控制器。 但是,即使从通知中心解除通知,也正在显示该特定的视图控制器。 当我们closures通知时触发了什么方法? 这是我使用的代码: func application(application: UIApplication!,didReceiveLocalNotification notification: UILocalNotification) { var root = self.window!.rootViewController as ViewController let main: UIStoryboard = UIStoryboard(name: "Main", bundle: nil) var setview = main.instantiateViewControllerWithIdentifier("destination") as tapViewController //root.navigationController?.popToViewController(setview, animated: false) if application.applicationState == UIApplicationState.Inactive { root.presentViewController(setview, animated:false , completion: nil) } }

如何在iOS(ObjC)中安排每日本地推送通知?

无法以正确的方式安排每日本地PushNotification 。 我想在上午9:00只显示一个每日本地推送通知,并计算今天的任务。 我的代码在didFinishLaunchingWithOptions只执行一次,如: – (void)scheduleLocalNotification { self.localNotification = [UILocalNotification new]; unsigned unitFlags = NSCalendarUnitYear | NSCalendarUnitMonth | NSCalendarUnitDay; NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateComponents *components = [calendar components:unitFlags fromDate:[NSDate date]]; components.hour = 9; components.minute = 0; components.second = 0; NSDate *fireTime = [calendar dateFromComponents:components]; _localNotification.fireDate = fireTime; _localNotification.alertBody = [NSString stringWithFormat:@"Hi, <username>. You have […]

设置多个UILocalNotification

我需要设置不同的UILocalNotification 我有 StartDate:Starting date from which notification starts(using date picker) EndDate: enddate upto when notfication fire(using date picker) //从dateselect器中select不同的时间(最多5次) time1tofire:HH:MM time2tofire:HH:MM time3tofire:HH:MM time4tofire:HH:MM time5tofire:HH:MM 我知道我可以设置不同的重复每日UILocalNotification以下属性的CalenderUnit NSEraCalendarUnit NSYearCalendarUnit NSMonthCalendarUnit NSDayCalendarUnit NSHourCalendarUnit NSMinuteCalendarUnit NSSecondCalendarUnit NSWeekCalendarUnit NSWeekdayCalendarUnit NSWeekdayOrdinalCalendarUnit NSQuarterCalendarUnit 并设置简单的通知 – (IBAction)addNotification:(id)sender { UILocalNotification *localNotification = [[UILocalNotification alloc] init]; //Create the localNotification object [localNotification setFireDate:[NSDate dateWithTimeIntervalSinceNow:[datePicker countDownDuration]]]; //Set […]

本地通知是否可以在iOS8中触发代码?

我正在尝试创build一个需要超过64个本地通知的应用程序。 系统在没有用户与通知交互的情况下向用户发送通知时,是否有任何触发代码的方式?