iOS - представление MFMessageComposeViewController после получения UILocalNotification - PullRequest
0 голосов
/ 09 февраля 2012

Мне нужно представить MFMessageComposeViewController после получения UILocalNotification.

. Сейчас у меня есть контроллер представления, назовем его ViewControllerA, который соответствует MFMessageComposeViewControllerDelegateViewControllerA я настроил следующий метод:

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

Поэтому, когда я получаю UILocalNotification от AppDelegate, я настроил следующий метод:

- (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 никогда не отображается.На самом деле я знаю, что MFMessageComposeViewController будет правильно отображаться в приложении без использования UILocalNotification.

. В основном, сразу после получения уведомления и нажатия «Просмотр», я хочу, чтобы MFMessageComposeViewController был представлен.

1 Ответ

1 голос
/ 09 февраля 2012
    ViewControllerA *vcA = [[ViewControllerA alloc] initWithNibName:nil bundle:nil];
    vcA.messageData = [NSArray arrayWithArray:self.messageData];    
    [vcA sendNow];

vcA - не добавляется (выдвигается) к контроллеру навигации, окну или чему-либо еще.У вас есть переменная контроллера навигации в приложении делегата?используйте это

...