大佬教程收集整理的这篇文章主要介绍了当通知超过64 时,如何在iOS中安排更多本地通知,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
- (void)scheduleNotification:(NSMutableArray *)datesArray withmessage:(NSMutableArray *)messagesArray NotificationID:(NSString *)notificationID { NSCalendar *calendar = [NSCalendar currentCalendar]; NSDateFormatter *formatter = [[NSDateFormatter alloc]init]; [formatter setDateStyle:NSDateFormatterNoStyle]; [formatter settimestyle:NSDateFormatterShortStyle]; NSDateFormatter *formatter1 = [[NSDateFormatter alloc]init]; [formatter1 setDateStyle:NSDateFormatterMediumStyle]; [formatter1 setDateFormat:@"dd/MM/yyyy"]; // NSDate *@R_597_6674@ = [formatter dateFromString:@"06:10 PM"]; NSDate *@R_597_6674@ = [formatter dateFromString:fireTime]; for (int i = 0; i < [datesArray count]; i++) { NSDate *myDate = [formatter1 dateFromString:[datesArray objectATindex:i]]; NSDateComponents *dateComponents = [calendar components:NSDayCalendarUnit|NSMonthCalendarUnit|NSYearCalendarUnit fromDate:myDate]; NSDateComponents *timeComponents = [calendar components:NSHourCalendarUnit|NSminuteCalendarUnit fromDate:@R_597_6674@]; NSDateComponents * newComponents = [[NSDateComponents alloc]init]; NSDateComponents *todayComponents = [[NSCalendar currentCalendar] components:NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit fromDate:[NSDate date]]; int day = [dateComponents day]; int month = [dateComponents month]; [newCompoents setDay:[dateComponents day]]; [newCompoents setMonth:[dateComponents month]]; if (day >= [todayComponents day] && month >= [todayComponents month]) { NSLog(@"day = %d,month = %d",day,month); [newComponents setYear:[todayComponents year]]; } else { NSLog(@"%d,%d",month); [newComponents setYear:[todayComponents year]+1]; } [newComponents setHour:[timeComponents hour]]; [newComponents setminute:[timeComponents minute]]; NSDate *combDate = [calendar dateFromComponents: newComponents]; localNotif = [[UIlocalnotification alloc] init]; if (localNotif == nil) return; localNotif.fireDate = combDate; localNotif.timeZone = [NSTimeZone defaultTimeZone]; // Notification details NSString *message = [@"Wish" StringByAppendingFormat:@" %@%@",[messagesArray objectATindex:i],@" On His Birthday"]; localNotif.alertBody = message; // Set the action button localNotif.alertAction = @"View"; localNotif.soundName = UIlocalnotificationDefaultSoundName; localNotif.applicationIconBadgenumber = 1; // Specify custom data for the notification NSDictionary *infoDict = [NSDictionary DictionaryWithObject:notificationID forKey:notificationID]; localNotif.userInfo = infoDict; // schedule the notification [[UIApplication sharedApplication] schedulelocalnotification:localNotif]; } }
请记住,重叠的生日可能在这里很有用.如果两个人最终在同一天过生日,请取消并重新安排他们的相关信息.如果你没有通用消息,你可以找到重复发生的其他间隔.
显然,让用户按下通知以打开应用程序会有所帮助(也可能与您的广告收入有关).你可以为你的最后一个尝试一个好消息.
这很麻烦,但你可以使用geofencing(但可能不是远程通知),如下所述:Can push notifications be used to run code without notifying user?.如果添加使用它的功能,您甚至可以获得批准.
我也考虑过传递一个自定义日历,但NSCalendar是免费的CFCalendarRef桥接,故事似乎是我没有运气试图深入研究(并至少获得批准).我很高兴被告知我错了.
以上是大佬教程为你收集整理的当通知超过64 时,如何在iOS中安排更多本地通知全部内容,希望文章能够帮你解决当通知超过64 时,如何在iOS中安排更多本地通知所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。