jiGuangXieZuo/ProductApp/Pods/WechatOpenSDK/OpenSDK2.0.4/WXApi.h

232 lines
8.5 KiB
C
Raw Normal View History

2024-10-17 16:36:05 +08:00
//
// WXApi.h
// 所有Api接口
//
// Created by Wechat on 12-2-28.
// Copyright (c) 2012年 Tencent. All rights reserved.
//
#import <Foundation/Foundation.h>
#import "WXApiObject.h"
NS_ASSUME_NONNULL_BEGIN
typedef BOOL(^WXGrantReadPasteBoardPermissionCompletion)(void);
#pragma mark - WXApiDelegate
/*! @brief 接收并处理来自微信终端程序的事件消息
*
*
* WXApiDelegate handleOpenURL:delegate:使
*/
@protocol WXApiDelegate <NSObject>
@optional
/*! @brief 收到一个来自微信的请求第三方应用程序处理完后调用sendResp向微信发送结果
*
* sendResp发送处理结果给微信
* GetMessageFromWXReqShowMessageFromWXReq等
* @param req
*/
- (void)onReq:(BaseReq*)req;
/*! @brief 发送一个sendReq后收到微信的回应
*
* sendReq后会收到onResp
* SendMessageToWXRespSendAuthResp等
* @param resp具体的回应内容
*/
- (void)onResp:(BaseResp*)resp;
/* ! @brief 用于在iOS16以及以上系统上控制OpenSDK是否读取剪切板中微信传递的数据以及读取的时机
* iOS16以及以上系统SDK需要读取剪切板中微信写入的数据时
*
* 1. iOS16以及以上的系统版本上回调;
* 2. OpenSDK会直接调用读取剪切板接口;
* 3. completion(), SDK允许读取剪切板中微信传递的数据,
* completion()OpenSDK读取剪切板onReq:, onResp:使
* 4. completion不释放
*/
- (void)onNeedGrantReadPasteBoardPermissionWithURL:(nonnull NSURL *)openURL completion:(nonnull WXGrantReadPasteBoardPermissionCompletion)completion;
@end
#pragma mark - WXApiLogDelegate
@protocol WXApiLogDelegate <NSObject>
- (void)onLog:(NSString*)log logLevel:(WXLogLevel)level;
@end
#pragma mark - WXApi
/*! @brief 微信Api接口函数类
*
* SDK的所有接口
*/
@interface WXApi : NSObject
/*! @brief WXApi的成员函数向微信终端程序注册第三方应用。
*
*
* @attention 线
* @param appid ID
* @param universalLink Universal Link
* @return YESNO
*/
+ (BOOL)registerApp:(NSString *)appid universalLink:(NSString *)universalLink;
/*! @brief 处理旧版微信通过URL启动App时传递的数据
*
* application:openURL:sourceApplication:annotation:application:handleOpenURL中调用
* @param url URL
* @param delegate WXApiDelegate对象
* @return YESNO
*/
+ (BOOL)handleOpenURL:(NSURL *)url delegate:(nullable id<WXApiDelegate>)delegate;
/*! @brief 处理微信通过Universal Link启动App时传递的数据
*
* application:continueUserActivity:restorationHandler:
* @param userActivity API传递过来的userActivity
* @param delegate WXApiDelegate对象
* @return YESNO
*/
+ (BOOL)handleOpenUniversalLink:(NSUserActivity *)userActivity delegate:(nullable id<WXApiDelegate>)delegate;
/*! @brief 检查微信是否已被用户安装
*
* @return YESNO
*/
+ (BOOL)isWXAppInstalled;
/*! @brief 判断当前微信的版本是否支持OpenApi
*
* @return YESNO
*/
+ (BOOL)isWXAppSupportApi;
/*! @brief 判断当前微信的版本是否支持分享微信状态功能
*
* @attention LSApplicationQueriesSchemes配置中添加weixinStateAPI
* @return YESNO
*/
+ (BOOL)isWXAppSupportStateAPI;
#ifndef BUILD_WITHOUT_PAY
/*! @brief 判断当前微信的版本是否支持二维码拉起微信支付
*
* @attention LSApplicationQueriesSchemes配置中添加weixinQRCodePayAPI
* @return YESNO
*/
+ (BOOL)isWXAppSupportQRCodePayAPI;
#endif
/*! @brief 获取微信的itunes安装地址
*
* @return
*/
+ (NSString *)getWXAppInstallUrl;
/*! @brief 获取当前微信SDK的版本号
*
* @return SDK的版本号
*/
+ (NSString *)getApiVersion;
/*! @brief 打开微信
*
* @return YESNO
*/
+ (BOOL)openWXApp;
/*! @brief 发送请求到微信等待微信返回onResp
*
* onResponResp
* SendAuthReqSendMessageToWXReqPayReq等
* @param req
* @param completion block
*/
+ (void)sendReq:(BaseReq *)req completion:(void (^ __nullable)(BOOL success))completion;
/*! @brief 收到微信onReq的请求发送对应的应答给微信并切换到微信界面
*
* onReq的请求
* GetMessageFromWXRespShowMessageFromWXResp等
* @param resp
* @param completion block
*/
+ (void)sendResp:(BaseResp*)resp completion:(void (^ __nullable)(BOOL success))completion;
/*! @brief 发送Auth请求到微信支持用户没安装微信等待微信返回onResp
*
* onResponRespSendAuthReq类型
* @param req
* @param viewController
* @param delegate WXApiDelegate对象
* @param completion block
*/
+ (void)sendAuthReq:(SendAuthReq *)req viewController:(UIViewController*)viewController delegate:(nullable id<WXApiDelegate>)delegate completion:(void (^ __nullable)(BOOL success))completion;
/*! @brief 测试函数用于排查当前App通过Universal Link方式分享到微信的流程
1: registerApp:universalLink接口,
2: Log产生startLogByLevel函数Log排查问题
3: block
4: SDK时调试使用
*
* completion回调的step为WXULCheckStepFinal时Universal Link接入成功
* @param completion Block
*/
+ (void)checkUniversalLinkReady:(nonnull WXCheckULCompletion)completion;
/*! @brief WXApi的成员函数接受微信的log信息。byBlock
1:SDK会强引用这个block,,
2:startLog by block之后startLoad,logBlocklogBlock
*
* @param level log的级别
* @param logBlock log的回调block
*/
+ (void)startLogByLevel:(WXLogLevel)level logBlock:(WXLogBolock)logBlock;
/*! @brief WXApi的成员函数接受微信的log信息。byDelegate
1:sdk会弱引用这个delegateWXApiDelegate同一个对象
2:startLog by delegate之后startLoad,logDelegate对象
* @param level log的级别
* @param logDelegate log的回调代理
*/
+ (void)startLogByLevel:(WXLogLevel)level logDelegate:(id<WXApiLogDelegate>)logDelegate;
/*! @brief 停止打印log会清理block或者delegate为空释放block
* @param
*/
+ (void)stopLog;
@end
NS_ASSUME_NONNULL_END