消息扩展发送音频文件

时间:2017-02-10 16:41:24

标签: ios10 nsurl nsbundle imessage imessage-extension

我有这个网址

myString = 文件:///var/mobile/Containers/Data/PluginKitPlugin/-------/Documents/MyAudio.m4a

这是我的发送代码

  MSConversation * conversation = self.activeConversation;
    if (conversation) {
        MSMessageTemplateLayout * activeLayout = [[MSMessageTemplateLayout alloc] init];
       // activeLayout.image = image;
        activeLayout.caption = @"Message Counter";
        activeLayout.subcaption = @"Message subcaption";
        activeLayout.trailingCaption = @"Trailing caption";
        activeLayout.trailingSubcaption = @"Trailing Subcaption";

        activeLayout.mediaFileURL = [NSURL URLWithString:myString];

        activeLayout.imageTitle = @"Image counter";
        activeLayout.imageSubtitle = @"Image subtitle";

        MSMessage * message = [[MSMessage alloc] init];
        message.layout = activeLayout;
        message.URL = [NSURL URLWithString:@"Empty URL"];
        message.summaryText = @"This is Summary";

        [conversation insertMessage:message completionHandler:^(NSError *error) {
            if (error) {
                NSLog(@"Error sending message %@", [error localizedDescription]);
            }
        }];
    }
    else {
        NSLog(@"No &%#%&^# conversation found");
    }

我无法获取发送的音频文件我只有消息计数器等。

1 个答案:

答案 0 :(得分:-1)

使用insertAttachment-而不是使用insertMessage- [[conversation insertAttachment:[NSURL URLWithString:myString]; withAlternateFilename:@“Alternate Name”completionHandler:^(NSError * error){             DDLogInfo(@“错误是%@”,错误);         }];

相关问题