WechatManager
public class WechatManager: NSObject
WechatManager
-
A closure used to receive and process request from Third-party
Declaration
Swift
public typealias Handle = (Result<[String: Any], Int32>) -> Void
-
微信开放平台,注册的应用程序id
Declaration
Swift
public static var appid: String!
-
微信开放平台,注册的应用程序Secret
Declaration
Swift
public static var appSecret: String!
-
openid
Declaration
Swift
public var openid: String!
-
access token
Declaration
Swift
public var accessToken: String!
-
refresh token
Declaration
Swift
public var refreshToken: String!
-
csrf
Declaration
Swift
public static var csrfState = "73746172626f796368696e61"
-
分享Delegation
Declaration
Swift
public var shareDelegate: WechatManagerShareDelegate?
-
A shared instance
Declaration
Swift
public static let shared: WechatManager =
-
检查微信是否已被用户安装
Declaration
Swift
public func isInstalled() -> Bool
Return Value
微信已安装返回true,未安装返回false
-
处理微信通过URL启动App时传递的数据
需要在 application:openURL:sourceApplication:annotation:或者application:handleOpenURL中调用。
Declaration
Swift
public func handleOpenURL(_ url: URL) -> Bool
Parameters
url
微信启动第三方应用时传递过来的URL
Return Value
成功返回true,失败返回false
-
分享
Declaration
Swift
public func share(_ scence: WXScene, image: UIImage?, title: String, description: String, url: String? = "https://open.weixin.qq.com/", extInfo: String? = nil)
Parameters
scence
请求发送场景
image
消息缩略图
title
标题
description
描述内容
url
地址
extInfo
app分享信息 (点击分享内容返回程序时,会传给WechatManagerShareDelegate.showMessage(message: String)
-
收到一个来自微信的请求,第三方应用程序处理完后调用sendResp向微信发送结果
- 收到一个来自微信的请求,异步处理完成后必须调用sendResp发送处理结果给微信。
可能收到的请求有GetMessageFromWXReq、ShowMessageFromWXReq等。
Declaration
Swift
public func onReq(_ req: BaseReq)
Parameters
req
具体请求内容,是自动释放的
-
发送一个sendReq后,收到微信的回应
- 收到一个来自微信的处理结果。调用一次sendReq后会收到onResp。
可能收到的处理结果有SendMessageToWXResp、SendAuthResp等
Declaration
Swift
public func onResp(_ resp: BaseResp)
Parameters
resp
具体的回应内容,是自动释放的