Мне нужно представить MFMessageComposeViewController
после получения UILocalNotification
.iOS - Представление MFMessageComposeViewController после получения UILocalNotification
Прямо сейчас у меня есть контроллер просмотра, назовем его ViewControllerA
, который соответствует MFMessageComposeViewControllerDelegate
. В ViewControllerA
я имею установку следующий метод:
- (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 и записывает «Can send text», но MFMessageComposeViewController
никогда не отображается. Я знаю, что MFMessageComposeViewController
будет правильно отображаться в приложении, не используя UILocalNotification
.
В основном сразу после получения уведомления и нажатия «Вид» я хочу представить MFMessageComposeViewController
.