iOS SDK 对接文档

iOS SDK 对接文档


用户登出

<h1>用户登出</h1> <p>直接使用BSSDKUI对应的类方法调用登出接口。 调用者需要传入对应的回调函数以处理API返回的结果。 当用户成功登出后,在界面上的悬浮球会消失。</p> <h2>接口定义</h2> <p>Swift</p> <pre><code>extension BSSDKUI { static func signOut(appID: String, clientID: String, clientKey: String, success: @escaping SignOutSuccessHandler, failure: @escaping FailureHandler) }</code></pre> <p>Objective-C</p> <pre><code>@interface BSSDKUI + (void)signOutWithAppID:(NSString * _Nonnull)appID clientID:(NSString * _Nonnull)clientID clientKey:(NSString * _Nonnull)clientKey success:(void (^ _Nonnull)(NSString * _Nonnull))success failure:(void (^ _Nonnull)(BSSDKUIError * _Nonnull))failure; @end</code></pre> <h2>接口参数说明</h2> <table> <thead> <tr> <th>参数名</th> <th>类型</th> <th>参数说明</th> </tr> </thead> <tbody> <tr> <td>appID</td> <td>String</td> <td>游戏App 的 ID</td> </tr> <tr> <td>clientID</td> <td>String</td> <td>客户ID</td> </tr> <tr> <td>clientKey</td> <td>String</td> <td>客户密钥</td> </tr> <tr> <td>success</td> <td>SignOutSuccessHandler</td> <td>登录接口的成功回调</td> </tr> <tr> <td>failure</td> <td>FailureHandler</td> <td>登录接口的失败回调</td> </tr> </tbody> </table> <h2>接口回调说明</h2> <p>● 登录成功回调方法中参数说明: <strong>Swift</strong></p> <pre><code>public typealias SignOutSuccessHandler = (String) -&amp;gt; Void</code></pre> <table> <thead> <tr> <th>回调参数说明:</th> <th>参数名</th> <th>类型</th> <th>参数说明</th> </tr> </thead> <tbody> <tr> <td>memberID</td> <td>string</td> <td>登出成功后,用户的mem_id</td> </tr> </tbody> </table> <p>● 登录失败回调方法中参数说明: <strong>Swift</strong></p> <pre><code>@objc public final class BSSDKUIError: NSObject, Error { @objc public let code: Int @objc public let message: String }</code></pre> <p><strong>Objective-C</strong></p> <pre><code>@interface BSSDKUIError : NSObject @property (nonatomic, readonly) NSInteger code; @property (nonatomic, readonly, copy) NSString * _Nonnull message; @end</code></pre> <table> <thead> <tr> <th>该方法在产生业务逻辑错误时调用。</th> <th>参数名</th> <th>类型</th> <th>参数说明</th> </tr> </thead> <tbody> <tr> <td>code</td> <td>string</td> <td>登录失败错误码</td> </tr> <tr> <td>msg</td> <td>string</td> <td>登录失败的消息提示</td> </tr> </tbody> </table> <h2>调用完整代码</h2> <p><strong>Swift</strong></p> <pre><code>BSSDKUI.signOut(appID: &amp;quot;your_app_id&amp;quot;, clientID: &amp;quot;your_client_id&amp;quot;, clientKey: &amp;quot;your_client_key&amp;quot;, success: { print(&amp;quot;Sign out success:\($0)&amp;quot;)}, failure: { print(&amp;quot;Sign out Failed: \($0)&amp;quot;)})</code></pre> <p><strong>Objective-C</strong></p> <pre><code>[BSSDKUI signOutWithAppID:@&amp;quot;your_app_id&amp;quot; clientID:@&amp;quot;your_client_id&amp;quot; clientKey:@&amp;quot;your_client_key&amp;quot; success:^(NSString * _Nonnull memberID) { NSLog(@&amp;quot;Sign out success: %@&amp;quot;, memberID); } failure:^(BSSDKUIError * _Nonnull error) { NSLog(@&amp;quot;Sign out Failed: %@&amp;quot;, error); }];</code></pre>

页面列表

ITEM_HTML