I am building a standalone iMessage application. I have a UIViewController
which inherits from MSMessagesAppViewController
. It seems activeConversation
is always nil. Any ideas why? I am mirroring how Apple sends a message in their sample Ice Cream project.
MSConversation *conversation = [self activeConversation];
if (conversation) {
MSMessageTemplateLayout *layout = [[MSMessageTemplateLayout alloc] init];
layout.caption = @"Caption";
layout.subcaption = @"subcaption";
MSMessage *message = [[MSMessage alloc] init];
message.URL = [NSURL URLWithString:@"www.example.com"];
message.layout = layout;
[conversation insertMessage:message completionHandler:^(NSError *error) {
if (error) {
NSLog(@"Error sending message %@", [error localizedDescription]);
}
}];
}
else {
NSLog(@"No &%#%&^# conversation found");
}
It may be worth noting the UIViewController
is embedded in a UINavigationController
.
Turns out you can only have one instance of MSMessagesAppViewController
which will actually interact with the conversation threads. Other controllers can inherit from MSMessagesAppViewController
but none of the conversation protocol or compact/expanded transition delegate methods will fire in those instances, just the first instance the extension encounters.