-
Notifications
You must be signed in to change notification settings - Fork 55
Open
Labels
Description
目前的分享方法
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)
}
}
大家想法是怎样的?