【sdk登录】新增两个参数extData 和 p_appId 草花渠道使用
parent
9681a00816
commit
c2961f8f2d
|
@ -1935,3 +1935,13 @@ end
|
||||||
function GetPlayerRoleSingleConFig()
|
function GetPlayerRoleSingleConFig()
|
||||||
return ConfigManager.GetConfigDataByKey(ConfigName.PlayerRole,"Role",0)
|
return ConfigManager.GetConfigDataByKey(ConfigName.PlayerRole,"Role",0)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- 网络url转码
|
||||||
|
function decodeURI(s)
|
||||||
|
s = string.gsub(s, '%%(%x%x)', function(h) return string.char(tonumber(h, 16)) end)
|
||||||
|
return s
|
||||||
|
end
|
||||||
|
function encodeURI(s)
|
||||||
|
s = string.gsub(s, "([^%w%.%- ])", function(c) return string.format("%%%02X", string.byte(c)) end)
|
||||||
|
return string.gsub(s, " ", "+")
|
||||||
|
end
|
|
@ -42,11 +42,58 @@ function this.Initialize()
|
||||||
this.SdkLoginTimeStamp = result[3]
|
this.SdkLoginTimeStamp = result[3]
|
||||||
AppConst.TokenStr = result[4]
|
AppConst.TokenStr = result[4]
|
||||||
AppConst.SdkChannel = result[5]
|
AppConst.SdkChannel = result[5]
|
||||||
|
this.extData = result[6]
|
||||||
|
this.p_appId = result[7]
|
||||||
AppConst.SdkPackageName = AndroidDeviceInfo.Instance:GetPackageName()
|
AppConst.SdkPackageName = AndroidDeviceInfo.Instance:GetPackageName()
|
||||||
end
|
end
|
||||||
-- 判断是否是注册并登录
|
-- 判断是否是注册并登录
|
||||||
if this.isRegister then
|
if this.isRegister then
|
||||||
this.isRegister = false
|
this.isRegister = false
|
||||||
|
-- 触发创建账户的事件
|
||||||
|
this.TrackCreateAccount()
|
||||||
|
-- 发送登录成功事件
|
||||||
|
Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess,result[1])
|
||||||
|
else
|
||||||
|
this.CheckIsRegister(AppConst.OpenId, function(isRegister)
|
||||||
|
if isRegister then
|
||||||
|
-- 触发创建账户的事件
|
||||||
|
this.TrackCreateAccount()
|
||||||
|
-- 发送登录成功事件
|
||||||
|
Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess,result[1])
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
SDKMgr.onSwitchAccountCallback = function(resp)
|
||||||
|
Log("onSwitchAccountCallback::"..resp)
|
||||||
|
local result = string.split(resp, "#")
|
||||||
|
if tonumber(result[1]) == SDK_RESULT.SUCCESS then
|
||||||
|
ThinkingAnalyticsManager.Track("change_account")
|
||||||
|
Game.Restart()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
SDKMgr.onLogoutCallback = function(resp)
|
||||||
|
Log("onLogoutCallback::"..resp)
|
||||||
|
local result = string.split(resp, "#")
|
||||||
|
if LoginManager.IsLogin and tonumber(result[1]) == SDK_RESULT.SUCCESS then
|
||||||
|
ThinkingAnalyticsManager.Track("quit_account")
|
||||||
|
Game.Restart()
|
||||||
|
end
|
||||||
|
-- 发送登出事件
|
||||||
|
Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLogout)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
-- 检测是否是新账户
|
||||||
|
function this.CheckIsRegister(openId, func)
|
||||||
|
if func then
|
||||||
|
func(false)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function this.TrackCreateAccount()
|
||||||
-- 登出之前的账号
|
-- 登出之前的账号
|
||||||
ThinkingAnalyticsManager.Logout()
|
ThinkingAnalyticsManager.Logout()
|
||||||
ThinkingAnalyticsManager.ClearSuperProperties()
|
ThinkingAnalyticsManager.ClearSuperProperties()
|
||||||
|
@ -58,32 +105,6 @@ function this.Initialize()
|
||||||
device_id = AppConst.isSDK and ThinkingAnalyticsManager.GetDeviceId() or ""
|
device_id = AppConst.isSDK and ThinkingAnalyticsManager.GetDeviceId() or ""
|
||||||
})
|
})
|
||||||
ThinkingAnalyticsManager.Track("create_account")
|
ThinkingAnalyticsManager.Track("create_account")
|
||||||
end
|
|
||||||
-- 发送登录成功事件
|
|
||||||
Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLoginSuccess,result[1])
|
|
||||||
end
|
|
||||||
|
|
||||||
SDKMgr.onSwitchAccountCallback = function(resp)
|
|
||||||
Log("onSwitchAccountCallback::"..resp)
|
|
||||||
local result = string.split(resp, "#")
|
|
||||||
--Util.LogError(debug.traceback("<color=#00ccee>onSwitchAccountCallback:" .. result[1] .. "</color>"))
|
|
||||||
if tonumber(result[1]) == SDK_RESULT.SUCCESS then
|
|
||||||
ThinkingAnalyticsManager.Track("change_account")
|
|
||||||
Game.Restart()
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
SDKMgr.onLogoutCallback = function(resp)
|
|
||||||
Log("onLogoutCallback::"..resp)
|
|
||||||
local result = string.split(resp, "#")
|
|
||||||
--Util.LogError(debug.traceback("<color=#00ccee>onLogoutCallback:" .. result[1] .. "</color>"))
|
|
||||||
if LoginManager.IsLogin and tonumber(result[1]) == SDK_RESULT.SUCCESS then
|
|
||||||
ThinkingAnalyticsManager.Track("quit_account")
|
|
||||||
Game.Restart()
|
|
||||||
end
|
|
||||||
-- 发送登出事件
|
|
||||||
Game.GlobalEvent:DispatchEvent(GameEvent.LoginSuccess.OnLogout)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function this.SaveLoginInfo(user, pw)
|
function this.SaveLoginInfo(user, pw)
|
||||||
|
@ -158,4 +179,6 @@ function this.RequestUser(name, pw, call)
|
||||||
end,nil,nil,nil)
|
end,nil,nil,nil)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return this
|
return this
|
|
@ -593,6 +593,8 @@ function this.RequestHttpLogin()
|
||||||
.. "&gid=" .. AppConst.SdkPackageName --LoginManager.pt_gId
|
.. "&gid=" .. AppConst.SdkPackageName --LoginManager.pt_gId
|
||||||
.. "&version=" .. LoginRoot_PackageVersion
|
.. "&version=" .. LoginRoot_PackageVersion
|
||||||
.. "&timeStamp="..LoginManager.SdkLoginTimeStamp
|
.. "&timeStamp="..LoginManager.SdkLoginTimeStamp
|
||||||
|
.. "&ext="..encodeURI(LoginManager.extData)
|
||||||
|
.. "&platform_appid="..LoginManager.p_appId
|
||||||
else
|
else
|
||||||
if IsDevelopLogin then
|
if IsDevelopLogin then
|
||||||
-- 开发用
|
-- 开发用
|
||||||
|
|
Loading…
Reference in New Issue