下面是我的代碼,我有檢查互聯網一切似乎不錯,但不知道通知不點火,我知道它是如此簡單,但我仍然堅持在這裏請大家幫忙問題在本地通知不點火
-(void)notification:(NSMutableArray *)nameArray datearray:(NSMutableArray*)datearray;
{
NSLog(@"name%@",nameArray);
NSLog(@"date%@",datearray);
"Jodie Hession",
"John Miller",
"Shane Jarome",
"Sharon Scott",
"Sheron Begley",
"Susan Diaz",
Kate,
John,
Anna,
David,
today,
"After Some day"
)
date(
"14/12/2013 04:35:00",
"18/12/2013 04:35:00",
"04/04/2014 04:35:00",
"01/01/2014 04:35:00",
"29/06/2014 04:35:00",
"05/01/2014 04:35:00",
"18/12/2013 04:35:00",
"20/01/2014 04:35:00",
"22/06/2014 04:35:00",
"29/08/2013 04:35:00",
"15/06/2014 04:35:00",
"22/07/2013 04:35:00",
"31/07/2013 04:35:00"
)
// logic for local notification start
[[UIApplication sharedApplication] cancelAllLocalNotifications];
NSDateFormatter *Form=[[[NSDateFormatter alloc]init]autorelease];
[Form setDateFormat:@"dd/MM/yyyy hh:mm:ss"];
UILocalNotification *notification = [[UILocalNotification alloc] init];
for (int i=0;i<datearray.count;i++)
{
NSDate *date =[Form dateFromString:[datearray objectAtIndex:i ]];
NSLog(@"%@",date);
if(notification)
{
notification.fireDate = date;
// if(notification.fireDate == date){
//
// notification.applicationIconBadgeNumber = 1;
//
// }
notification.timeZone = [NSTimeZone defaultTimeZone];
notification.alertBody = [NSString stringWithFormat:@"Today is %@\'s Birthday",[nameArray objectAtIndex:i]];
notification.alertAction = @"View";
notification.soundName = UILocalNotificationDefaultSoundName;
[[UIApplication sharedApplication] scheduleLocalNotification:notification];
}
NSLog(@"fire date%@", notification.fireDate);
// fire date2013-07-30 23:05:00 +0000
不要知道爲什麼,但NSDate的總是打印別的東西,如果我們用stringfromdate檢查它那麼只有它顯示了正確的價值 }
}
,並在我的應用程序delegete
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
{
NSLog(@"Notification Received, %@, set for date %@", notification.alertBody, notification.fireDate);
}
你檢查了最小化應用程序? –
yesss我做了先生 – java
盡我所知,通知不適用於循環。如果你運行一個值,它正在運行!讓我研究更多 –