1.接入龙图iOSSDK的游戏及应用的iOS客户端开发者。
2.使用此文档内接口,需要先接入龙图iOSSDK(详情查看龙图iOSSDK文档,当前支持龙图官网最新版本)。
3.接入龙图iOSSDK后,需要配置WemixSDK需要的依赖库。
注:Wemix iOS终端SDK接入教程,只涉及SDK的使用方法。
WemixClientId:必须参数,联系运营支持获取并配置到info.plist中;
在官网下载对应SDK和demo
1、需要引入的三方库
另外,由于Mopub部分库为动态库所以需要在General中的Frameworks,Libraries,and Embedded Content中找到动态库WemixAuth_iOS.framework,将其设置为Embed & Sign(如图)
2、必须在 Xcode Build Settings 里面 Other Linker Flags 设置值 -ObjC。
该项如果设置错误,运行时就会出现异常:unrecognized selector sent to instance exception
3、添加URL TYPE
参数内容联系运营支持获取
4、添加白名单
<string>wemix-wallet</string>
5、配置Wemix识别参数
<key>LTBase_WemixLogin</key>
<true/>
如果使用wemix请设置布尔值为true
接口介绍
/**
* 启动接口
*/
- (BOOL)LTWeMixApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;
示例
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[LTWeMixSDK sharedInstance] LTWeMixApplication:application didFinishLaunchingWithOptions:launchOptions];
}
/**
* 生命周期接口
*/
- (BOOL)LTWeMixApplication:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options;
示例
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
{
NSLog(@"handleOpenURLannotation=%@", url);
[[LTWeMixSDK sharedInstance] LTWeMixApplication:app openURL:url options:options];
}
/// 授权接口
/// @param viewController viewController 控制器
/// @param contract 透传参数,可传空字符
/// @param nonce 透传参数,可传空字符
/// @param column 透传参数,可传空字符
/// @param amount 透传参数,可传空字符
/// @param method 透传参数,可传空字符
- (void)LTWeMixSignInWithWemix:(UIViewController *)viewController contract:(NSString *_Nullable)contract nonce:(NSString *_Nullable)nonce column:(NSString *)column amount:(NSString *_Nullable)amount method:(NSString *)method;
示例
[[LTWeMixSDK sharedInstance] LTWeMixSignInWithWemix:self contract:@"contract" nonce:@"nonce" column:@"column" amount:@"amount" method:@"method"]
代理方法
声明和设置代理
@interface ViewController ()<LTWeMixSDKDelegate>
@end
[LTWeMixSDK sharedInstance].delegate = self;
实现代理
- (void)LTWeMixSDKSignInWithWemixCallBack:(NSDictionary *)dict code:(NSInteger)code result:(BOOL)result {
/*
错误码:
100.成功
101.链接wemix失败
102.获取userID失败
103.获取sign失败
104.sign为空
105.授权服务端查询请求失败(具体失败原因见服务端返回)
106.授权服务端绑定请求失败
107.用户取消首次绑定wemix
108.用户取消三方绑定游客
109.accessToken为空
110.用户三方绑定游客失败
111.点击关闭绑定页面
112.打开绑定页面失败
*/
NSLog(@"LTWeMixSDKSignInWithWemixCallBack dict :%@,code:%ld",dict,(long)code);
/*
失败格式
dict :{
error = "\U70b9\U51fb\U5173\U95ed\U7ed1\U5b9a\U9875\U9762";
}
成功格式
dict :{
accessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJzb25nIiwiYWRkcmVzcyI6IjB4YTA2NGZmMzJmN2NkMzFhMWYxMDBlZWRhZjI5M2NkOTc3N2IwN2MwNCIsImF1ZCI6IjEwMDEtdG0ycW5kbm5obDlwZHNiZy5hcHBzLndlbWl4bmV0d29yay5jb20iLCJleHAiOjE2NDE1NDU4MzAsImp0aSI6InlGVUh0V1BhYllNSXJnSWEiLCJpYXQiOjE2NDE0NTk0MzAsInN1YiI6IjYyNTg4YjJhLWYxZmUtNGE3My1iODQ0LWMxODg1NjY3ZTQwZCJ9.3N8DPOMaO3CLAfFhhwDbmdaLu9ckAF3TV6cbvcppnok";
address = 0xa064ff32f7cd31a1f100eedaf293cd9777b07c04;
sign = 0x17fe4f6c113087a1a1ba71693928e7bf408fc3e45509bea5f41a347b28f081174bbb3a2849f620ec45b1cdbf58fbbd4edeb992e15a393e492ffee3cf3784fd4d00;
userID = 11111;
}
*/
}
接口介绍
/// 查询绑定状态接口
- (void)LTWeMixSignInWithWemixCheckBind;
示例说明
//查询绑定
[[LTWeMixSDK sharedInstance] LTWeMixSignInWithWemixCheckBind];
/// 绑定wemix接口
/// @param viewController 当前控制器
- (void)LTWeMixBindWemix:(UIViewController *)viewController;
示例说明
//绑定wemix
[[LTWeMixSDK sharedInstance] LTWeMixBindWemix:UIViewController];
//代理回调
//声明和设置代理(同之前代理设置,无需额外设置)
@interface ViewController ()<LTWeMixSDKDelegate>
@end
[LTWeMixSDK sharedInstance].delegate = self;
//实现代理
/// 绑定状态/绑定结果
/// @param type 回调类型 0=查询绑定状态回调;1=绑定wemix结果回调
/// @param code code 1=请求成功,=其他为失败状态
/// @param message 描述信息
/// @param isBind 是否已绑定(type=0)/是否绑定成功(type=1);返回yes代表成功,下列dict会返回token,userID和address,返回no则参数为空字符
/// @param dict 返回参数address/token/userId
- (void)LTWeMixSDKSignFromWemixWithType:(NSString *)type code:(NSInteger)code message:(NSString *)message isBind:(BOOL)isBind dict:(NSDictionary *)dict{
NSLog(@"LTWeMixSDKSignFromWemixWithType type:%@ isBind:%@ code:%ld msg:%@ dict :%@,",type,isBind ? @"yes" : @"no",(long)code,message,dict);
if ([type isEqualToString:@"0"]) {//查询
if (code == 1) {
if (isBind) {//已绑定
[self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ message :%@",type,@"yes" ,message]];
}else{//未绑定
[self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ message :%@",type,@"no",message]];
}
}else{//查询失败
[self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ msg :%@",type,@"no",message]];
}
}else{//单独绑定
if (code == 1) {//绑定
if (isBind) {//绑定成功
[self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ message :%@",type,@"yes" ,message]];
}else{//绑定失败
[self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ message :%@",type,@"no",message]];
}
}else{//绑定失败
[self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ msg :%@",type,@"no",message]];
}
}
/*
错误码:
1.成功
101.链接wemix失败
102.获取userID失败
105.授权服务端查询请求失败(具体失败原因见服务端返回)
106.授权服务端绑定请求失败
107.用户取消首次绑定wemix
108.用户取消三方绑定游客
109.accessToken为空
110.用户三方绑定游客失败
111.点击关闭绑定页面
112.打开绑定页面失败
*/
/*
失败格式
dict :{//返回空字符
address = ;
token = ;
userId = ;
}
成功格式
dict :{
address = 0xa064ff32f7cd31a1f100eedaf293cd9777b07c04;
code = 1;
token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJzb25nIiwiYWRkcmVzcyI6IjB4YTA2NGZmMzJmN2NkMzFhMWYxMDBlZWRhZjI5M2NkOTc3N2IwN2MwNCIsImF1ZCI6IjEwMDEtdG0ycW5kbm5obDlwZHNiZy5hcHBzLndlbWl4bmV0d29yay5jb20iLCJleHAiOjE2NDUyNjE0ODQsImp0aSI6IkpTYU9pcW5rYlhNZ05yVGciLCJpYXQiOjE2NDUxNzUwODQsInN1YiI6IjYyNTg4YjJhLWYxZmUtNGE3My1iODQ0LWMxODg1NjY3ZTQwZCJ9.tayCogoke4SLR6XlXg3f8Nv4axo8b_cFVNqH0pm8W0Q";
userId = 1200010000000000000000000000000000111111;
}
*/
}
状态码 | 说明 |
---|---|
1 | 成功(查询绑定状态和绑定wemix回调) |
100 | 成功(授权回调) |
101 | 链接wemix失败 |
102 | 获取userID失败 |
103 | 获取sign失败 |
104 | sign为空 |
105 | 授权服务端查询请求失败(具体失败原因见服务端返回) |
106 | 授权服务端绑定请求失败 |
107 | 用户取消首次绑定wemix |
108 | 用户取消三方绑定游客 |
109 | accessToken为空 |
110 | 用户三方绑定游客失败 |
111 | 点击关闭绑定页面 |
112 | 打开绑定页面失败 |
上海中清龙图软件有限公司