客户端与前端交互文档
<p>[TOC]</p>
<h3>1、打开登录页面</h3>
<p>地址参数
?action=login&app_id=123&platform=android</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>action</td>
<td>登录为 login</td>
</tr>
<tr>
<td>game</td>
<td>SDK参数</td>
</tr>
<tr>
<td>platform</td>
<td>平台 ios 或者 android</td>
</tr>
<tr>
<td>ts</td>
<td>时间戳 1730959613</td>
</tr>
<tr>
<td>device_type</td>
<td>设备类型,默认phone,平板为pad</td>
</tr>
<tr>
<td>language</td>
<td>客户端系统语言 英语 en-us,香港繁体 zh-hk,澳门繁体 zh-mo,台湾繁体zh-tw,默认值 简体中文 zh-cn</td>
</tr>
<tr>
<td>package_name</td>
<td>包名</td>
</tr>
<tr>
<td>sub_chl</td>
<td>分包标识</td>
</tr>
<tr>
<td>channel</td>
<td>渠道</td>
</tr>
<tr>
<td>tmp_uid</td>
<td>游客登录临时标识,会优先用广告ID、安卓ID/NSID 进行 MD5</td>
</tr>
<tr>
<td>orientation</td>
<td>横屏 2 ,竖屏 1</td>
</tr>
<tr>
<td>version_name</td>
<td>version_name</td>
</tr>
<tr>
<td>version_code</td>
<td>version_code</td>
</tr>
</tbody>
</table>
<p>其他待定参数说明</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>android_id</td>
<td>平台为<code>安卓</code>的时有,安卓ID ,客户端获取方法 Settings.Secure.getString(getContentResolver(), Settings.Secure.ANDROID_ID)</td>
</tr>
<tr>
<td>idfv</td>
<td>平台为<code>苹果</code>时有,相当于安卓ID, 但是只能是同一开发者下不同应用内获取才一致 ,客户端获取方法 [[[UIDevice currentDevice] identifierForVendor] UUIDString]</td>
</tr>
<tr>
<td>adid</td>
<td>平台为<code>安卓</code>时有,谷歌广告ID (可能为空,需设备支持谷歌框架),客户端获取方法 AdvertisingIdClient.getAdvertisingIdInfo</td>
</tr>
<tr>
<td>fbid</td>
<td>平台为<code>安卓、苹果</code>时有,firebase安装ID(可能为空,需设备支持谷歌框架),客户端获取方法 FirebaseInstallations.getInstance().getId()和let installations = Installations.installations() installations.installationID</td>
</tr>
<tr>
<td>idfa</td>
<td>平台为<code>苹果</code>时有,苹果广告ID(可能为空,需授权),客户端获取方法 [[[ASIdentifierManager sharedManager] advertisingIdentifier]UUIDString];</td>
</tr>
<tr>
<td>afid</td>
<td>平台为<code>安卓、苹果</code>时有,appsflyer SDK生成 AppsFlyerLib.getInstance().getAppsFlyerUID / [[AppsFlyerLib shared] getAppsFlyerUID];</td>
</tr>
</tbody>
</table>
<h3>2、第二次打开快速登录页面(其他参数同1)</h3>
<p>地址参数
?action=quick_login</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>action</td>
<td>快速登录为 quick_login</td>
</tr>
</tbody>
</table>
<h3>3、前端调用第三方登录/绑定</h3>
<p>点击facebook和Google登录/绑定</p>
<p>安卓暴露方法 facebookLogin
前端代码(应该是) </p>
<pre><code class="language-javascript">window.android.facebookLogin &amp;&amp; window.android.facebookLogin(&quot;login&quot;);//登录
window.android.facebookLogin &amp;&amp; window.android.facebookLogin(&quot;bind&quot;);//绑定</code></pre>
<p>安卓暴露方法 googleLogin
前端代码(应该是) </p>
<pre><code class="language-javascript">window.android.googleLogin &amp;&amp; window.android.googleLogin(&quot;login&quot;);//登录
window.android.googleLogin &amp;&amp; window.android.googleLogin(&quot;bind&quot;);//绑定</code></pre>
<p>iOS调用方法 <code>iosWebView</code> 为客户端监听的方法</p>
<pre><code class="language-javascript">window.webkit.messageHandlers.iosWebView.postMessage({
method: &quot;facebookLogin&quot;, //登录facebookLogin 绑定 facebookBind
params: &quot;&quot;,
});</code></pre>
<pre><code class="language-javascript">window.webkit.messageHandlers.iosWebView.postMessage({
method: &quot;googleLogin&quot;, //登录googleLogin 绑定 googleBind
params: &quot;&quot;,
});</code></pre>
<h3>4、客户端第三方登录完成后返回给前端</h3>
<p>方法名 login_suc</p>
<p>json = {"loginType":"google","third_uid":"123123","third_token":"xxxxx","user_name":"","action":"login"}</p>
<p>webView.evaluateJavascript("javascript:login_suc('" + json + "');", null);</p>
<p>wkWebView.evaluateJavaScript("login_suc('(json)')")</p>
<h4>json 参数格式</h4>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>loginType</td>
<td>第三方登录类型 facebook、google、apple</td>
</tr>
<tr>
<td>action</td>
<td>login/bind 登录还是绑定</td>
</tr>
<tr>
<td>third_uid</td>
<td>第三方登录返回uid</td>
</tr>
<tr>
<td>third_token</td>
<td>第三方登录返回token</td>
</tr>
<tr>
<td>user_name</td>
<td>第三方登录返回昵称(可能为空)</td>
</tr>
</tbody>
</table>
<h3>5、前端登录成功之后返回登录信息给客户端</h3>
<h4>json 参数格式(待定)</h4>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>uid</td>
<td>服务端登录返回</td>
</tr>
<tr>
<td>token</td>
<td>服务端登录返回</td>
</tr>
</tbody>
</table>
<p>安卓暴露方法 loginSuccess
前端代码(应该是) </p>
<pre><code class="language-javascript">window.android.loginSuccess(json);</code></pre>
<p>iOS调用方法 <code>iosWebView</code> 为客户端监听的方法</p>
<pre><code class="language-javascript">window.webkit.messageHandlers.iosWebView.postMessage({
method: &quot;loginSuccess&quot;,
params: json,
});</code></pre>
<h3>6、前端通知客户端用户默认语言切换</h3>
<p>客户端系统语言 英语 en-us,香港繁体 zh-hk,澳门繁体 zh-mo,台湾繁体zh-tw,默认值 简体中文 zh-cn</p>
<p>安卓暴露方法 change_language
前端代码(应该是) </p>
<pre><code class="language-javascript">window.android.change_language &amp;&amp; window.android.change_language(&quot;en-us&quot;);</code></pre>
<p>iOS调用方法 <code>iosWebView</code> 为客户端监听的方法</p>
<pre><code class="language-javascript">window.webkit.messageHandlers.iosWebView.postMessage({
method: &quot;change_language&quot;,
params: &quot;en-us&quot;,
});</code></pre>
<p>调用通知后,下次调用打开登录页面时 ,第一点 ,language 参数会对应变化,不再受到手机系统语言切换</p>
<h3>7、前端通知客户端关闭页面</h3>
<p>安卓暴露方法 page_finish
前端代码(应该是) </p>
<pre><code class="language-javascript">window.android.page_finish &amp;&amp; window.android.page_finish();</code></pre>
<p>iOS调用方法 <code>iosWebView</code> 为客户端监听的方法</p>
<pre><code class="language-javascript">window.webkit.messageHandlers.iosWebView.postMessage({
method: &quot;page_finish&quot;,
params: &quot;&quot;,
});</code></pre>
<h3>8、打开切换账号页面(其他参数同1)</h3>
<p>地址参数
?action=change_account</p>
<table>
<thead>
<tr>
<th>参数</th>
<th>说明</th>
</tr>
</thead>
<tbody>
<tr>
<td>action</td>
<td>切换账号页面 为 change_account</td>
</tr>
</tbody>
</table>
<h3>9、获取全部历史登录信息</h3>
<p>安卓暴露方法 get_all_login
前端代码(应该是) </p>
<pre><code class="language-javascript">window.android.page_finish &amp;&amp; window.android.get_all_login();</code></pre>
<p>iOS调用方法 <code>iosWebView</code> 为客户端监听的方法</p>
<pre><code class="language-javascript">window.webkit.messageHandlers.iosWebView.postMessage({
method: &quot;get_all_login&quot;,
params: &quot;&quot;,
});</code></pre>
<pre><code class="language-json">返回json格式字符串
last_login_type 是最后登录成功的方式
其他key为该登录方式成功的信息
{
&quot;visitor&quot;: &quot;{\&quot;code\&quot;:1,\&quot;msg\&quot;:\&quot;success\&quot;,\&quot;d\&quot;:{\&quot;account_name\&quot;:\&quot;vit_000520000008\&quot;,\&quot;account_type\&quot;:0,\&quot;loginType\&quot;:\&quot;visitor\&quot;,\&quot;game\&quot;:\&quot;game_test_gg_1\&quot;,\&quot;uid\&quot;:\&quot;6_5_3\&quot;,\&quot;isNew\&quot;:0,\&quot;token\&quot;:\&quot;GR8WGBQzCitHtHvgWDHK2E43RnY0d21oMFdvT1hMNUlxUkhuRVdmdnNGMGlKSjVxQ0E5b2hLMzdyQVhQWkVIOFF1MkZackcraGFsZC9jVDJ1KzA1NStVSnNTWm9FdHVmK1NmZ2NIMytCSVlLQkdLNDZzZ05tam5WVjk5UC9odnZ2NDVFU2wwVUdaVE1XUnhiMHNkb01xZVJPK3cyVGw4eUM1anN1QT09\&quot;,\&quot;account\&quot;:\&quot;vit_000520000008\&quot;,\&quot;password\&quot;:\&quot;61be2160f2b518e7194d7c1efa64045b\&quot;,\&quot;account_state\&quot;:0},\&quot;ec\&quot;:false}&quot;,
&quot;last_login_type&quot;: &quot;visitor&quot;,
&quot;email&quot;: &quot;{\&quot;code\&quot;:1,\&quot;msg\&quot;:\&quot;success\&quot;,\&quot;d\&quot;:{\&quot;account_name\&quot;:\&quot;qqww@qq.com\&quot;,\&quot;account_type\&quot;:1,\&quot;loginType\&quot;:\&quot;email\&quot;,\&quot;game\&quot;:\&quot;game_test_gg_1\&quot;,\&quot;uid\&quot;:\&quot;7_5_3\&quot;,\&quot;isNew\&quot;:1,\&quot;token\&quot;:\&quot;v6a2EwDzqGGpu04sY7ZfMFFYNVVqNTQ3U2hlRFZ6OG82ZWcyazh3blVrVyt4RFFyZ2ozUStmbmQ0NmcxN1lVQTRYRGdCQVJ5QmtINW9CM1QzUVM2cStkQVhKS3NnWmt5M3ZqTVRyR0krWDF4WFcvV2VqMm1NZVdKY2xVZEFSOFNtWDBMWHpqMWJxY0puTmp2SGFHWlV3dllYVS9kTHZoZ1cxS2ozUT09\&quot;,\&quot;account\&quot;:\&quot;em_000520000009\&quot;,\&quot;password\&quot;:\&quot;3e1d10a4c8c45d4b87587c3097a4bc60\&quot;,\&quot;account_state\&quot;:0},\&quot;ec\&quot;:false}&quot;
}</code></pre>