0

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.

Oh Danny Boy
  • 4,857
  • 8
  • 56
  • 88
  • MSConversation *conversation = [MSConversation new]; will send a new message, still struggling to get current thread however. – Oh Danny Boy Sep 15 '16 at 21:42

1 Answers1

1

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.

Oh Danny Boy
  • 4,857
  • 8
  • 56
  • 88