2015-01-16 2 views
1

Я создал UITableView с CustomCells.when нажав кнопку в верхней части представления, создается локальное уведомление и обновляется представление таблицы. Если приложение не находится в запущенном состоянии, уведомление отображается в баннере. При нажатии на баннер как запустить соответствующий обновленный UItableviewcell. Нужна помощь ...при нажатии на уведомление показывает соответствующий контент в UITableViewCell?

ответ

1

После нажатия на баннер, если приложение не был запущен, вы получите уведомление в местное применения: didFinishLaunchingWithOptions: в словаре опций, с помощью ключа UIApplicationLaunchOptionsLocalNotificationKey. Поэтому вам нужно проверить этот ключ в начале приложения и показать соответствующие ячейки, если присутствует местное уведомление.

0

Вы можете использовать приложение: didFinishLaunchingWithOptions, чтобы получить UILocalNotification и обновить представление таблицы, вы можете отправить NSNotification из этого метода.

0

@ sha007, в вашем при запуске приложения, вы должны написать код, приведенный ниже,

- (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 режим означает, что его Running затем используйте код ниже ..

- (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"]; 

} 
+0

спасибо за ваш ответ ..... я собираюсь попробовать с этим .... – sha007

+0

@ sha007..best of luck..keep encoding – Mehul

Смежные вопросы