[英]when clicking notification show the corresponding content in UITableViewCell?
我用CustomCells創建了一個UITableView。單擊視圖頂部的按鈕時,將創建一個本地通知並更新表視圖。如果應用程序未處於運行狀態,則通知將顯示在橫幅中。單擊橫幅時如何啟動相應的更新的UItableviewcell。 需要幫忙...
如果您的應用程序未運行,請在單擊橫幅后,您將在選項字典中的application:didFinishLaunchingWithOptions:中通過按鍵UIApplicationLaunchOptionsLocalNotificationKey收到本地通知。 因此,您需要在應用啟動時檢查此鍵,並在顯示本地通知時顯示正確的單元格。
您可以使用application:didFinishLaunchingWithOptions方法接收UILocalNotification並更新表視圖,您可以通過此方法發布NSNotification。
- (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;
}
&如果您的應用程序是Foregroung模式,則表示其正在運行,然后使用以下代碼。
- (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"];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.