Имам приложение, в което използвам локалното известие, ако потребителят не е отварял приложението известно време.
Ако потребителят отвори приложението чрез локално известие, моята база данни се актуализира и дава кредити на акаунта на потребителя и аз показвам предупреждението „Имате допълнителни кредити“.
Кредитите се актуализират в моята база данни Когато потребителят щракне върху OK, но контролерът ми не се опреснява и не показва кредити, актуализирани на етикет по това време.
Когато отида на друг изглед и се върна, той показва.
Как да получа актуализирани резултати в момента, в който потребителят кликне върху OK от AlertView?
Благодаря предварително....
Редактиране
[[UIApplication sharedApplication]cancelAllLocalNotifications];
NSDate *today=[NSDate date];
NSLog(@"%@",today);
NSDateFormatter *dateFormat1 = [[NSDateFormatter alloc] init];
[dateFormat1 setDateFormat:@"dd-MMM-yyyy hh:mm:ss a"];
NSTimeInterval secondsInEightHours = 20;
NSString *tt=[dateFormat1 stringFromDate:today];
//tt=@"20-Apr-2013 06:39:32 PM";
NSDate *Ass_date=[dateFormat1 dateFromString:tt];
Ass_date=[Ass_date dateByAddingTimeInterval:secondsInEightHours];
NSLog(@"%@",tt);
NSLog(@"%@",today);
NSLog(@"%@",Ass_date);
//[[UIApplication sharedApplication]cancelAllLocalNotifications];
UILocalNotification *localNotif1 = [[UILocalNotification alloc] init];
[[UIApplication sharedApplication]cancelLocalNotification:localNotif1];
if (localNotif1 == nil)
return;
localNotif1.fireDate = Ass_date;
localNotif1.timeZone = [NSTimeZone defaultTimeZone];
// Notification details
localNotif1.alertBody = @"You have not played for a long time. Play and get 250 Stars credits for free!";
// Set the action button
localNotif1.alertAction = @"Get It Now";
localNotif1.soundName = UILocalNotificationDefaultSoundName;
//localNotif.applicationIconBadgeNumber = 1;
//localNotif1.applicationIconBadgeNumber ++;
// Schedule the notification
[[UIApplication sharedApplication] scheduleLocalNotification:localNotif1];
[localNotif1 release];
Това е кодът, който направих във ViewDidAppear на моя viewcontroller.
Сега в делегата на приложението в приложение didReceiveLocalNotification: показах предупреждение.
[self localNotif];
////NSLog(@"Recieved Notification %@",localNotif);
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"" message:@"250 Stars have been credited to your account" delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
[alert release];
}
При щракване върху бутон Ok от предупреждение, искам, искам моят контролер за изглед да се обнови или презареди.