Wemix拓展功能接入说明

1.接入须知

1.接入龙图iOSSDK的游戏及应用的iOS客户端开发者。
2.使用此文档内接口,需要先接入龙图iOSSDK(详情查看龙图iOSSDK文档,当前支持龙图官网最新版本)。
3.接入龙图iOSSDK后,需要配置WemixSDK需要的依赖库。

注:Wemix iOS终端SDK接入教程,只涉及SDK的使用方法。

1.0 开发要求


  • iOS 13.0 及以上版本

  • XCode 12 及以上版本

  • 1.1 申请你的AppID

    WemixClientId:必须参数,联系运营支持获取并配置到info.plist中;

    1.2 下载SDK包和示例Demo

    在官网下载对应SDK和demo

    1.3 开发环境配置

    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、添加白名单

    1. <string>wemix-wallet</string>

    5、配置Wemix识别参数

    1. <key>LTBase_WemixLogin</key>
    2. <true/>

    如果使用wemix请设置布尔值为true

    2 功能接入

    2.1 生命周期接口

    2.1.1 启动接口

    接口介绍

    1. /**
    2. * 启动接口
    3. */
    4. - (BOOL)LTWeMixApplication:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions;

    示例

    1. - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    2. {
    3. [[LTWeMixSDK sharedInstance] LTWeMixApplication:application didFinishLaunchingWithOptions:launchOptions];
    4. }

    2.1.2 生命周期跳转接口

    1. /**
    2. * 生命周期接口
    3. */
    4. - (BOOL)LTWeMixApplication:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options;

    示例

    1. - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<NSString*, id> *)options
    2. {
    3. NSLog(@"handleOpenURLannotation=%@", url);
    4. [[LTWeMixSDK sharedInstance] LTWeMixApplication:app openURL:url options:options];
    5. }

    2.2授权接口

    1. /// 授权接口
    2. /// @param viewController viewController 控制器
    3. /// @param contract 透传参数,可传空字符
    4. /// @param nonce 透传参数,可传空字符
    5. /// @param column 透传参数,可传空字符
    6. /// @param amount 透传参数,可传空字符
    7. /// @param method 透传参数,可传空字符
    8. - (void)LTWeMixSignInWithWemix:(UIViewController *)viewController contract:(NSString *_Nullable)contract nonce:(NSString *_Nullable)nonce column:(NSString *)column amount:(NSString *_Nullable)amount method:(NSString *)method;

    示例

    1. [[LTWeMixSDK sharedInstance] LTWeMixSignInWithWemix:self contract:@"contract" nonce:@"nonce" column:@"column" amount:@"amount" method:@"method"]

    2.3授权回调代理

    代理方法

    1. 声明和设置代理
    2. @interface ViewController ()<LTWeMixSDKDelegate>
    3. @end
    4. [LTWeMixSDK sharedInstance].delegate = self;
    5. 实现代理
    6. - (void)LTWeMixSDKSignInWithWemixCallBack:(NSDictionary *)dict code:(NSInteger)code result:(BOOL)result {
    7. /*
    8. 错误码:
    9. 100.成功
    10. 101.链接wemix失败
    11. 102.获取userID失败
    12. 103.获取sign失败
    13. 104.sign为空
    14. 105.授权服务端查询请求失败(具体失败原因见服务端返回)
    15. 106.授权服务端绑定请求失败
    16. 107.用户取消首次绑定wemix
    17. 108.用户取消三方绑定游客
    18. 109.accessToken为空
    19. 110.用户三方绑定游客失败
    20. 111.点击关闭绑定页面
    21. 112.打开绑定页面失败
    22. */
    23. NSLog(@"LTWeMixSDKSignInWithWemixCallBack dict :%@,code:%ld",dict,(long)code);
    24. /*
    25. 失败格式
    26. dict :{
    27. error = "\U70b9\U51fb\U5173\U95ed\U7ed1\U5b9a\U9875\U9762";
    28. }
    29. 成功格式
    30. dict :{
    31. accessToken = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJzb25nIiwiYWRkcmVzcyI6IjB4YTA2NGZmMzJmN2NkMzFhMWYxMDBlZWRhZjI5M2NkOTc3N2IwN2MwNCIsImF1ZCI6IjEwMDEtdG0ycW5kbm5obDlwZHNiZy5hcHBzLndlbWl4bmV0d29yay5jb20iLCJleHAiOjE2NDE1NDU4MzAsImp0aSI6InlGVUh0V1BhYllNSXJnSWEiLCJpYXQiOjE2NDE0NTk0MzAsInN1YiI6IjYyNTg4YjJhLWYxZmUtNGE3My1iODQ0LWMxODg1NjY3ZTQwZCJ9.3N8DPOMaO3CLAfFhhwDbmdaLu9ckAF3TV6cbvcppnok";
    32. address = 0xa064ff32f7cd31a1f100eedaf293cd9777b07c04;
    33. sign = 0x17fe4f6c113087a1a1ba71693928e7bf408fc3e45509bea5f41a347b28f081174bbb3a2849f620ec45b1cdbf58fbbd4edeb992e15a393e492ffee3cf3784fd4d00;
    34. userID = 11111;
    35. }
    36. */
    37. }

    2.4 查询绑定状态接口

    接口介绍

    1. /// 查询绑定状态接口
    2. - (void)LTWeMixSignInWithWemixCheckBind;

    示例说明

    1. //查询绑定
    2. [[LTWeMixSDK sharedInstance] LTWeMixSignInWithWemixCheckBind];

    2.5 绑定wemix接口

    1. /// 绑定wemix接口
    2. /// @param viewController 当前控制器
    3. - (void)LTWeMixBindWemix:(UIViewController *)viewController;

    示例说明

    1. //绑定wemix
    2. [[LTWeMixSDK sharedInstance] LTWeMixBindWemix:UIViewController];

    2.6 查询绑定状态和绑定wemix回调代理

    //代理回调

    1. //声明和设置代理(同之前代理设置,无需额外设置)
    2. @interface ViewController ()<LTWeMixSDKDelegate>
    3. @end
    4. [LTWeMixSDK sharedInstance].delegate = self;
    5. //实现代理
    6. /// 绑定状态/绑定结果
    7. /// @param type 回调类型 0=查询绑定状态回调;1=绑定wemix结果回调
    8. /// @param code code 1=请求成功,=其他为失败状态
    9. /// @param message 描述信息
    10. /// @param isBind 是否已绑定(type=0)/是否绑定成功(type=1);返回yes代表成功,下列dict会返回token,userID和address,返回no则参数为空字符
    11. /// @param dict 返回参数address/token/userId
    12. - (void)LTWeMixSDKSignFromWemixWithType:(NSString *)type code:(NSInteger)code message:(NSString *)message isBind:(BOOL)isBind dict:(NSDictionary *)dict{
    13. NSLog(@"LTWeMixSDKSignFromWemixWithType type:%@ isBind:%@ code:%ld msg:%@ dict :%@,",type,isBind ? @"yes" : @"no",(long)code,message,dict);
    14. if ([type isEqualToString:@"0"]) {//查询
    15. if (code == 1) {
    16. if (isBind) {//已绑定
    17. [self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ message :%@",type,@"yes" ,message]];
    18. }else{//未绑定
    19. [self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ message :%@",type,@"no",message]];
    20. }
    21. }else{//查询失败
    22. [self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ msg :%@",type,@"no",message]];
    23. }
    24. }else{//单独绑定
    25. if (code == 1) {//绑定
    26. if (isBind) {//绑定成功
    27. [self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ message :%@",type,@"yes" ,message]];
    28. }else{//绑定失败
    29. [self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ message :%@",type,@"no",message]];
    30. }
    31. }else{//绑定失败
    32. [self showMessage:[NSString stringWithFormat:@"type:%@ isBind:%@ msg :%@",type,@"no",message]];
    33. }
    34. }
    35. /*
    36. 错误码:
    37. 1.成功
    38. 101.链接wemix失败
    39. 102.获取userID失败
    40. 105.授权服务端查询请求失败(具体失败原因见服务端返回)
    41. 106.授权服务端绑定请求失败
    42. 107.用户取消首次绑定wemix
    43. 108.用户取消三方绑定游客
    44. 109.accessToken为空
    45. 110.用户三方绑定游客失败
    46. 111.点击关闭绑定页面
    47. 112.打开绑定页面失败
    48. */
    49. /*
    50. 失败格式
    51. dict :{//返回空字符
    52. address = ;
    53. token = ;
    54. userId = ;
    55. }
    56. 成功格式
    57. dict :{
    58. address = 0xa064ff32f7cd31a1f100eedaf293cd9777b07c04;
    59. code = 1;
    60. token = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyaWQiOiJzb25nIiwiYWRkcmVzcyI6IjB4YTA2NGZmMzJmN2NkMzFhMWYxMDBlZWRhZjI5M2NkOTc3N2IwN2MwNCIsImF1ZCI6IjEwMDEtdG0ycW5kbm5obDlwZHNiZy5hcHBzLndlbWl4bmV0d29yay5jb20iLCJleHAiOjE2NDUyNjE0ODQsImp0aSI6IkpTYU9pcW5rYlhNZ05yVGciLCJpYXQiOjE2NDUxNzUwODQsInN1YiI6IjYyNTg4YjJhLWYxZmUtNGE3My1iODQ0LWMxODg1NjY3ZTQwZCJ9.tayCogoke4SLR6XlXg3f8Nv4axo8b_cFVNqH0pm8W0Q";
    61. userId = 1200010000000000000000000000000000111111;
    62. }
    63. */
    64. }

    3. 错误码

    状态码 说明
    1 成功(查询绑定状态和绑定wemix回调)
    100 成功(授权回调)
    101 链接wemix失败
    102 获取userID失败
    103 获取sign失败
    104 sign为空
    105 授权服务端查询请求失败(具体失败原因见服务端返回)
    106 授权服务端绑定请求失败
    107 用户取消首次绑定wemix
    108 用户取消三方绑定游客
    109 accessToken为空
    110 用户三方绑定游客失败
    111 点击关闭绑定页面
    112 打开绑定页面失败