Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
E13Lau opened this issue Jun 3, 2017 · 1 comment
Open

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

E13Lau opened this issue Jun 3, 2017 · 1 comment

Comments

@E13Lau
Copy link
Contributor

E13Lau commented Jun 3, 2017

目前的分享方法

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)
            }
        }

大家想法是怎样的?

@Xinguang
Copy link
Owner

Xinguang commented Jun 5, 2017

目前除了登录, 其他都没有好好去实现.
这也是版本号一直都在0点几徘徊的原因.

你的提议不错, 但除了分享出去以外. 还要考虑, 如何返回 app.

目前有一个WechatManagerShareDelegate 去处理返回时,如何处理.

但是作为一个第四方(整合第三方)的框架, 不应该使用 Delegate. 会增加用户使用难度,
block 应该是比较好的选择.

也就是,需要在分享出去之前. 注册一下(设置一下返回的处理方法)block. 在分享.
如果不是 APP 分享,那么可以跳过注册这一步.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants