2013-10-15 4 views
0

내 응용 프로그램에서 데이터 개체의 배열을 유지; 특정 동작에서 데이터 객체가 로컬 알림을 생성합니다. 로컬 알림을 생성 한 개체를 인식 할 수있게하려는 경우, 사용자가 알림을 열 때 - 앱이 활성화되었을 때 알림이 시작될 경우 팝업되는 UIAlertView에서 온 것이 든, 알림에 의해 트리거되는지 여부 앱이 백그라운드에있을 때 나타나는 팝업 - 특정 개체 데이터가 표시된 화면을 열 수 있습니다.iOS >> 로컬 알림 >> 특정 알림을 로컬 알림에 연결하는 방법?

로컬 알림 인스턴스에 관련 객체를 어떻게 정의합니까?

+1

알림의 'Notif.userinfo' 속성을 사용하십시오. 저장 개체에 대한 사전을 가져옵니다. Notif.userinfo에 의해 통지 수신 방법에서이를 얻을 수 있습니다. – user1673099

답변

1

이 방법을 시도 ...

있는 NSDictionary * DICT = [NSDictionary에 dictionaryWithObject : "개체"forKey @ : "키"@]

UILocalNotification *localNotif = [[UILocalNotification alloc] init]; 
    localNotif.fireDate = Pre_date; 
    localNotif.timeZone = [NSTimeZone defaultTimeZone]; 

    // Notification details 
    localNotif.alertBody = [txtRemindetText text]; 
    // Set the action button 
    localNotif.alertAction = @"View"; 
    localNotif.userInfo=dict; 
    localNotif.soundName = UILocalNotificationDefaultSoundName; 

    // Schedule the notification 
    [[UIApplication sharedApplication] scheduleLocalNotification:localNotif]; 

AppDelegate.m

- (void)application:(UIApplication *)app didReceiveLocalNotification:(UILocalNotification *)notif { 
    // Handle the notificaton when the app is running 
    NSLog(@"Recieved Notification %@",notif); 
    NSLog(@"%@",notif.userInfo); 
    NSLog(@"%@",[notif.userInfo objectForKey:@"YOUR KEY"]; 
} 

당신이 어떤 문제가 있다면 알려주세요.

+0

감사합니다. 해피 코딩 ... – user1673099