MSSDK

SDK 文档


iOS SDK集成文档

<p>[TOC]</p> <h2>历史记录</h2> <table> <thead> <tr> <th>文档版本</th> <th>时间</th> <th>修改内容</th> <th>责任人</th> <th>备注</th> </tr> </thead> <tbody> <tr> <td>v1.0</td> <td>2019/01/02</td> <td>首次编写</td> <td>jack.deng</td> <td>无</td> </tr> <tr> <td>v1.1</td> <td>2019/01/07</td> <td>更新描述</td> <td>caden.liu</td> <td>无</td> </tr> <tr> <td>v1.2</td> <td>2019/01/22</td> <td>新增分享功能</td> <td>caden.liu</td> <td>无</td> </tr> <tr> <td>v1.2.1</td> <td>2019/11/06</td> <td>新增带UI的用户协议,隐私政策接口说明</td> <td>jack.deng</td> <td>需要更新SDK到1.4.1.2版本</td> </tr> <tr> <td>v1.2.2</td> <td>2019/11/08</td> <td>新增问卷星新增url参数。</td> <td>jack.deng</td> <td>需要更新SDK到1.4.2版本</td> </tr> <tr> <td>v1.5.0</td> <td>2019/12/1</td> <td>新增LBS功能</td> <td>jack.deng</td> <td>需要更新SDK到1.5.0版本</td> </tr> <tr> <td>v1.6.0</td> <td>2019/1/5</td> <td>新增push功能,LBS新增</td> <td>jack.deng</td> <td>需要更新SDK到1.6.0版本</td> </tr> <tr> <td>v1.7.0</td> <td>2010/1/16</td> <td>新增兑换码相关功能</td> <td>jack.deng</td> <td>需要更新SDK到1.7.0版本</td> </tr> <tr> <td>v1.8.0</td> <td>2010/2/27</td> <td>新增直播相关的功能描述</td> <td>jack.deng</td> <td>需要更新SDK到1.8.0版本</td> </tr> <tr> <td>v1.8.0</td> <td>2010/3/17</td> <td>新增关系链相关的功能描述</td> <td>mighty.liao</td> <td>需要更新SDK到1.8.0版本</td> </tr> <tr> <td>v1.9.0</td> <td>2010/3/20</td> <td>新增新浪微博相关功能描述。更新LBS描述</td> <td>jack.deng</td> <td>需要更新SDK到1.9.0版本</td> </tr> <tr> <td>v1.9.3</td> <td>2010/3/30</td> <td>新增OpenInstall接入相关内容</td> <td>jack.deng</td> <td>需要更新SDK到1.9.3版本</td> </tr> </tbody> </table> <h3>1 概述</h3> <ul> <li>MSSDK(Micro Services SDK)是2019年技术中台提供的全新标准化SDK</li> <li>支持iOS 8及以上系统,支持arm64、armv7架构,支持Xcode 11及以上版本</li> <li>本文主要描述iOS MSSDK新手集成教程,API调用细则请参考<a href="https://www.showdoc.cc/mssdk?page_id=2629802447347960z">《iOS MSSDK API文档》</a>和接入Demo。</li> </ul> <p><em>备注:当前版本支持游戏发行业务在iOS正版AppStore渠道基本最小范围的用户、支付和数据统计能力。</em></p> <p><strong>特别注意:如果开发者的应用有服务器(如强登录的APP)资源可以考虑在服务端接入我们的相关接口,这样可以保证登录和支付的安全。具体接入文档可以查看 <a href="https://www.showdoc.cc/mssdk?page_id=2640157465255050">MSSDK 服务端接入文档</a></strong></p> <h2>重要信息</h2> <p>在接入SDK之前,需要在我们后台申请账号并且创建应用参数,具体可以参考 <a href="https://www.showdoc.cc/mssdk?page_id=2692703335764519">技术中台服务接入指南</a> 文档。</p> <p>本文档中涉及到的 <code>错误码</code> 可以参考下面链接的内容。</p> <p>iOS SDK 错误码可以参考 <a href="https://www.showdoc.cc/mssdk?page_id=2629915269319032">iOS SDK 错误码</a> 文档</p> <p>在开发者接入SDK过程中遇到任何问题,请 <a href="https://www.showdoc.cc/mssdk?page_id=2615409307929897">联系我们</a>。</p> <p>开发者接入SDK完成后,可以按照我们提供的测试用例进行自测。测试用例如下: <img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/sdk_test_case.png?raw=true" alt="" /></p> <h3>2 事项准备</h3> <h4>2.1 申请乐逗参数</h4> <ul> <li> <p>登录<a href="http://biz.cloud.idreamsky.com">微服务业务控制台</a>创建应用,<span id="msConfig">将下载的配置文件 msConfig.json 加入到xcode工程中。</span>.</p> </li> <li> <p>如下图: <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/9bb32c077ddfb055c6995a3072b34bef?showdoc=.jpg" alt="" /></p> </li> <li>若无微服务帐号,请 <a href="https://www.showdoc.cc/mssdk?page_id=2615409307929897">联系我们</a> 开通。</li> </ul> <h4>2.2 策划集成方案</h4> <h5>2.2.1 登录页面(必须)</h5> <ul> <li>用户首次进入游戏,加载完游戏资源,进入「游戏登录页」</li> <li>用户在「游戏登录页」点击「帐号登录」调起登录面板,点击「快速进入」使用游客登录流程。</li> <li>设计参考:</li> <li><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/baa59413a2563986e8cd800ccd4741a6?showdoc=.jpg" alt="image" /></li> </ul> <h5>2.2.2 用户中心(必须)</h5> <ul> <li>用户成功登录进入游戏,游戏内提供「用户中心」入口,供用户维护帐号个人信息</li> <li>设计参考1:游戏主界面提供入口</li> <li><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/bd2716a54bb4839b05a897e3ea262139?showdoc=.jpg" alt="image" /></li> <li>设计参考2:游戏设置里提供入口</li> <li><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/994bcb78967a6efd3da54cd9214e3687?showdoc=.jpg" alt="image" /></li> </ul> <h3>3 SDK集成</h3> <h4>3.1 获取SDK和配置文件</h4> <ul> <li>获取MSSDK资源zip包,请 <a href="https://www.showdoc.cc/mssdk?page_id=2615409307929897">联系我们</a></li> <li>配置文件msConfig.json,<a href="https://www.showdoc.cc/mssdk?page_id=2615409307929897">联系我们</a></li> </ul> <h4>3.2 配置开发环境</h4> <h5>3.2.1 添加SDK文件到工程</h5> <ul> <li> <p>解压MSSDK资源zip包 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/1ef8073ce1eaa48e3c0c2711796b8bb4?showdoc=.jpg" alt="" /></p> </li> <li>添加MSSDK framework文件到工程</li> </ul> <p>步骤1:右键点击在Xcode工程主目录,点击<strong>Add Files to &quot;your project name&quot;</strong> <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/0d4c390ae778241ed9a5114ebc68bf3b?showdoc=.jpg" alt="" /></p> <p>步骤2:在弹窗里选中 <strong>MSLDSDK文件夹</strong>,再选择 <strong>Create groups</strong>,最后点击 <strong>Add</strong> 按钮,即完成添加 framework 到工程。 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/5ee5936e45a69d0d1c756ac649b17efe?showdoc=.jpg" alt="" /></p> <h5>3.2.2 添加framework文件路径</h5> <p>选择 <strong>TARGETS</strong> –&gt; <strong>Build Settings</strong> –&gt; <strong>Framework Search Paths</strong>,在此添加MSSDK的framework文件路径。(支持相对路径和绝对路径,不可含有空格)</p> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/da31d168005100ad6ada3ba3321c5eec?showdoc=.jpg" alt="" /></p> <h5>3.2.3 嵌入动态库</h5> <p>选择 <strong>TARGETS</strong> –&gt; <strong>General</strong> –&gt; <strong>Embedded Binaries</strong> -&gt; <strong>+</strong>,添加MSSDK的framework文件。</p> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/0cd04d476f2a07f60351a94743917315?showdoc=.jpg" alt="" /></p> <h5>3.2.4 设置Build Settings</h5> <p>选择 <strong>TARGETS</strong> –&gt; <strong>Build Settings</strong> -&gt; <strong>Other Linker Flags</strong>,添加 -ObjC和-lz。</p> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/ae72571bc589131aa209abce28f9fd9b?showdoc=.jpg" alt="" /></p> <h5>3.2.5 添加配置文件到工程</h5> <p>将MSSDK的配置文件msConfig.json添加到工程主目录。</p> <h4>3.3 初始化SDK</h4> <ul> <li>在AppDelegate.m导入SDK的头文件</li> </ul> <pre><code class="language-objc">#import &lt;MSLDSDK/MSLDSDK.h&gt;</code></pre> <ul> <li>在AppDelegate以下代理方法中调用初始化函数</li> </ul> <pre><code class="language-objc">- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(nullable NSDictionary *)launchOptions</code></pre> <ul> <li>调用初始化函数</li> </ul> <p><em>备注:初始化参数是从SDK配置文件中读取,参数错误会导致初始化失败,只有初始化成功,SDK的各项功能才能正常使用。</em></p> <pre><code class="language-objc">// 初始化MSSDK [[MSLDSDK sharedInstance] initSDKWithSuccess:^(NSString *msg, id data) { NSLog(@"init MSLD SDK success!"); } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { NSLog(@"init MSLD SDK failed! code = %ld, msg = %@", code, msg); }];</code></pre> <h5>3.4 获取配置信息(选接)</h5> <ul> <li>获取MSSDK配置信息。</li> <li>调用示例</li> </ul> <pre><code class="language-objc">MSLDConfig *config = [[MSLDSDK sharedInstance] syncActionWithLDUrl:ROUTE_SDK_CONFIG param:nil];</code></pre> <h3>4 功能接入</h3> <ul> <li>只有SDK初始化成功,才能调用MSSDK的各项功能。</li> <li>MSSDK含有用户、支付和数据统计功能。</li> </ul> <h4>4.1 接入用户</h4> <ul> <li>MSSDK用户功能提供登录、用户中心和实名认证等能力。</li> </ul> <h5>4.1.1 登录面板</h5> <h5>4.1.1.2 展示登录面板</h5> <ul> <li>登录面板提供登录UI界面。</li> <li>当前版本支持手机号验证码、用户名密码和游客登录。</li> </ul> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/fc0f7f530d6fe240616db667f27671f2?showdoc=.jpg" alt="" /></p> <ul> <li>调用示例:</li> </ul> <pre><code class="language-objc">// url参数设置为ROUTE_ _LOGIN [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ACCOUNT_LOGIN param:@{} success:^(NSString *msg, id data) { // 登录成功 成功后,会在data中告知登录的用户信息 NSString *logStr = [NSString stringWithFormat:@"登录面板登录成功!, msg = %@, data = %@", msg, data]; NSLog(@"%@",logStr); [self changeToMainScence];// 登录完成后,跳入到需要的场景 } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 登录失败 在此block中,会告知失败原因,游戏需要根据错误码做自己相关的业务。 if (MSLDErrorCodeUIUserClose == code) { // 用户取消了登录 NSLog(@"用户取消了登录:%@",msg); } else { // 登录失败 NSString *logStr = [NSString stringWithFormat:@"登录面板登录失败!code = %ld, msg = %@, data = %@", code, msg, errorData]; NSLog(@"%@", logStr); } }];</code></pre> <h5>4.1.1.2.1 一键登录</h5> <p>SDK内置了一键登录的功能。若配置了一键登录功能且能够正常获取手机号,将在呼出登录面板的流程中优先显示一键登录页面。</p> <h6>4.1.1.2.1.1 极光后台配置</h6> <ul> <li>请在极光的后台申请应用。即可获取极光的appkey。 申请方式请联系渠道商务同事。</li> <li>在极光后台的 应用设置-&gt; 认证设置 -&gt; 一键登录 里面,设置RSA加密公钥。 公钥请填入msConfig.json文件中的 ms_app_public_key 对应的值。</li> </ul> <h6>4.1.1.2.1.2 配置极光的key到msConfig.json文件中。</h6> <p>在msConfig.json中填入极光的appkey。注意key为 “jg_app_key”。</p> <h5>4.1.2 游客登录</h5> <ul> <li>为用户创建游客帐号,无需进行任何验证,即可进入游戏体验。</li> <li>调用示例:</li> </ul> <pre><code class="language-objc">[[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ACCOUNT_GUEST_LOGIN param:@{} success:^(NSString *msg, id data) { // 登录成功 NSString *logStr = [NSString stringWithFormat:@"快速登录成功!, msg = %@, data = %@", msg, data]; NSLog(@"%@",logStr); [self changeToMainScence]; // 登录完成后,跳入到需要的场景 } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { if (MSLDErrorCodeUIUserClose == code) { // 用户取消了登录 NSLog(@"用户取消了登录:%@",msg); } else { // 登录失败 NSString *logStr = [NSString stringWithFormat:@"快速登录失败!code = %ld, msg = %@, data = %@", code, msg, errorData]; NSLog(@"%@", logStr); } }];</code></pre> <h5>4.1.3 自动登录</h5> <ul> <li>用户场景:用户登录成功且无触发登出,再次启动游戏时无需验证,直接进入游戏。</li> <li>SDK逻辑:游戏调用MSSDK自动登录接口,MSSDK使用最近一次登录信息进行自动登录。</li> <li>调用示例:</li> </ul> <pre><code class="language-objc">[[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ACCOUNT_AUTO_LOGIN param:@{} success:^(NSString *msg, id data) { // 自动登录成功 NSString *logStr = [NSString stringWithFormat:@"自动登录成功!, msg = %@, data = %@", msg, data]; NSLog(@"%@", logStr); // 进入游戏主界面 [self changeToMainScence]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 自动登录失败 NSString *logStr = [NSString stringWithFormat:@"自动登录失败!code = %ld, msg = %@, data = %@", code, msg, errorData]; NSLog(@"%@", logStr); // 进入游戏登录页 [self.gameLoginView setHidden:NO]; }];</code></pre> <h5>4.1.4 监听账号系统回调事件</h5> <p>和账号系统相关的回调,会通过全局代理的方式,告知CP方。CP方可以根据回调信息做自己的逻辑。 目前和账号系统相关的回调事件有:</p> <table> <thead> <tr> <th>事件名</th> <th>事件</th> <th>说明</th> </tr> </thead> <tbody> <tr> <td>MSLDSDKSwitchAccount</td> <td>切换账号</td> <td></td> </tr> <tr> <td>MSLDSDKLogOut</td> <td>登出</td> <td></td> </tr> <tr> <td>MSLDSDKAccountInfoUpdated</td> <td>个人信息变更</td> <td>data中会带回账号信息中哪个字段更新了。以及是不是首次更新的信息。通过位掩码的形式实现。详情请看demo</td> </tr> </tbody> </table> <ul> <li>游戏可通过监听登录回调事件,及时处理游戏帐号的业务逻辑。</li> <li>步骤1:在合适的地方设置代理</li> </ul> <pre><code class="language-objc">[MSLDSDK sharedInstance].delegate = self;</code></pre> <ul> <li>步骤2:实现代理的方法,并处理相应登录相关事件</li> </ul> <pre><code class="language-objc">-(void)onMSLDSDKEvent:(MSLDSDKGlobalEvent)eventID msg:(NSString *)msg data:(id)data{ switch (eventID) { case MSLDSDKLogOut: //用户登出 NSLog(@"onEvennt MSLDSDKLogOut"); break; case MSLDSDKSwitchAccount: //用户切换帐号,并登录成功 NSLog(@"onEvennt MSLDSDKSwitchAccount"); break; case MSLDSDKAccountInfoUpdated:{ NSDictionary * userInfo = (NSDictionary *)data; MSLDUserInfoField filed = [[userInfo objectForKey:@"field"] unsignedIntegerValue]; MSLDUserInfoField isNew = [[userInfo objectForKey:@"isNew"] unsignedIntegerValue]; MSLDAccount * account = [userInfo objectForKey:@"account"]; if (filed &amp; MSLDUserInfoFieldPhone) { BOOL isFiledNew = ((isNew &amp; MSLDUserInfoFieldPhone) == MSLDUserInfoFieldPhone); // 绑定手机 [MSLDLog logDebug:@"MSLDSDK onMSLDSDKEvent MSLDUserInfoFieldPhone(%ld) account=%@", isFiledNew, account]; }else if (filed &amp; MSLDUserInfoFieldPassword) { // 设置密码 BOOL isFiledNew = ((isNew &amp; MSLDUserInfoFieldPassword) == MSLDUserInfoFieldPassword); [MSLDLog logDebug:@"MSLDSDK onMSLDSDKEvent MSLDUserInfoFieldPassword(%ld) account=%@",isFiledNew, account]; }else if ((filed &amp; MSLDUserInfoFieldUserName) || (filed &amp; MSLDUserInfoFieldAvatar)) { BOOL isUserNameNew = ((isNew &amp; MSLDUserInfoFieldUserName) == MSLDUserInfoFieldUserName); BOOL isAvatarNew = ((isNew &amp; MSLDUserInfoFieldAvatar) == MSLDUserInfoFieldAvatar); // 同步昵称和头像 [MSLDLog logDebug:@"MSLDSDK onMSLDSDKEvent MSLDUserInfoFieldUserName(%ld)|MSLDUserInfoFieldAvator(%ld) account=%@",isUserNameNew,isAvatarNew, account]; }else if (filed &amp; MSLDUserInfoFieldRealName) { BOOL isFiledNew = ((isNew &amp; MSLDUserInfoFieldRealName) == MSLDUserInfoFieldRealName); // 实名认证 [MSLDLog logDebug:@"MSLDSDK onMSLDSDKEvent MSLDUserInfoFieldRealName(%ld) account=%@",isFiledNew, account]; } } break; default: break; } }</code></pre> <h5>4.1.5 用户中心</h5> <ul> <li> <p>用户中心是乐逗用户中心UI界面,包含用户信息、手机绑定、密码设置、实名认证和切换帐号等功能。 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/84174f12a091c20310b95c9a90609135?showdoc=.jpg" alt="" /></p> </li> <li>调用示例:</li> </ul> <pre><code class="language-objc">[[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ACCOUNT_USER_CENTER param:nil success:^(NSString *msg, id data) { } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { if (MSLDErrorCodeUIUserClose == code) { // 用户关闭了个人中心 } }];</code></pre> <h5>4.1.6 实名认证(选接)</h5> <ul> <li>用户中心面板已有实名认证入口,单独的实名认证接口(含UI)支持游戏在其他场景下的直接调用。</li> <li>调用示例:</li> </ul> <pre><code class="language-objc">[[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ACCOUNT_AUTHENTICATION param:nil success:^(NSString *msg, id data) { // 实名认证成功 MSLDLOG(@"auth success! msg: %@, data :%@",msg, data); } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 实名认证失败 MSLDLOG(@"auth fail! code %li msg: %@, data :%@", (long)code, msg, errorData); }];</code></pre> <h5>4.1.7 获取用户信息(选接)</h5> <ul> <li>获取当前用户的用户信息,具体内容可查看<a href="https://www.showdoc.cc/mssdk?page_id=2629802447347960">《iOS MSSDK API文档》</a></li> <li>调用示例:</li> </ul> <pre><code class="language-objc">MSLDAccount *account = [[MSLDSDK sharedInstance] syncActionWithLDUrl:ROUTE_ACCOUNT_LOGINED_USER_INFO param:nil];</code></pre> <h5>4.1.8 用户协议和隐私政策(选接)</h5> <ul> <li>SDK提供了展示用户协议和隐私政策面板的功能。可以调用<code>ROUTE_ACCOUNT_USER_AGREEMENT</code>,<code>ROUTE_ACCOUNT_PRIVATE_AGREEMENT</code> 来展示。当用户点返回后,会收到回调返回码 MSLDErrorCodeUIUserBack ,游戏可以继续接下来的流程。</li> <li>SDK也提供了更深入定制话的数据层接口,可以直接返回用户协议和隐私政策的数据。游戏也可以用这些数据自己去绘制UI。调用 <code>ROUTE_ACCOUNT_DIRECT_USER_AGREEMENT</code>和 <code>ROUTE_ACCOUNT_DIRECT_PRIVATE_AGREEMENT</code> 可分别获取用户协议和隐私条款的数据。</li> <li>若无特别需求,建议使用面板的方式。</li> </ul> <h5>4.1.9 最佳实践</h5> <ul> <li>登录接口调用最佳实践 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/db16dbe93c50dbe82b42f43e649da317?showdoc=.jpg" alt="" /></li> </ul> <h4>4.2 接入支付</h4> <ul> <li>MSSDK支付功能提供苹果IAP内购能力。</li> <li>前置条件:在<a href="https://itunesconnect.apple.com/">App Store商品后台</a>和服务业务控制台配置游戏商品信息。</li> <li>注意:支付功能依赖于用户功能,在用户登录状态下,才能调用成功支付相关接口。</li> <li>客户端发放商品的游戏必须实现补单代理方法,详见本文档4.2.2章节。</li> </ul> <h4>4.2.1 设置游戏支付回调地址</h4> <p><strong> 如果你不接入支付的话,可以忽略本部分内容。</strong></p> <ul> <li>游戏支付回调地址是用于接收到账通知的URL,MSSDK在充值成功后会向URL发送同步请求。</li> <li>配置入口:<a href="http://biz.cloud.idreamsky.com">微服务业务控制台</a> ,如下图:</li> <li> <p><strong>注意</strong>:客户端发放商品的休闲游戏,请填入<strong><a href="http://ois-pay.uu.cc/order/sdk_callback">http://ois-pay.uu.cc/order/sdk_callback</a></strong></p> </li> <li> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/c77083a001d6fecc580187ff268912a7?showdoc=.jpg" alt="image" /></p> </li> <li><strong>注意</strong>:客户端发放商品的休闲游戏可以不配置,但必须实现补单代理方法,详见本文档4.2.2章节。</li> </ul> <h5>4.2.2 购买商品</h5> <ul> <li>在用户处于登录状态,才可调用购买商品接口。</li> <li>购买商品接口是无UI接口,需要游戏自行实现商品购买的UI界面。</li> <li>调用示例:</li> </ul> <pre><code class="language-objc">// 调用此接口,传入商品相关的信息,即可开启购买。商品相关的信息要和苹果后台配置的一致。 NSString * item = @"test01";//需要和苹果后台的配置一致 [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_PAY_PURCHASE_PRODUCT param:@{ PAY_PRODUCT_ID: item, PAY_EXTRA_INFO: @"" } success:^(NSString *msg, id data) { // 支付成功之后,将返回订单相关的信息。游戏可以根据这个订单信息,校验订单的有效性,从而下发道具。 MSLDOrder *order = data; NSLog(@"pay success! orderID : %@, productID :%@", order.orderID, order.productID); } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 支付失败。 NSLog(@"pay error! %@", msg); }];</code></pre> <h5>4.2.3 实现补单代理方法(客户端发放商品必接)</h5> <ul> <li>用户的购买流程可能因为异常情况导致中断,当流程恢复后,MSSDK会在回调代理中告知游戏方.</li> <li>游戏方需要在回调代理中,根据回调信息校验订单有效性,决定是否发放商品。</li> <li><strong>注意</strong>:通过<strong>服务端</strong>发放商品的游戏,请以支付服务器的通知为准,这个通知仅作为参考。</li> <li> <p><strong>注意</strong>:通过<strong>客户端</strong>发放商品的游戏,必须实现补单代理方法,进行补发商品,以免造成漏单!补发之 前请先确认订单的有效性,避免重复发放。</p> </li> <li>调用示例:</li> </ul> <pre><code class="language-objc">// 设置代理 [MSLDSDK sharedInstance].delegate = self; // 实现代理方法 -(void)onMSLDSDKEvent:(MSLDSDKGlobalEvent)eventID msg:(NSString *)msg data:(id)data{ switch (eventID) { case MSLDSDKRedeliveryOrder: // 收到补单成功后,需要根据回调信息继续处理购买成功后的流程 MSLDOrder *order = data; NSLog(@"onEvennt MSLDSDKRedeliveryOrder"); break; case ...: ... default: break; } }</code></pre> <h5>4.2.4 恢复购买</h5> <ul> <li>查询当前Apple ID在游戏内购买的非消耗型商品</li> <li>调用示例:</li> </ul> <pre><code class="language-objc">[[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_PAY_RESTORE_TRANSACTIONS param:nil success:^(NSString *msg, id data) { // 查询恢复购买成功 NSArray *restoreTransactions = data; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 查询恢复购买失败 }];</code></pre> <h5>4.2.5 查询商品信息</h5> <ul> <li>根据商品ID到苹果后台查询商品信息</li> <li>调用示例:</li> </ul> <pre><code class="language-objc">[[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_PAY_QUERY_PRODUCT param:@{ PAY_PRODUCT_ID: @"test01" } success:^(NSString *msg, id data) { // 查询商品信息成功 NSDictionary *productInfo = data; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 查询商品信息失败 }];</code></pre> <h5>4.2.6 查询订阅信息</h5> <ul> <li>查询用户当前订阅信息</li> <li>调用示例:</li> </ul> <pre><code class="language-objc">[[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_PAY_QUERY_SUBSCRIPTIONS param:nil success:^(NSString *msg, id data) { // 查询订阅信息成功 NSArray&lt;MSLDSubscription *&gt; *subscriptions = data; if (subscriptions.count &gt; 0) { } } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 查询订阅信息失败 }];</code></pre> <h4>4.3 接入分享</h4> <ul> <li>MSSDK分享功能提供微信,QQ,微博分享能力。</li> <li>当前版本支持以下分享场景: <ol> <li>分享图片到微信会话/微信会话/QQ好友/Qzone/微博</li> <li>分享链接到微信会话/微信会话/QQ好友/Qzone/微博</li> <li>分享微信小程序到微信会话</li> <li>应用打开微信小程序</li> </ol></li> </ul> <h5>4.3.1 QQ分享</h5> <h6>4.3.1.1 申请QQ参数</h6> <ul> <li>在<a href="https://connect.qq.com/index.html">QQ互联平台</a>创建应用并获取QQ AppId,具体联系渠道商务同事。</li> <li>在MSSDK配置文件msConfig.json填入QQ的 qq_app_id,qq_universal_link,具体请联系技术中台-标准化中台。</li> </ul> <h6>4.3.1.2 添加QQ SDK到Xcode工程</h6> <ul> <li>将iOS MSSDK的以下framework文件添加进XCode工程: <ol> <li>MSLDShareSDK.framework</li> <li>MSLDQQShareSDK.framework</li> <li>MSLDQQPackage.framework</li> </ol></li> <li>添加方法请参考本文档3.2.1、3.2.2和3.2.3章节。</li> </ul> <h6>4.3.1.3 配置QQ信息到XCode工程</h6> <ul> <li>URL Scheme配置</li> </ul> <p>选择 <strong>TARGETS</strong> –&gt; <strong>Info</strong> –&gt; <strong>URLTypes</strong>,新增一条<strong>URL scheme</strong>,命名为tencent+QQAppId,例如tencent222222 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/bee7eb1c13bcaac2b0517418de34cf5d?showdoc=.jpg" alt="" /></p> <ul> <li>LSApplicationQueriesSchemes配置</li> </ul> <p>选择 <strong>TARGETS</strong> –&gt; <strong>Info</strong> –&gt; <strong>LSApplicationQueriesSchemes</strong>,添加以下内容:</p> <pre><code class="language-xml">&lt;key&gt;LSApplicationQueriesSchemes&lt;/key&gt; &lt;array&gt; &lt;string&gt;mqq&lt;/string&gt; &lt;string&gt;mqqapi&lt;/string&gt; &lt;string&gt;mqqwpa&lt;/string&gt; &lt;string&gt;mqqbrowser&lt;/string&gt; &lt;string&gt;mttbrowser&lt;/string&gt; &lt;string&gt;mqqOpensdkSSoLogin&lt;/string&gt; &lt;string&gt;mqqopensdkapiV2&lt;/string&gt; &lt;string&gt;mqqopensdkapiV3&lt;/string&gt; &lt;string&gt;mqqopensdkapiV4&lt;/string&gt; &lt;string&gt;wtloginmqq2&lt;/string&gt; &lt;string&gt;mqzone&lt;/string&gt; &lt;string&gt;mqzoneopensdk&lt;/string&gt; &lt;string&gt;mqzoneopensdkapi&lt;/string&gt; &lt;string&gt;mqzoneopensdkapi19&lt;/string&gt; &lt;string&gt;mqzoneopensdkapiV2&lt;/string&gt; &lt;string&gt;mqqapiwallet&lt;/string&gt; &lt;string&gt;mqqopensdkfriend&lt;/string&gt; &lt;string&gt;mqqopensdkdataline&lt;/string&gt; &lt;string&gt;mqqgamebindinggroup&lt;/string&gt; &lt;string&gt;mqqopensdkgrouptribeshare&lt;/string&gt; &lt;string&gt;tencentapi.qq.reqContent&lt;/string&gt; &lt;string&gt;tencentapi.qzone.reqContent&lt;/string&gt; &lt;/array&gt;</code></pre> <ul> <li>分享回调代码:用于获知分享结果。</li> </ul> <pre><code class="language-objc">- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { [[MSLDSDK sharedInstance] msld_application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; return YES; } #if __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= __IPHONE_9_0 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary&lt;UIApplicationOpenURLOptionsKey, id&gt; *)options { [[MSLDSDK sharedInstance] msld_application:app openURL:url options:options]; return YES; } #endif</code></pre> <h6>4.3.1.4 调用QQ分享功能</h6> <ul> <li>分享图片到QQ好友:</li> </ul> <pre><code class="language-objc">- (void)shareImageToQQ { // 图片数据 // NSDictionary *param = @{ SHARE_SCENE: SHARE_QQ_FRIENDS, // @"image": [UIImage imageNamed:@"bg_launcher"], // @"thumbImage": [UIImage imageNamed:@"bg_launcher"], // @"title": @"分享图片标题", // @"description": @"分享图片描述" }; // 图片data数据 NSDictionary *param = @{ SHARE_SCENE: SHARE_QQ_FRIENDS, @"image": UIImagePNGRepresentation([UIImage imageNamed:@"bg_launcher"]), @"thumbImage": [UIImage imageNamed:@"bg_launcher"], @"title": @"分享图片标题", @"description": @"分享图片描述" }; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_IMAGE param:param success:^(NSString *msg, id data) { [MSLDLog logDebug:@"分享图片到QQ成功! msg=%@", msg]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; [MSLDLog logDebug:@"分享图片到QQ失败! code:%ld,msg=%@,errorData=%@", code, msg, errorData]; }]; }</code></pre> <ul> <li>分享图片到QZone:</li> </ul> <pre><code class="language-objc">- (void)shareImageToQzone { NSDictionary *param = @{ SHARE_SCENE: SHARE_QQ_QZONE, @"image": [UIImage imageNamed:@"bg_launcher"], @"thumbImage": [UIImage imageNamed:@"bg_launcher"], @"title": @"分享图片标题", @"description": @"分享图片描述" }; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_IMAGE param:param success:^(NSString *msg, id data) { [MSLDLog logDebug:@"分享图片到QZone成功! msg=%@", msg]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { [MSLDLog logDebug:@"分享图片到QZone失败! code:%ld,msg=%@,errorData=%@", code, msg, errorData]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <ul> <li>分享链接到QQ好友:</li> </ul> <pre><code class="language-objc">- (void)shareWebToQQ { NSDictionary *param = @{ SHARE_SCENE: SHARE_QQ_FRIENDS, @"webpageUrl": @"http://baidu.com", @"thumbImage": [UIImage imageNamed:@"bg_launcher"], @"title": @"分享链接标题", @"description": @"分享链接描述" }; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_WEBPAGE param:param success:^(NSString *msg, id data) { [MSLDLog logDebug:@"分享链接到QQ成功! msg=%@", msg]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { [MSLDLog logDebug:@"分享链接到QQ失败! code:%ld,msg=%@,errorData=%@", code, msg, errorData]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <ul> <li>分享链接到QZone:</li> </ul> <pre><code class="language-objc">- (void)shareWebToQzone { NSDictionary *param = @{ SHARE_SCENE: SHARE_QQ_QZONE, @"webpageUrl": @"http://baidu.com", @"thumbImage": [UIImage imageNamed:@"bg_launcher"], @"title": @"分享链接标题", @"description": @"分享链接描述" }; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_WEBPAGE param:param success:^(NSString *msg, id data) { [MSLDLog logDebug:@"分享链接到QZone成功! msg=%@", msg]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { [MSLDLog logDebug:@"分享链接到QZone失败! code:%ld,msg=%@,errorData=%@", code, msg, errorData]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <h5>4.3.2 微信分享</h5> <h6>4.3.2.1 申请微信参数</h6> <ul> <li>在<a href="https://open.weixin.qq.com/">微信开放平台</a>创建应用并获取微信AppId,具体联系渠道商务同事。</li> <li>在MSSDK配置文件msConfig.json填入微信的 wx_app_id,wx_app_secret,wx_universal_link。具体请联系技术中台-标准化中台</li> </ul> <h6>4.3.2.2 添加微信SDK到Xcode工程</h6> <ul> <li>将iOS MSSDK的以下framework文件添加进XCode工程: 1.MSLDShareSDK.framework 2.MSLDWeChatShareSDK.framework 3.MSLDWeChatPackage.framework</li> <li>添加方法请参考本文档3.2.1、3.2.2和3.2.3章节。</li> </ul> <h6>4.3.2.3 配置微信信息到XCode工程</h6> <ul> <li>URL Scheme配置:</li> </ul> <p>选择 <strong>TARGETS</strong> –&gt; <strong>Info</strong> –&gt; <strong>URLTypes</strong>,新增一条<strong>URL scheme</strong>,命名为wx+appid,例如wx3f520918821729b6 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/1ec2f162131ac5452eb0d83879482aab?showdoc=.jpg" alt="" /></p> <ul> <li>LSApplicationQueriesSchemes 配置</li> </ul> <p>选择 <strong>TARGETS</strong> –&gt; <strong>Info</strong> –&gt; <strong>LSApplicationQueriesSchemes</strong>,添加weixin</p> <pre><code class="language-xml">&lt;key&gt;LSApplicationQueriesSchemes&lt;/key&gt; &lt;array&gt; &lt;string&gt;weixin&lt;/string&gt; &lt;string&gt;weixinULAPI&lt;/string&gt; &lt;/array&gt;</code></pre> <ul> <li>分享回调代码:用于获知分享结果。</li> </ul> <pre><code class="language-objc">- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { [[MSLDSDK sharedInstance] msld_application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; return YES; } #if __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= __IPHONE_9_0 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary&lt;UIApplicationOpenURLOptionsKey, id&gt; *)options { [[MSLDSDK sharedInstance] msld_application:app openURL:url options:options]; return YES; } #endif</code></pre> <h6>4.3.2.4 调用微信分享功能</h6> <ul> <li>分享图片到微信会话</li> </ul> <pre><code class="language-objc">- (void)shareImageToWeChatSession { UIImage *image = [UIImage imageNamed:@"bg_launcher"]; UIImage *thumbImage = [UIImage imageNamed:@"AppIcon"]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_IMAGE param:@{ SHARE_SCENE: SHARE_WECHAT_SESSION, @"image": image, @"thumbImage": thumbImage } success:^(NSString *msg, id data) { MSLDLOG(@"--------- shareImageToWeChatSession success"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { MSLDLOG(@"--------- shareImageToWeChatSession fail"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <ul> <li>分享图片到朋友圈</li> </ul> <pre><code class="language-objc"> - (void)shareImageToWeChatTimeLine { UIImage *image = [UIImage imageNamed:@"bg_launcher"]; UIImage *thumbImage = [UIImage imageNamed:@"AppIcon"]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_IMAGE param:@{ SHARE_SCENE: SHARE_WECHAT_TIMELINE, @"image": image, @"thumbImage": thumbImage } success:^(NSString *msg, id data) { MSLDLOG(@"--------- shareImageToWeChatTimeLine success"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { MSLDLOG(@"--------- shareImageToWeChatTimeLine fail"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <ul> <li>分享链接到微信会话</li> </ul> <pre><code class="language-objc"> - (void)shareWebpageToWeChatSession { UIImage *image = [UIImage imageNamed:@"bg_launcher"]; NSString *webpageUrl = @"www.baidu.com"; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_WEBPAGE param:@{ SHARE_SCENE: SHARE_WECHAT_SESSION, @"thumbImage": image, @"webpageUrl": webpageUrl, @"title": @"百度一下", @"description": @"你就知道" } success:^(NSString *msg, id data) { MSLDLOG(@"--------- shareWebpageToWeChatSession success"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { MSLDLOG(@"--------- shareWebpageToWeChatSession fail"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <ul> <li>分享链接到朋友圈</li> </ul> <pre><code class="language-objc">- (void)shareWebpageToWeChatTimeLine { UIImage *image = [UIImage imageNamed:@"bg_launcher"]; NSString *webpageUrl = @"www.baidu.com"; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_WEBPAGE param:@{ SHARE_SCENE: SHARE_WECHAT_TIMELINE, @"thumbImage": image, @"webpageUrl": webpageUrl, @"title": @"百度一下", @"description": @"你就知道" } success:^(NSString *msg, id data) { MSLDLOG(@"--------- shareWebpageToWeChatTimeLine success"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { MSLDLOG(@"--------- shareWebpageToWeChatTimeLine fail"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <ul> <li>分享微信小程序到微信会话</li> </ul> <ol> <li>参数申请:在<a href="https://mp.weixin.qq.com/">微信公众平台</a>注册小程序并获取小程序原始id,具体联系渠道商务或技术中台-微信组。</li> <li>注意事项:在<a href="https://open.weixin.qq.com/">微信开放平台</a>,将应用所属的微信开发平台帐号绑定小程序,具体联系渠道商务或技术中台-微信组。</li> <li>调用示例:</li> </ol> <pre><code class="language-objc">- (void)shareWeChatMiniPragram { NSString *userName = @"gh_cda1b47da577";//小程序原始id NSString *thumbImage = @"https://www.idreamsky.com/static/img/service/icon4.png";//小程序新版本的预览图 128k NSString *url = @"https://www.idreamsky.com/";//低版本网页链接&lt;玩家手机中的微信版本低到不支持小程序, 就需要展示web&gt; NSString *path = @"";//需要进入到的小程序路径(若为空,则进入小程序首页) NSString *title = @"这里是标题";//分享标题 NSString *description = @"这里是描述";//分享描述 NSNumber *miniprogramType = [NSNumber numberWithInt:0];//小程序场景类型 (0:正式版 1:开发版 2:体验版) [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_MINI_PROGRAM param:@{ @"userName": userName, @"path": path, @"webpageUrl": url, @"withShareTicket": @"1", @"title": title, @"description": description, @"thumbImage": thumbImage, @"type": miniprogramType } success:^(NSString *msg, id data) { MSLDLOG(@"--------- shareWeChatMiniPragram success"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { MSLDLOG(@"--------- shareWeChatMiniPragram fail"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <ul> <li>应用打开微信小程序</li> </ul> <ol> <li>参数申请:在<a href="https://mp.weixin.qq.com/">微信公众平台</a>注册小程序并获取小程序原始id,具体联系渠道商务或技术中台-微信组。</li> <li>注意事项:在<a href="https://open.weixin.qq.com/">微信开放平台</a>将应用所属的微信开发平台帐号绑定小程序,具体联系渠道商务或技术中台-微信组。</li> <li>调用示例:</li> </ol> <pre><code class="language-objc">- (void)openWeChatMiniPragram { NSString *userName = @"gh_cda1b47da577";//小程序原始id 梦幻家园 gh_f67f93083326 绝地战机 gh_e46d2ebfbff6 [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_LAUNCH_MINI_PROGRAM param:@{ @"userName": userName } success:^(NSString *msg, id data) { MSLDLOG(@"--------- openWeChatMiniPragram success"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { MSLDLOG(@"--------- openWeChatMiniPragram fail"); [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <h5>4.3.3 微博分享</h5> <h6>4.3.3.1 申请微博参数</h6> <ul> <li>在<a href="https://open.weibo.com/">新浪微博开放平台</a>创建应用并获取微博 App Key,Sectet, redirectURI。具体联系渠道商务同事。</li> <li>在MSSDK配置文件msConfig.json填入获取的的 ms_weibo_Key,ms_weibo_Secret,ms_weibo_redirectURI。具体请联系技术中台-标准化中台。</li> </ul> <h6>4.3.3.2 添加微博 SDK到Xcode工程</h6> <ul> <li>将iOS MSSDK的以下framework文件添加进XCode工程: <ol> <li>MSLDShareSDK.framework</li> <li>MSLDWeiBoShare.framework</li> <li>MSLDWeiBoPackage.framework</li> </ol></li> <li>添加方法请参考本文档3.2.1、3.2.2和3.2.3章节。</li> </ul> <h6>4.3.1.3 配置QQ信息到XCode工程</h6> <ul> <li>URL Scheme配置</li> </ul> <p>选择 <strong>TARGETS</strong> –&gt; <strong>Info</strong> –&gt; <strong>URLTypes</strong>,新增一条<strong>URL scheme</strong>,命名为wb+微博AppKey,例如wb233432143 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/b97b7d8756c7b617926704dc00cf6e55?showdoc=.jpg" alt="" /></p> <ul> <li>LSApplicationQueriesSchemes配置</li> </ul> <p>选择 <strong>TARGETS</strong> –&gt; <strong>Info</strong> –&gt; <strong>LSApplicationQueriesSchemes</strong>,添加以下内容:</p> <pre><code class="language-xml">&lt;key&gt;LSApplicationQueriesSchemes&lt;/key&gt; &lt;array&gt; &lt;string&gt;sinaweibohd&lt;/string&gt; &lt;string&gt;sinaweibo&lt;/string&gt; &lt;string&gt;weibosdk&lt;/string&gt; &lt;string&gt;weibosdk2.5&lt;/string&gt; &lt;/array&gt;</code></pre> <ul> <li>分享回调代码:用于获知分享结果。若已添加,则无需理会。</li> </ul> <pre><code class="language-objc">- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { [[MSLDSDK sharedInstance] msld_application:application openURL:url sourceApplication:sourceApplication annotation:annotation]; return YES; } #if __IPHONE_OS_VERSION_MIN_REQUIRED &gt;= __IPHONE_9_0 - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary&lt;UIApplicationOpenURLOptionsKey, id&gt; *)options { [[MSLDSDK sharedInstance] msld_application:app openURL:url options:options]; return YES; } #endif</code></pre> <h6>4.3.1.4 调用微博分享功能</h6> <ul> <li>分享图片到微博:</li> </ul> <pre><code class="language-objc">// 分享图片到微博 - (void)shareImageToWeiBo{ UIImage *image = [UIImage imageNamed:@"bg_launcher"]; NSDictionary *dic = @{ SHARE_SCENE: SHARE_WEIBO, @"image": image, @"text": @"分享的文本内容", }; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_IMAGE param:dic success:^(NSString *msg, id data) { [MSLDLog logDebug:@"分享图片到微博成功! msg=%@", msg]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { [MSLDLog logDebug:@"分享图片到微博失败! code:%ld,msg=%@,errorData=%@", code, msg, errorData]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <ul> <li>分享链接到微博:</li> </ul> <pre><code class="language-objc">- (void)shareWebToWeiBo{ UIImage *image = [UIImage imageNamed:@"image_2"]; NSDictionary *param = @{ SHARE_SCENE: SHARE_WEIBO, @"title": @"分享链接标题", @"description": @"分享链接描述", @"thumbImage": image, @"scheme":@"", @"webpageUrl": @"https://www.idreamsky.com/", @"text": @"分享的文本内容", }; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_SHARE_WEBPAGE param:param success:^(NSString *msg, id data) { [MSLDLog logDebug:@"分享链接到微博成功! msg=%@", msg]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { [MSLDLog logDebug:@"分享链接到微博失败! code:%ld,msg=%@,errorData=%@", code, msg, errorData]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:msg]; }]; }</code></pre> <h4>4.4 上报游戏数据(DLOG SDK)</h4> <ul> <li>MSSDK已集成DLOG SDK数据统计能力,游戏可以上报各项数据,并支持可视化数据报表。</li> <li>数据上报功能依赖于用户功能,必须先接入用户功能才能使用。</li> <li>调用示例:</li> </ul> <pre><code class="language-objc"> // 上报游戏加载时长 [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_DLOG_LOADING_COMPLETED_EVENT param:@{ @"loadingTime": @1211 } success:^(NSString *msg, id data) { NSLog(@"report success!"); } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { NSLog(@"report failed"); }]; // 上报自定义事件 NSMutableDictionary *param = [[NSMutableDictionary alloc] initWithCapacity:1]; [param setObject:@"login" forKey:DLOG_EVENT_ID]; [param setObject:@"captchaLogin" forKey:DLOG_EVENT_PARAM]; [param setObject:@{ @"captchaNumber": @"1111" } forKey:DLOG_EXTEND]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_DLOG_CUSTOM_EVENT param:param success:nil fail:nil];</code></pre> <h4>4.5 用户反馈</h4> <p>目前用户反馈模块,支持问卷调查功能。</p> <h5>4.5.1 问卷调查</h5> <h6>4.5.1.1 问卷星后台配置</h6> <ul> <li>问卷调查功能目前使用<a href="https://www.wjx.cn/">问卷星</a>。开发者首先要在问卷星登录账号,创建问卷。并获取问卷的地址。 <img src="https://github.com/veryitman/MSSDKResource/blob/mark-feature/Unity3D/guide-main/guide_11.png?raw=true" alt="" /></li> <li> <p>创建问卷时,“提交答卷后的处理方式”修改为“跳转到指定网址”,地址<strong>必须</strong>填写为“<a href="http://localhost/survey_finish">http://localhost/survey_finish</a>” 跳转提示文字不做要求. <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/db768ae63be3363feaf980bd8f8aaaf9?showdoc=.jpg" alt="" /></p> </li> <li>“数据推送API”的“HTTP POST地址”<strong>必须</strong>填写为“<a href="https://internal-gw.uu.cc/internal-gateway/ms-gift/sdk_/questionaire/callback">https://internal-gw.uu.cc/internal-gateway/ms-gift/sdk_/questionaire/callback</a>” <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/96a8144e61dac6c4700f73d5c6055f2a?showdoc=.jpg" alt="" /></li> </ul> <h6>4.5.1.2 微服务业务控制台配置</h6> <p>在在线参数配置项中,配置: (1)问卷开关,用于控制整个问卷调查功能是否可用。 (2)问卷地址。这个是4.5.1.1中问卷星上获取的问卷的地址。 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/a05e56a882bd8c01b2ef8fcf2053104b?showdoc=.jpg" alt="" /></p> <h6>4.5.1.3 问卷调查功能是否可用</h6> <p>调用MSLDFeedbackManager 类的方法 public static bool IsQuestionEnabled() 获取当前问卷调查功能是否可用。可用依赖这个值决定是否在游戏相应界面显示问卷调查路况。</p> <pre><code class="language-objc">NSString *isEnabledStr = [[MSLDSDK sharedInstance] syncActionWithLDUrl:ROUTE_QUESTIONNAIRE_ISENABLE param:@{}]; if ([isEnabledStr boolValue]) { [MSLDLog logDebug:@"👍问卷调查功能可用"]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:@"👍问卷调查功能可用"]; } else { [MSLDLog logDebug:@"❌问卷调查功能不可用"]; [UIAlertView msld_showAlertDialogWithTitle:@"提示" msg:@"❌问卷调查功能不可用"]; }</code></pre> <h6>4.5.1.4 展示问卷调查面板</h6> <p>调用接口 <code>ROUTE_QUESTIONNAIRE_OPEN</code> 路由的方法 可展示问卷调查面板。 为调用起问卷星所需要的一些额外信息。如 玩家Id, 服务器Id,角色Id,扩展字段,url等字段。这些信息根据游戏的具体情况填入。</p> <p><strong>这里特别注意</strong>:如果开发者需要自己在特殊场景下弹出不同的问卷内容,可以通过传入 <code>url</code> 值来进行控制,但是如果客户端传入了此值,问卷调查将优先使用传入的值作为问卷地址展示给用户。如果此值为空,则使用后台配置的默认问卷地址。 <strong>如果想使用 <code>url</code> 字段,需要升级MSSDK到1.4.2版本。</strong></p> <p>另外,问卷星支持客户端通知开发者客户端,也支持MSSDK服务端通知开发者服务端,具体可以参考 <a href="https://www.showdoc.cc/mssdk?page_id=3169583440854192">问卷星服务端接入</a> 文档。</p> <pre><code class="language-objc">MSLDAccount *account = [[MSLDSDK sharedInstance] syncActionWithLDUrl:ROUTE_ACCOUNT_LOGINED_USER_INFO param:nil]; NSDictionary * param = @{ @"level": @"98", @"accruingAmounts": @"1998", @"consecutiveDays": @"99", @"serverId": @"1232", @"roleId": @"4563", @"playerId": account.playerId == nil ? @"" : account.playerId, @"extra": @"ex3t332", @"url":@"http://abc.wjx.com" //此值为空,则使用后台配置的默认问卷地址,不为空以此地址为主打开问卷内容。 }; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_QUESTIONNAIRE_OPEN param:param success:^(NSString *msg, id data) { // 展示面板成功 } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { if (MSLDErrorCodeUIUserClose == code) { // 用户取消了 } else { // 失败 } }];</code></pre> <h4>4.6 广告跟踪</h4> <p>MSSDK集成了广告跟踪相关的功能。 广告跟踪要求接入方在相应的业务逻辑部分,调用相应的接口。</p> <h5>4.6.1 登录成功后,请调用ROUTE_ADTRACK_LOGIN 上报登录信息</h5> <pre><code class="language-objc">NSString *playerId = [[MSLDSDK sharedInstance] syncActionWithLDUrl:ROUTE_ACCOUNT_LOGINED_USER_PLAYER_ID param:nil]; NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithCapacity:1]; if (!IS_NS_STRING_EMPTY(playerId)) { [params msld_setObject:playerId forKey:@"playerId"]; } [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ADTRACK_LOGIN param:params success:^(NSString *msg, id data) { // 登录上报成功 } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 登录上报失败 }];</code></pre> <h5>4.6.2 购买成功后,请调用 ROUTE_ADTRACK_PURCHASE 上报购买相关信息</h5> <pre><code class="language-objc">NSString *playerId = [[MSLDSDK sharedInstance] syncActionWithLDUrl:ROUTE_ACCOUNT_LOGINED_USER_PLAYER_ID param:nil]; NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithCapacity:1]; if (!IS_NS_STRING_EMPTY(playerId)) { [params msld_setObject:playerId forKey:@"playerId"]; } [params msld_setObject:@"1" forKey:@"amount"]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ADTRACK_PURCHASE param:params success:^(NSString *msg, id data) { // 消费上报成功 } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 消费上报失败 }];</code></pre> <h5>4.6.3 点击广告成功后,请调用 ROUTE_ADTRACK_ADCLICK 上报相关信息</h5> <pre><code class="language-objc"> NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithCapacity:2]; // 腾讯腾讯优良汇平台广告 [params msld_setObject:@"1" forKey:@"platformType"]; // 广告形式为插页广告 [params msld_setObject:@"2" forKey:@"displayType"]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ADTRACK_ADCLICK param:params success:^(NSString *msg, id data) { // 广告点击事件上报上报成功 } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 广告点击事件上报上报失败 }];</code></pre> <h5>4.6.4 调用 ROUTE_ADTRACK_CUSTOM 上报自定义信息</h5> <pre><code class="language-objc"> NSString *playerId = [[MSLDSDK sharedInstance] syncActionWithLDUrl:ROUTE_ACCOUNT_LOGINED_USER_PLAYER_ID param:nil]; NSMutableDictionary *params = [[NSMutableDictionary alloc] initWithCapacity:2]; NSMutableDictionary *customData = [[NSMutableDictionary alloc] initWithCapacity:2]; if (!IS_NS_STRING_EMPTY(playerId)) { [customData msld_setObject:playerId forKey:@"playerId"]; } [customData msld_setObject:@"1" forKey:@"logout"]; NSString *eventName = @"logout"; [params msld_setObject:eventName forKey:@"eventName"]; [params msld_setObject:customData forKey:@"customData"]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_ADTRACK_CUSTOM param:params success:^(NSString *msg, id data) { // 自定义上报成功 } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // 自定义上报失败 }];</code></pre> <h4>4.7 buggly集成</h4> <p>把在buggly开发者后台申请的app id,填入到 <code>msConfig.json</code> 中后,MSSDK将自动启动buggly。 在msConfig.json文件中相应的key为 <code>bugly_app_id</code>。</p> <h4>4.8 LBS集成</h4> <h5>4.8.1 获取高德的appKey</h5> <p>请到<a href="https://lbs.amap.com/">高德开放平台</a> 创建应用,并获得高德的appKey。 并将appKey配置到“msConfig.json”文件中,配置键名为“amap_key”。 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/22e4c74d38649e7e664c48d6cc59f63d?showdoc=.jpg" alt="" /></p> <h5>4.8.2 配置LBS权限</h5> <p>由于需要用到获取地理位置信息,需要得到用户的授权,在XCode工程中配置 NSLocationWhenInUseUsageDescription, NSLocationAlwaysUsageDescription, NSLocationAlwaysAndWhenInUseUsageDescription 。</p> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/e5278a392d7dfed4a8920f6f98300b1d?showdoc=.jpg" alt="" /></p> <h5>4.8.3 调用 ROUTE_LBS_REQUEST_LOCATION_PERMISSIONS 接口,向系统申请权限</h5> <p>从1.9.0之后,获取位置信息权限的动作由CP方主动调用申请。SDK不再在内部申请。从而让权限申请的系统弹框在业务需要的时候触发。因此,CP在做业务之前,需要先先调用这个接口。否则业务将失败。并返回没有权限的错误码。</p> <p>NSDictionary <em> param = [self.actionParams objectForKey:@(1)]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_LBS_REQUEST_LOCATION_PERMISSIONS param:param success:^(NSString </em>msg, id data) { [MSLDLog logDebug:@&quot;获取授权成功! msg:%@, auth:[%@]&quot;, msg,data]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { [MSLDLog logDebug:@&quot;获取授权失败! msg:%@, auth:[%@]&quot;, msg,errorData]; }];</p> <h5>4.8.4 调用ROUTE_LBS_SEARCHNEARBY接口,获取周围玩家</h5> <p>此接口需要在登录之后调用。</p> <blockquote> <p>注意: 1. 附近的人记录限制100条; 2. 默认缓存时间10分钟</p> </blockquote> <pre><code> NSDictionary * param = @{ @"pageIndex": pageIndex == nil?@"":pageIndex, // 页索引 @"pageSize": pageSize == nil?@"":pageSize,// 页大小 @"sort": sort == nil?@"":sort,// 距离排序:desc由近及远/asc有远及近搜索 @"radius": radius == nil?@"":radius, // 半径,单位为KM 搜索半径过大会影响服务端的性能,最好控制在100KM以内 }; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_LBS_SEARCHNEARBY param:param success:^(NSString *msg, id data) { // [MSLDLog logDebug:@"附近的玩家: %@", data]; //返回为json格式的字符串 } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { // NSString *logStr = [NSString stringWithFormat:@"获取附近的玩家失败!code = %ld, msg = %@, data = %@", (long)code, msg, errorData]; [MSLDLog logDebug:@"%@", logStr]; }]; </code></pre> <h5>4.8.5 调用 ROUTE_LBS_CURRENT_LOCATION,获取当前位置的信息。如果没有位置信息权限,将会返回MSLDErrorCodeLBSDenied 错误码。 正常获取到位置权限后,data实际为 MSLDLocation 对象。MSLDLocation结构详见API文档。</h5> <pre><code> [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_LBS_CURRENT_LOCATION param:nil success:^(NSString *msg, id data) { [MSLDLog logDebug:@"获取位置成功! msg:%@, location:[%@]", msg,data]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { [MSLDLog logDebug:@"获取位置失败! msg:%@, errorData:%@", msg,errorData]; }]; </code></pre> <h4>4.9 推送</h4> <p>推送的接入,请参考<a href="https://www.showdoc.cc/mssdk?page_id=3750735621349219">Push集成文档</a> .</p> <h4>4.10 兑换码</h4> <p>MSSDK集成了兑换码相关的功能。此功能使用的是原有兑换码相关的服务。因此需要使用到 <a href="http://dev.idreamsky.com">DEV</a> 后台等相关的服务。 基本的设计思路是,MSSDK请求微服务后台,微服务后台转发请求到DGC的服务,校验兑换码。 1.到DEV后台配置相关的内容。 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/7cb69cc09242a0f2619c3cb23c7b1f0e?showdoc=.jpg" alt="" /></p> <p>2.调用接口,展示UI让玩家输入验证码,请求验证兑换码(此接口登录之后调用才有效)</p> <pre><code class="language-objc"> [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_REDEEM_SHOW_REDEEM_CODE param:nil success:^(NSString *msg, id data) { NSString *infoStr = [NSString stringWithFormat:@"兑换成功! msg:%@, productId:[%@]", msg,data]; [MSLDLog logDebug:infoStr]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { NSString *infoStr = [NSString stringWithFormat:@"兑换失败! msg:%@, errorData:%@", msg,errorData]; [MSLDLog logDebug:infoStr]; }];</code></pre> <p>3.如果对UI不满意,可以自己实现UI,并调用数据接口请求验证兑换码(此接口登录之后调用才有效)</p> <pre><code class="language-objc">NSMutableDictionary * params = [NSMutableDictionary dictionary]; [params setObject:redeemCode forKey:@"redeemCode"]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_REDEEM_NOUI_REDEEM_CODE param:params success:^(NSString *msg, id data) { NSString *infoStr = [NSString stringWithFormat:@"兑换成功! msg:%@, productId:[%@]", msg,data]; [MSLDLog logDebug:infoStr]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { NSString *infoStr = [NSString stringWithFormat:@"兑换失败! msg:%@, errorData:%@", msg,errorData]; [MSLDLog logDebug:infoStr]; }];</code></pre> <h4>4.11 直播</h4> <p>用户可以使用直播功能,在游戏界面中展示和游戏相关的直播。</p> <h4>4.11.1 在微服务后台配置相应的直播平台</h4> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/dedbfddd0148ef0e82e608394fb3be5a?showdoc=.jpg" alt="" /></p> <p>并在在线参数中,打开相应的开关</p> <p><img src="https://www.showdoc.cc/server/api/common/visitfile/sign/e7823ff0e2323ff0951c0585f6d4b679?showdoc=.jpg" alt="" /></p> <p>需要跟多的帮助,请联系中台。</p> <h4>4.11.2 前端查看直播开关是否开启</h4> <p>在MSConfig对象中,有个属性表示直播开关是否打开。可以调用接口获取。 集成时,如果此开关为关闭,则不要绘制UI入口。否则,打开的直播页面也是不可用的。</p> <pre><code>-(void)isLiveEnable { MSLDConfig *config = [[MSLDSDK sharedInstance] syncActionWithLDUrl:ROUTE_SDK_CONFIG param:nil]; if (config.isLiveEnable) { [UIAlertView msld_showAlertDialogWithTitle:@"在线开关" msg:@"可用"]; }else{ [UIAlertView msld_showAlertDialogWithTitle:@"在线开关" msg:@"不可用"]; } }</code></pre> <h4>4.11.3 展示直播界面</h4> <p>调用 ROUTE_LIVE_START_LIVE_WEB 接口,可以展示直播页面。 注意:</p> <ul> <li>目前直播页面只支持横屏适配。</li> <li>如果后台关闭了,将会返回MSLDErrorCodeCommonDisabled的错误码。</li> </ul> <pre><code>-(void)showLiveWeb { [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_LIVE_START_LIVE_WEB param:nil success:^(NSString *msg, id data) { NSString *infoStr = [NSString stringWithFormat:@"成功! msg:%@, data:[%@]", msg,data]; [MSLDLog logDebug:infoStr]; [UIAlertView msld_showAlertDialogWithTitle:@"成功" msg:infoStr]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { if (code == MSLDErrorCodeUIUserClose) { NSString *infoStr = [NSString stringWithFormat:@"用户关闭! msg:%@, errorData:%@", msg,errorData]; [MSLDLog logDebug:infoStr]; [UIAlertView msld_showAlertDialogWithTitle:@"用户关闭" msg:infoStr]; }else if (code == MSLDErrorCodeCommonDisabled){ NSString *infoStr = [NSString stringWithFormat:@"功能关闭! msg:%@, errorData:%@", msg,errorData]; [MSLDLog logDebug:infoStr]; [UIAlertView msld_showAlertDialogWithTitle:@"功能关闭" msg:infoStr]; }else{ NSString *infoStr = [NSString stringWithFormat:@"失败! msg:%@, errorData:%@", msg,errorData]; [MSLDLog logDebug:infoStr]; [UIAlertView msld_showAlertDialogWithTitle:@"失败" msg:infoStr]; } }]; } </code></pre> <h4>4.12 好友关系链</h4> <h5>4.12.1 配置通信录权限</h5> <p>由于需要获取通信录信息,需要得到用户的授权,在XCode工程中配置 Privacy - Contacts Usage Description 。 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/9bad8210348f41fd966aee70b0b8db78?showdoc=.jpg" alt="" /></p> <h5>4.12.2 获取通讯录权限(拒绝后下次无提示弹窗)</h5> <pre><code> NSMutableDictionary *dic = [NSMutableDictionary new]; [dic setValue:@"0" forKey:@"IS_SHOW_CONFIRM_DIALOG"]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_CONTACT_PERMISSIONS param:dic success:^(NSString *msg, id data) { NSString *logStr = [NSString stringWithFormat:@"获取通讯录权限成功: msg = %@, data = %@", msg, data]; [MSLDLog logDebug:@"%@", logStr]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { NSString *logStr = [NSString stringWithFormat:@"获取通讯录权限失败: msg = %@, data = %@", msg, errorData]; [MSLDLog logDebug:@"%@", logStr]; }];</code></pre> <h5>4.12.3 获取通讯录权限(拒绝后下次有提示弹窗)</h5> <pre><code> NSMutableDictionary *dic = [NSMutableDictionary new]; [dic setValue:@"1" forKey:@"IS_SHOW_CONFIRM_DIALOG"]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_CONTACT_PERMISSIONS param:dic success:^(NSString *msg, id data) { NSString *logStr = [NSString stringWithFormat:@"获取通讯录权限成功: msg = %@, data = %@", msg, data]; [MSLDLog logDebug:@"%@", logStr]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { NSString *logStr = [NSString stringWithFormat:@"获取通讯录权限失败: msg = %@, data = %@", msg, errorData]; [MSLDLog logDebug:@"%@", logStr]; }];</code></pre> <h5>4.12.4 获取关系链平台级联系人列表</h5> <pre><code> NSMutableDictionary *dic = [NSMutableDictionary new]; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_CONTACT_PLATFORM_FRIENDLIST param:dic success:^(NSString *msg, id data) { NSString *logStr = [NSString stringWithFormat:@"关系链平台级联系人列表成功: msg = %@, data = %@", msg, data]; [MSLDLog logDebug:@"%@", logStr]; [ContactsPlatformListView isShowContactsPlatformListViewWithData:data]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { NSString *logStr = [NSString stringWithFormat:@"获取关系链平台级联系人列表失败: msg = %@, data = %@", msg, errorData]; [MSLDLog logDebug:@"%@", logStr]; }];</code></pre> <h4>4.13 Openinstall</h4> <h5>4.13.1 申请Openinstall的key</h5> <p>注册并登录<a href="https://www.openinstall.io/">Openinstall网站</a>,创建OpenInstall应用内。创建之后,可以获得应用的的Appkey。 Openinstall的免费版本功能较少,一下功能均基于付费版本。具体请联系业务BP。</p> <h5>4.13.2 配置Openinstall</h5> <h6>4.13.2.1 把申请的Openinstall的Appkey填入到msConfig.json中。</h6> <p>在msConfig中的key为<code>openinstall_key</code>。 <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/d4c5d4ca8515437b158179eddc634dcf?showdoc=.jpg" alt="" /></p> <h6>4.13.2.2 在info.plist中添加 com.openinstall.APP_KEY</h6> <p>在Info.plist文件中配置appKey键值对,如下:</p> <pre><code>&lt;key&gt;com.openinstall.APP_KEY&lt;/key&gt; &lt;string&gt;YouOpeninstallKey&lt;/string&gt;</code></pre> <p>如: <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/c61d8f04628e10dfbe66917d329e6100?showdoc=.jpg" alt="" /></p> <h6>4.13.2.3 添加Associated Domains和Scheme</h6> <p>在XCode中配置openinstall为当前应用生成的关联域名(Associated Domains):</p> <pre><code>applinks:YouOpeninstallKey.openinstall.io</code></pre> <p>如图: <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/1fd95ff0360299516946e8e858dd3abe?showdoc=.jpg" alt="" /> 增加OpenInstall的scheme: <img src="https://www.showdoc.cc/server/api/common/visitfile/sign/8e350976ed0cbac03bc7814042cdd7b2?showdoc=.jpg" alt="" /></p> <h6>4.13.2.4 在系统回调中调用统一处理方法</h6> <p>如果以前接入过相应的接口,则可以不用重复添加该回调入口。否则要添加。</p> <pre><code>-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray&lt;id&lt;UIUserActivityRestoring&gt;&gt; * _Nullable))restorationHandler{ [MSLDLog logDebug:@"msld continueUserActivity"]; return [[MSLDSDK sharedInstance] msld_application:application continueUserActivity:userActivity restorationHandler:restorationHandler]; }</code></pre> <pre><code>- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary&lt;UIApplicationOpenURLOptionsKey, id&gt; *)options { [[MSLDSDK sharedInstance] msld_application:app openURL:url options:options]; return YES; }</code></pre> <h6>4.13.2.5 添加全局回调处理</h6> <p>在从落地页点击打开应用时,会收到Openinstall,带着落地页的参数进来。游戏可以处理该数据,进入游戏的相应业务。</p> <pre><code>- (void)onMSLDSDKEvent:(MSLDSDKGlobalEvent)eventID msg:(NSString *)msg data:(id)data { [MSLDLog logDebug:@"MSLDSDK onMSLDSDKEvent begin eventId=%d",eventID]; if (MSLDSDKSwitchAccount == eventID) { // ...... }else if(MSLDSDKOpeninstallDataReceived == eventID){ // 在这里收到全局回调,数据类型为 MSLDOpenInstallData MSLDOpenInstallData *msg = (MSLDOpenInstallData *)data; [MSLDLog logDebug:@"MSLDSDK onMSLDSDKEvent MSLDOpeninstallDataReceived msg=%@", msg]; }else if ...... } </code></pre> <h6>4.13.3 功能使用</h6> <h6>4.13.3.1 获取安装参数</h6> <p>默认超时时间为8s。</p> <pre><code>[[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_OPENINSTALL_GET_INSTALL_PARMS param:nil success:^(NSString *msg, id data) { NSString *infoStr = [NSString stringWithFormat:@"获取OpenInstall参数成功! msg:%@, data:[%@]", msg,data]; [MSLDLog logDebug:infoStr]; } fail:^(MSLDErrorCode code, NSString *msg, id errorData) { NSString *infoStr = [NSString stringWithFormat:@"获取OpenInstall参数失败! msg:%@, errorData:%@", msg,errorData]; [MSLDLog logDebug:infoStr]; }];</code></pre> <h6>4.13.3.2 上报数据</h6> <p>建议游戏在自己的业务逻辑中调用这些接口,这样可以在Openinstall后台看到相应的统计。</p> <p>上报注册数据</p> <pre><code class="language-objc"> [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_OPENINSTALL_REPORT_REGISTER param:nil success:nil fail:nil]; </code></pre> <p>上报效果点数据 调用接口前,现在后台创建相应的效果点。前后端匹配。</p> <pre><code class="language-objc"> NSDictionary * param = @{@"effectID":@"effect_test",@"effectValue":@(1)}; [[MSLDSDK sharedInstance] actionWithLDUrl:ROUTE_OPENINSTALL_REPORT_EFFECT_POINT param:param success:nil fail:nil]; </code></pre>

页面列表

ITEM_HTML