2012-02-09 4 views
0

UILocalNotification을받은 후 MFMessageComposeViewController을 제시해야합니다.iOS - UILocalNotification을받은 후 MFMessageComposeViewController 표시

지금 바로보기 컨트롤러를 MFMessageComposeViewControllerDelegate에 부합하는 ViewControllerA이라고 부릅시다. 내가 AppDelegate에에서 UILocalNotification을받을 때 내가 설정을 다음과 같은 방법이 그래서

- (void)sendNow { 

    MFMessageComposeViewController *mfMessageComposeVC = [[MFMessageComposeViewController alloc] init]; 

    if([MFMessageComposeViewController canSendText]) { 

     DLog(@"Can send text"); 

     mfMessageComposeVC.recipients = self.numbers; 
     mfMessageComposeVC.body = self.message; 
     mfMessageComposeVC.messageComposeDelegate = self; 
     [self presentModalViewController:mfMessageComposeVC animated:YES]; 
    } 
} 

: ViewControllerA에서 나는 설정을 다음과 같은 방법을

- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification { 

    DLog(@"Notification Body: %@", notification.alertBody); 
    DLog(@"%@", notification.userInfo); 

    //application.applicationIconBadgeNumber = 0; 

    UIApplicationState state = [application applicationState]; 
    if (state == UIApplicationStateInactive) { 

     // Application was in the background when notification was delivered. 

     ViewControllerA *vcA = [[ViewControllerA alloc] initWithNibName:nil bundle:nil]; 
     vcA.messageData = [NSArray arrayWithArray:self.messageData];  
     [vcA sendNow]; 

     //[remindersNavigationController pushViewController:reminderDetailsVC animated:NO]; 

    } else { 

     // Application is currently running, Alert the user with a UIAlertView that he has scheduled a message to be sent at this time, give him the option of Close and Send 
    } 
} 

이상한 것은은 그에서 응용 프로그램을 실행할 때 시뮬레이터가 UIAlertView "이 장치는 텍스트를 보낼 수 없습니다"라는 팝업을 띄웁니다. 이 동작이 예상됩니다. 그러나 장치에서 실행할 때 IF 내부로 들어가 "텍스트를 보낼 수 있음"을 기록하지만 MFMessageComposeViewController은 절대로 제공되지 않습니다. 사실 MFMessageComposeViewControllerUILocalNotification을 사용하지 않고 앱에 올바르게 표시됩니다.

기본적으로 알림을받은 후 "보기"를 클릭하면 MFMessageComposeViewController을 표시합니다.

답변

1
ViewControllerA *vcA = [[ViewControllerA alloc] initWithNibName:nil bundle:nil]; 
    vcA.messageData = [NSArray arrayWithArray:self.messageData];  
    [vcA sendNow]; 

vcA - nav 컨트롤러 또는 창 또는 다른 것으로 추가되지 않습니다. 앱 대리인에 nav 컨트롤러 변수가 있습니까? 그것을 사용하십시오

관련 문제