2

我想从我的 iMessage 扩展发送一个 GIF 图片。消息与图像一起发送,但问题是图像没有动画。

我的做法:

    let msg = msgList[indexPath.row]
    
    let message = MSMessage()
    let msgLayout = MSMessageTemplateLayout()
    
    if let title = msg.message { msgLayout.caption = title }
    if let msgImg = msg.image { msgLayout.image = msgImg }
    
    message.layout = msgLayout

    if let conversation = self.activeConversation {
            conversation.insert(message) { error in
                print("Insert message error: \(String(describing: error))")
           }
     }

还尝试过mediaFileUrl

 if let url = Bundle.main.url(forResource: "IMG_0673", withExtension: "gif") {
            msgLayout.mediaFileURL = url
        }

但是当我尝试使用MSStickerGIF 动画时。

代码:

    do {
        let sticker = try MSSticker(contentsOfFileURL: Bundle.main.url(forResource:"AS001494_20", withExtension: "gif")!,localizedDescription: "a gif image")
        
        if let conversation = self.activeConversation {
            conversation.insert(sticker) { error in
                print(error)
            }
        }
        
    } catch {
        print("Sticker error: \(error.localizedDescription)")
    }

是否可以使用MSMessageand发送动画 GIF MSMessageTemplateLayout

4

0 回答 0