[M] change sns link function

This commit is contained in:
2025-12-25 15:41:48 +08:00
parent 8cc0a67f03
commit 58a29b0335
8 changed files with 106 additions and 26 deletions

View File

@@ -21,6 +21,7 @@ public class ConfigManager {
public static final String UNITY_FACADE_NAME = "TYSdkFacade";
public static final String LOGIN_CALLBACK_FUNCTION_NAME = "LoginResult";
public static final String LINKACCOUT_CALLBACK_FUNCTION_NAME = "LinkAccoutResult";
public static final String CHECKLINK_CALLBACK_FUNCTION_NAME = "CheckLinkResult";
public static final String PAY_CALLBACK_FUNCTION_NAME = "PayResult";
public static final String PAY_TYPE_CALLBACK_FUNCTION_NAME = "SKUListResult";

View File

@@ -161,12 +161,87 @@ public class SDKManager {
}
public static void LinkAccount(String type, String userId)
{
SDKAPI.getIns().getSnsInfo(type, (code, snsInfo, msg) -> {
if(code == SDKCallBack.CODE_SUCCESS && snsInfo != null){
SDKAPI.getIns().bindBySnsId(snsInfo, userId, mLogin);
}else {
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LOGIN_CALLBACK_FUNCTION_NAME, "{\"code\":1}}");
{
SDKAPI.getIns().getSnsInfo(type, (snscode, snsInfo, snsmsg) ->{
if(snscode == SDKCallBack.CODE_SUCCESS && snsInfo !=null)
{
SDKAPI.getIns().bindBySnsId(snsInfo, userId, (bindcode, bindmsg)->{
if(bindcode == SDKCallBack.CODE_SUCCESS)
{
String msg = "{\"code\":0, \"userId\": 0}";
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LINKACCOUT_CALLBACK_FUNCTION_NAME, msg);
}
else if(bindcode == 1)
{
try
{
JSONObject bindMsgObj = new JSONObject(bindmsg);
JSONObject bindMsgResult = bindMsgObj.getJSONObject("result");
int bindMsgResultCode = bindMsgResult.getInt("code");
if(bindMsgResultCode == 4)
{
SDKAPI.getIns().checkSnsInfo(snsInfo, (checkcode, checkMsg ) -> {
if(checkcode != SDKCallBack.CODE_SUCCESS)
{
Log.w(TAG, checkMsg);
String msg = "{\"code\":1, \"userId\": 0}";
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LINKACCOUT_CALLBACK_FUNCTION_NAME, msg);
return;
}
try {
//{
// "track":"128:10:28654792:1766569516",
// "result":{
// "bindInfo":"{ // \"guest\": \"guest:devidmap3:bf12a8a28b663548e368ebe8742368b7\", // \"google\": \"google:118182347502471840780\" // }",
// "code":0,
// "info":"user exist",
// "exist":1,
// "userId":10030
// }
// }
JSONObject checkMsgObj = new JSONObject(checkMsg);
JSONObject checkResult = checkMsgObj.getJSONObject("result");
String bindInfo = checkResult.getString("bindInfo");
int bindUserId = checkResult.getInt("userId");
JSONObject callbackMsg = new JSONObject();
callbackMsg.put("code", -1);
callbackMsg.put("userId", bindUserId);
callbackMsg.put("bindInfo", bindInfo);
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LINKACCOUT_CALLBACK_FUNCTION_NAME, callbackMsg.toString());
} catch (JSONException e) {
Log.i(TAG, e.toString());
String msg = "{\"code\":1, \"userId\": 0}";
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LINKACCOUT_CALLBACK_FUNCTION_NAME, msg);
}
});
}
else
{
Log.w(TAG, bindmsg);
String msg = "{\"code\":1, \"userId\": 0}";
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LINKACCOUT_CALLBACK_FUNCTION_NAME, msg);
}
}
catch (JSONException e)
{
Log.i(TAG, e.toString());
String msg = "{\"code\":1, \"userId\": 0}";
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LINKACCOUT_CALLBACK_FUNCTION_NAME, msg);
}
}
else
{
Log.w(TAG, bindmsg);
String msg = "{\"code\":1, \"userId\": 0}";
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LINKACCOUT_CALLBACK_FUNCTION_NAME, msg);
}
});
}
else
{
Log.w(TAG, snsmsg);
String msg = "{\"code\":1, \"userId\": 0}";
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.LINKACCOUT_CALLBACK_FUNCTION_NAME, msg);
}
});
}