Skip to content

关于修改分享方法讨论 #16

@E13Lau

Description

@E13Lau

目前的分享方法

public func share(_ scence: WXScene,
                      image: UIImage?,
                      title: String,
                      description: String,
                      url: String? = "https://open.weixin.qq.com/",
                      extInfo: String? = nil)

其一是无法得到分享成功失败的回调信息,
其二是无法分享纯文本类型、图片类型、音乐类型、视频类型等信息。

我想法是把分享方法修改成如下:

    public func share(_ scence: WXScene, _ shareContent: ShareContent, completionHandler: AuthHandle? = nil) {
        self.completionHandler = completionHandler
        WXApi.send(shareContent.getReq(scence))
    }

其中 ShareContent 为一个枚举类型:

public enum ShareContent {
    case Text(text: String)
    case Image(image: Data, messageExt: String, action: String, thumbImage: UIImage)
    case Link(urlString: String, title: String, description: String, thumbImage: UIImage)
    case Music(musicURL: String, dataURL: String, title: String, description: String, thumbImage: UIImage)
    case Video(videoURL: String, title: String, description: String, thumbImage: UIImage)
    case mediaMessage(WXMediaMessage)
}

使用上会是这样

        WechatManager.shared.share(WXSceneSession, .Text(text: "test")) { (result) in
            switch result {
            case .success(_):
                print("分享成功")
            case .failure(let e):
                print(e.description)
            }
        }

大家想法是怎样的?

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions