local notifications为我的应用程序启用它有点困难.
,是的,我建立了我的项目,一个local notification巫婆我想要的应用程序已被关闭后安排的一个星期 例如,如果用户在星期六8日打开应用程序,则本地通知应出现在15日的下一个星期六,但时间应该更改.例如,他/她在晚上8点关闭应用程序,我不想在下周8点打扰他们,所以我想在下午6点或类似的地方显示每个通知.
现在你知道我的问题,这是我正在使用的代码:
- (void)applicationDidEnterBackground:(UIApplication *)application
{
[[UIApplication sharedApplication] cancelAllLocalNotifications];
NSCalendar *calendar = [NSCalendar autoupdatingCurrentCalendar] ;
NSDateComponents *componentsForReferenceDate = [[NSDateComponents alloc] init];
//set day (saturday)
[componentsForReferenceDate setDay:26] ;
[componentsForReferenceDate setMonth:1] ;
[componentsForReferenceDate setYear:2013] ;
[componentsForReferenceDate setHour: 17] ;
[componentsForReferenceDate setMinute:30] ;
[componentsForReferenceDate setSecond:00] ;
NSDate *fireDateOfNotification = [calendar dateFromComponents: componentsForReferenceDate];
// Create the notification
UILocalNotification *notification = [[UILocalNotification alloc] init] ;
notification.fireDate = fireDateOfNotification ;
notification.timeZone = [NSTimeZone localTimeZone] ;
notification.alertBody = …Run Code Online (Sandbox Code Playgroud)