Hello,
My application already have an iMessage Extension since iOS10 that work perfectly.
I am trying to use MSMessageLiveLayout available in iOS11 but it doesn't work, the "Balloon" inserted in the conversation is blank.
There is my code :
- (void)composeMessageWithItem:(NSObject<MSMessageTemplateLayoutProtocol> *)item {
MSConversation *conversation = self.activeConversation;
MSMessage *message = [self messageTemplateLayoutWithItem:item
session:conversation.selectedMessage.session];
[conversation insertMessage:message completionHandler:^(NSError *error) {
NSLog(@"ERROR = %@", error);
}];
}
- (MSMessage *)messageTemplateLayoutWithItem:(NSObject<MSMessageTemplateLayoutProtocol> *)item session:(MSSession *)session {
MSMessageTemplateLayout *templateLayout = [MSMessageTemplateLayout new];
templateLayout.image = item.image;
templateLayout.caption = item.caption;
templateLayout.subcaption = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleDisplayName"];
MSMessageLayout *layout = templateLayout;
if (@available(iOS 11.0, *)) {
// If i comment this line, everything is fine and the "Ballon" uses the iOS 10 template
layout = [[MSMessageLiveLayout alloc] initWithAlternateLayout:templateLayout];
}
NSURLComponents *components = [NSURLComponents new];
components.queryItems = item.queryItems;
MSMessage *message = [[MSMessage alloc] initWithSession:(session != nil ? session : [MSSession new])];
message.URL = components.URL;
message.layout = layout;
return message;
}
Is anyone succeeded in making MSMessage with MSMessageLiveLayout ?
If the answer is YES, how ?
Can you post your code please ?
Thank you.