微信 官方 sdk 网页
有 接入指南 和 Demo
集成 微信
导入
#import <WXApi.h>
遵守协议
@interface AppDelegate()<WXApiDelegate>
AppDelegate.m
在 "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions NS_AVAILABLE_IOS(3_0);"
这个方法内 注册微信
要使你的程序启动后微信终端能响应你的程序,必须在代码中向微信终端注册你的id
// 注册微信分享
[WXApi registerApp:@"wx00000000"];
分享到微信
填加 微信 URL TYpe
Target -> info -> URL Types
填加
identifier 和 URL Schemes
image.png分享成功 获取 从 微信的反馈
// #pragma mark - 微信WXApiDelegate 方法
//重新拉起OA
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation {
// 微信分享 成功/取消 回掉响应
if([WXApi handleOpenURL:url delegate:self]){
return true;
}
}
// TODO: ll
-(void) onResp:(BaseResp)resp {
if([resp isKindOfClass:[SendMessageToWXResp class]])
{
// // WXSuccess = 0, /< 成功 /
// WXErrCodeCommon = -1, /< 普通错误类型 /
// WXErrCodeUserCancel = -2, /< 用户点击取消并返回 /
// WXErrCodeSentFail = -3, /< 发送失败 /
// WXErrCodeAuthDeny = -4, /< 授权失败 /
// WXErrCodeUnsupport = -5, /< 微信不支持 */
if(resp.errCode == 0){
[HUD showSuccessWithStatus:@"分享成功"];
}else if(resp.errCode == -2) {
[HUD showErrorWithStatus:@"取消了分享"];
} else {
[HUD showErrorWithStatus:@"分享失败"];
}
}
}
网友评论