我正在构建一个独立的iMessage应用程序。我有一个继承自MSMessagesAppViewController的UIViewController。似乎activeConversation总是为空。你知道为什么吗?我正在模仿苹果在他们的Ice Cream示例项目中发送信息的方式。
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");
}值得注意的是,UIViewController是嵌入在UINavigationController中的。
发布于 2016-10-05 03:04:19
事实证明,您只能有一个MSMessagesAppViewController实例,它将实际与会话线程进行交互。其他控制器可以从MSMessagesAppViewController继承,但在这些实例中不会触发会话协议或紧凑/扩展的转换委托方法,只会在扩展遇到的第一个实例中触发。
https://stackoverflow.com/questions/39519376
复制相似问题