내가 푸시 알림에 대한 책임있는 방법으로, AppDelegate에AppDelegate.m에서 TableView 데이터를 다시로드 하시겠습니까?
AppDelegate.m에서에서있는 tableView를 다시로드하려고, "didReceiveRemoteNotification는"나는 UIAlertView 매번 전화 통지가 도착했을 때.
UIAlertView *alertView = [[UIAlertView alloc] initWithTitle:@"Notification received" message:[NSString stringWithFormat:@"%@", titleMsg] delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
alertView.delegate = self;
[alertView show];
사용자가 "OK"버튼을 클릭하면, 데이터베이스의 읽기하고 난 UIAlertViewDelegate
프로토콜에 추가 된 헤더에있는 tableview
// Reload the table when the user click "OK" button in the alert
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
if ([alertView.title isEqualToString:@"Notification received"])
{
if (buttonIndex == [alertView cancelButtonIndex])
{
// Stop the sound for notifications
[self stopSoundForNotifications];
// Refresh table messages
AccueilViewController * avc = [[AccueilViewController alloc] init];
[avc readMsgsFromDB];
[avc reloadTableMsgsReceived];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReadMessagesFromDB" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadDataFromDelegate" object:nil];
}
}
}
를 다시로드한다
몇 가지 아이디어가 있으십니까? (UIAlertView *) alertView clickedButtonAtIndex : (NSInteger) buttonIndex 것 같습니다
if ([alertView.title isEqualToString:@"Notification received"])
{
if (buttonIndex == [alertView OKButtonIndex])
{
// then fire notification
// Stop the sound for notifications
[self stopSoundForNotifications];
// Refresh table messages
AccueilViewController * avc = [[AccueilViewController alloc] init];
[avc readMsgsFromDB];
[avc reloadTableMsgsReceived];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReadMessagesFromDB" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"ReloadDataFromDelegate" object:nil];
}
}
무엇이 문제입니까? 알림이 호출되지 않고 있습니까? – Bejibun