84 lines
3.0 KiB
C#
84 lines
3.0 KiB
C#
|
using cfg.BI;
|
|||
|
using PhxhSDK;
|
|||
|
using Framework.BI;
|
|||
|
using Gameplay.Login;
|
|||
|
using Framework.Event;
|
|||
|
using Constants = Framework.Constants.Constants;
|
|||
|
|
|||
|
public class LoginStatusApple : LoginStatus
|
|||
|
{
|
|||
|
public override LoginStatusID ID
|
|||
|
{
|
|||
|
get { return LoginStatusID.Apple; }
|
|||
|
}
|
|||
|
|
|||
|
public override void QuickLogin()
|
|||
|
{
|
|||
|
DebugUtil.LogWarning("苹果快速登录");
|
|||
|
var sdkHelper = SDKManager.Instance.GetSdkHelper(SDKManager.SdkName.FireBase);
|
|||
|
var loginService = sdkHelper as ILoginService;
|
|||
|
loginService?.SetCurLoginParty(ThirdLoginSDK.AppleSignIn);
|
|||
|
loginService?.QuickLogin(OnLoginSuccess, OnLoginFail);
|
|||
|
}
|
|||
|
|
|||
|
public override void Login()
|
|||
|
{
|
|||
|
DebugUtil.LogWarning("苹果登录");
|
|||
|
var sdkHelper = SDKManager.Instance.GetSdkHelper(SDKManager.SdkName.FireBase);
|
|||
|
var loginService = sdkHelper as ILoginService;
|
|||
|
loginService?.SetCurLoginParty(ThirdLoginSDK.AppleSignIn);
|
|||
|
loginService?.Login(OnLoginSuccess, OnLoginFail);
|
|||
|
}
|
|||
|
|
|||
|
public override void Logout()
|
|||
|
{
|
|||
|
var sdkHelper = SDKManager.Instance.GetSdkHelper(SDKManager.SdkName.FireBase);
|
|||
|
var loginService = sdkHelper as ILoginService;
|
|||
|
loginService?.SetCurLoginParty(ThirdLoginSDK.AppleSignIn);
|
|||
|
loginService?.Logout();
|
|||
|
}
|
|||
|
|
|||
|
public override string GetProfileName()
|
|||
|
{
|
|||
|
var sdkHelper = SDKManager.Instance.GetSdkHelper(SDKManager.SdkName.FireBase);
|
|||
|
var loginService = sdkHelper as ILoginService;
|
|||
|
loginService?.SetCurLoginParty(ThirdLoginSDK.AppleSignIn);
|
|||
|
string profileName = loginService?.GetProfileName();
|
|||
|
DebugUtil.LogWarning("Apple Get UserName: {0}", profileName);
|
|||
|
return string.IsNullOrEmpty(profileName) ? Constants.EmptyUser : profileName;
|
|||
|
}
|
|||
|
|
|||
|
private void OnLoginSuccess(string userID, string appleUserID, string idToken)
|
|||
|
{
|
|||
|
LoginManager.Instance.IsLogin = true;
|
|||
|
LoginManager.Instance.ShowLogin = true;
|
|||
|
|
|||
|
//第三方ID设置为Firebase验证后的唯一id 并存至本地
|
|||
|
AppInfoManager.Instance.ThirdLoginSuccess(userID, LoginStatusID.Apple);
|
|||
|
|
|||
|
//BI事件
|
|||
|
BIManager.Instance.ThirdID = userID;
|
|||
|
BIManager.Instance.TrackEvent(Event.login_success);
|
|||
|
BIManager.Instance.TrackEventOnce(EventFirst.fte_login_success);
|
|||
|
|
|||
|
//从服务器获取数据
|
|||
|
GetDataFromSever();
|
|||
|
|
|||
|
EventManager.Instance.Send(EventManager.EventName.LoginSuccess);
|
|||
|
DebugUtil.LogWarning("Apple登录成功:userID: {0}", userID);
|
|||
|
}
|
|||
|
|
|||
|
private void GetDataFromSever()
|
|||
|
{
|
|||
|
AppInfoManager.Instance.CurLoginState = AppInfoManager.NetConfigID.ThirdID;
|
|||
|
AppNetConfig.State = NetRequestStatus.Start;
|
|||
|
}
|
|||
|
|
|||
|
private void OnLoginFail(int code, string msg)
|
|||
|
{
|
|||
|
LoginManager.Instance.IsLogin = false;
|
|||
|
BIManager.Instance.TrackEvent(Event.login_fail, msg);
|
|||
|
DebugUtil.LogError("Apple Login Fail: {0}", msg);
|
|||
|
EventManager.Instance.Send(EventManager.EventName.LoginFail);
|
|||
|
}
|
|||
|
}
|