Reputation: 21
I created an UITableView with CustomCells.when clicking a button in top of the view a local notification is created and the table view is updated.if the app is not in running state,then notification is shown in banner.When clicking the banner how to launch the corresponding updated UItableviewcell. Need help...
Upvotes: 1
Views: 126
Reputation: 3198
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
// Handle launching from a notification
UILocalNotification *localNotif =
[launchOptions objectForKey:UIApplicationLaunchOptionsLocalNotificationKey];
if (localNotif) {
NSLog(@"Handle launching-> Recieved Notification ");
localNotif.applicationIconBadgeNumber = 0;// set here the value of badg
dicttemp=[NSDictionary new];
dicttemp=[NSDictionary dictionaryWithObject:[localNotif.userInfo valueForKey:@"sent"] forKey:@"sent"];
//Here you can get dictionary from Local Notification(eg.localNotif.userInfo) & using it , Navigate to View Controller & then Reload Data ..
}
return YES;
}
& if you app is Foregroung Mode means its Running then Use Below Code..
- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif {
// Handle the notificaton when the app is running
NSLog(@"Handle the notificaton when the app is running -> Recieved Notification %@",notif);
notif.applicationIconBadgeNumber = 0;// set here the value of badge
dicttemp=[NSDictionary new];
dicttemp=[NSDictionary dictionaryWithObject:[notif.userInfo valueForKey:@"sent"] forKey:@"sent"];
}
Upvotes: 0
Reputation: 1680
You can use application:didFinishLaunchingWithOptions method to receive UILocalNotification and to update your table view you can post NSNotification from this method.
Upvotes: 0
Reputation: 438
After clicking on banner if your application wasn't run, you will receive local notification in application:didFinishLaunchingWithOptions: in options dictionary, by key UIApplicationLaunchOptionsLocalNotificationKey. So you need to check this key on app start and show proper cells if local notification present.
Upvotes: 1