Compare commits
4 Commits
dev_video
...
c0b6ccf7ed
| Author | SHA1 | Date | |
|---|---|---|---|
| c0b6ccf7ed | |||
| db82fe0116 | |||
| 6866b7fca9 | |||
| 9f5151c54c |
@@ -7,23 +7,94 @@ import com.tuyoo.gamesdk.api.SDKAPI;
|
||||
import com.tuyoo.gamesdk.api.SDKAPIConstant;
|
||||
import com.tuyoo.gamesdk.api.SDKCallBack;
|
||||
import com.tuyoo.gamesdk.api.SDKWrapper;
|
||||
import com.tuyoo.gamesdk.login.model.SnsInfo;
|
||||
|
||||
import org.json.JSONException;
|
||||
import org.json.JSONObject;
|
||||
|
||||
public class SnsTest {
|
||||
static final String TAG = "SNSTEST";
|
||||
static final String GOName = "SDKTest";
|
||||
|
||||
public static void Bind(String type, String guserId)
|
||||
static SnsInfo tmpSnsInfo = null;
|
||||
|
||||
public static void Bind(String type, String userId)
|
||||
{
|
||||
SDKAPI.getIns().getSnsInfo(type, (snscode, snsInfo, snsmsg) ->{
|
||||
if(snscode == SDKCallBack.CODE_SUCCESS && snsInfo !=null)
|
||||
if(snscode == SDKCallBack.CODE_SUCCESS && snsInfo != null)
|
||||
{
|
||||
SDKAPI.getIns().bindBySnsId(snsInfo, guserId, (bindcode, bindmsg)->{
|
||||
SDKAPI.getIns().bindBySnsId(snsInfo, userId, (bindcode, bindmsg)->{
|
||||
if(bindcode == SDKCallBack.CODE_SUCCESS)
|
||||
{
|
||||
Log.i(TAG, "LinkSns success");
|
||||
try {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code", bindcode);
|
||||
result.put("userId", userId);
|
||||
|
||||
JSONObject serverResponse = new JSONObject(bindmsg);
|
||||
JSONObject userInfo = serverResponse.getJSONObject("result");
|
||||
result.put("loginData", userInfo);
|
||||
UnityPlayer.UnitySendMessage(GOName, "BindCallback", result.toString());
|
||||
|
||||
} catch (JSONException e) {
|
||||
String msg = "{\"code\":1, \"userId\": 0}";
|
||||
UnityPlayer.UnitySendMessage(GOName, "BindCallback", msg);
|
||||
}
|
||||
}
|
||||
else if(bindcode == SDKCallBack.CODE_FAILED)
|
||||
{
|
||||
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(GOName, "BindCallback", msg);
|
||||
return;
|
||||
}
|
||||
try {
|
||||
tmpSnsInfo = snsInfo;
|
||||
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(GOName, "BindCallback", callbackMsg.toString());
|
||||
} catch (JSONException e) {
|
||||
Log.i(TAG, e.toString());
|
||||
String msg = "{\"code\":1, \"userId\": 0}";
|
||||
UnityPlayer.UnitySendMessage(GOName, "BindCallback", msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.w(TAG, bindmsg);
|
||||
String msg = "{\"code\":1, \"userId\": 0}";
|
||||
UnityPlayer.UnitySendMessage(GOName, "BindCallback", msg);
|
||||
}
|
||||
}
|
||||
catch (JSONException e)
|
||||
{
|
||||
Log.i(TAG, e.toString());
|
||||
String msg = "{\"code\":1, \"userId\": 0}";
|
||||
UnityPlayer.UnitySendMessage(GOName, "BindCallback", msg);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i(TAG, String.format("LinkSns failed, code: %d, msg: %s", bindcode, bindmsg));
|
||||
Log.w(TAG, bindmsg);
|
||||
String msg = "{\"code\":1, \"userId\": 0}";
|
||||
UnityPlayer.UnitySendMessage(GOName, "BindCallback", msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
@@ -34,8 +105,32 @@ public class SnsTest {
|
||||
});
|
||||
}
|
||||
|
||||
public static void Unbind(String type, int userId)
|
||||
public static void ChangeBind(int unbindUserId, int bindUserId)
|
||||
{
|
||||
if(tmpSnsInfo == null)
|
||||
{
|
||||
Log.i(TAG, "tmpSnsInfo is null");
|
||||
return ;
|
||||
}
|
||||
|
||||
SDKAPI.getIns().unbindBySnsId(tmpSnsInfo, String.valueOf(unbindUserId), (unbindCode, unbindMsg) -> {
|
||||
Log.i(TAG, "unbindBySnsId code: " + unbindCode + " msg: " + unbindMsg);
|
||||
if(unbindCode == SDKCallBack.CODE_SUCCESS)
|
||||
{
|
||||
SDKAPI.getIns().bindBySnsId(tmpSnsInfo, String.valueOf(bindUserId), (bindCode, bindMsg) -> {
|
||||
Log.i(TAG, "bindBySnsId code: " + bindCode + " msg: " + bindMsg);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void RmSns()
|
||||
{
|
||||
tmpSnsInfo = null;
|
||||
}
|
||||
|
||||
public static void GetSns(String accountType)
|
||||
{
|
||||
Log.i(TAG, "GetSns accountType: " + accountType);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -513,6 +513,127 @@ MonoBehaviour:
|
||||
m_MipBias: 0
|
||||
m_VarianceClampScale: 0.9
|
||||
m_ContrastAdaptiveSharpening: 0
|
||||
--- !u!1 &385330068
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 385330072}
|
||||
- component: {fileID: 385330071}
|
||||
- component: {fileID: 385330070}
|
||||
- component: {fileID: 385330069}
|
||||
m_Layer: 5
|
||||
m_Name: changebind
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!114 &385330069
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 385330068}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 385330070}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &385330070
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 385330068}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &385330071
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 385330068}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!224 &385330072
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 385330068}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 465819806}
|
||||
m_Father: {fileID: 1044920373}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!1 &393321311
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -549,6 +670,85 @@ RectTransform:
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: -20, y: -20}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!1 &465819805
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 465819806}
|
||||
- component: {fileID: 465819808}
|
||||
- component: {fileID: 465819807}
|
||||
m_Layer: 5
|
||||
m_Name: Text (Legacy)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &465819806
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 465819805}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 385330072}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &465819807
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 465819805}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 33
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 0
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: CBind
|
||||
--- !u!222 &465819808
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 465819805}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &471181945
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -670,7 +870,7 @@ GameObject:
|
||||
- component: {fileID: 514656874}
|
||||
- component: {fileID: 514656873}
|
||||
m_Layer: 5
|
||||
m_Name: Check sns
|
||||
m_Name: rm sns
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@@ -1315,6 +1515,127 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 757589085}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &839565401
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 839565402}
|
||||
- component: {fileID: 839565405}
|
||||
- component: {fileID: 839565404}
|
||||
- component: {fileID: 839565403}
|
||||
m_Layer: 5
|
||||
m_Name: LoginBySns
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &839565402
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 839565401}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children:
|
||||
- {fileID: 1387388941}
|
||||
m_Father: {fileID: 1044920373}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 0, y: 0}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 1}
|
||||
--- !u!114 &839565403
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 839565401}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 4e29b1a8efbd4b44bb3f3716e73f07ff, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Navigation:
|
||||
m_Mode: 3
|
||||
m_WrapAround: 0
|
||||
m_SelectOnUp: {fileID: 0}
|
||||
m_SelectOnDown: {fileID: 0}
|
||||
m_SelectOnLeft: {fileID: 0}
|
||||
m_SelectOnRight: {fileID: 0}
|
||||
m_Transition: 1
|
||||
m_Colors:
|
||||
m_NormalColor: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_HighlightedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_PressedColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 1}
|
||||
m_SelectedColor: {r: 0.9607843, g: 0.9607843, b: 0.9607843, a: 1}
|
||||
m_DisabledColor: {r: 0.78431374, g: 0.78431374, b: 0.78431374, a: 0.5019608}
|
||||
m_ColorMultiplier: 1
|
||||
m_FadeDuration: 0.1
|
||||
m_SpriteState:
|
||||
m_HighlightedSprite: {fileID: 0}
|
||||
m_PressedSprite: {fileID: 0}
|
||||
m_SelectedSprite: {fileID: 0}
|
||||
m_DisabledSprite: {fileID: 0}
|
||||
m_AnimationTriggers:
|
||||
m_NormalTrigger: Normal
|
||||
m_HighlightedTrigger: Highlighted
|
||||
m_PressedTrigger: Pressed
|
||||
m_SelectedTrigger: Selected
|
||||
m_DisabledTrigger: Disabled
|
||||
m_Interactable: 1
|
||||
m_TargetGraphic: {fileID: 839565404}
|
||||
m_OnClick:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
--- !u!114 &839565404
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 839565401}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: fe87c0e1cc204ed48ad3b37840f39efc, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 1, g: 1, b: 1, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_Sprite: {fileID: 10905, guid: 0000000000000000f000000000000000, type: 0}
|
||||
m_Type: 1
|
||||
m_PreserveAspect: 0
|
||||
m_FillCenter: 1
|
||||
m_FillMethod: 4
|
||||
m_FillAmount: 1
|
||||
m_FillClockwise: 1
|
||||
m_FillOrigin: 0
|
||||
m_UseSpriteMesh: 0
|
||||
m_PixelsPerUnitMultiplier: 1
|
||||
--- !u!222 &839565405
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 839565401}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &845062987
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1506,7 +1827,7 @@ MonoBehaviour:
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: CSNS
|
||||
m_Text: RM SNS
|
||||
--- !u!222 &875109649
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -1706,11 +2027,13 @@ RectTransform:
|
||||
- {fileID: 1956900235}
|
||||
- {fileID: 1299164145}
|
||||
- {fileID: 1472314934}
|
||||
- {fileID: 839565402}
|
||||
- {fileID: 1274822429}
|
||||
- {fileID: 1095319726}
|
||||
- {fileID: 514656872}
|
||||
- {fileID: 599093755}
|
||||
- {fileID: 730871748}
|
||||
- {fileID: 385330072}
|
||||
m_Father: {fileID: 1451597222}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
@@ -2276,6 +2599,87 @@ CanvasRenderer:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1299164144}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1387388940
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1387388941}
|
||||
- component: {fileID: 1387388943}
|
||||
- component: {fileID: 1387388942}
|
||||
m_Layer: 5
|
||||
m_Name: Text (Legacy)
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!224 &1387388941
|
||||
RectTransform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1387388940}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_ConstrainProportionsScale: 0
|
||||
m_Children: []
|
||||
m_Father: {fileID: 839565402}
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
m_AnchorMin: {x: 0, y: 0}
|
||||
m_AnchorMax: {x: 1, y: 1}
|
||||
m_AnchoredPosition: {x: 0, y: 0}
|
||||
m_SizeDelta: {x: 0, y: 0}
|
||||
m_Pivot: {x: 0.5, y: 0.5}
|
||||
--- !u!114 &1387388942
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1387388940}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f7201a12d95ffc409449d95f23cf332, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
m_Material: {fileID: 0}
|
||||
m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1}
|
||||
m_RaycastTarget: 1
|
||||
m_RaycastPadding: {x: 0, y: 0, z: 0, w: 0}
|
||||
m_Maskable: 1
|
||||
m_OnCullStateChanged:
|
||||
m_PersistentCalls:
|
||||
m_Calls: []
|
||||
m_FontData:
|
||||
m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0}
|
||||
m_FontSize: 33
|
||||
m_FontStyle: 0
|
||||
m_BestFit: 1
|
||||
m_MinSize: 10
|
||||
m_MaxSize: 40
|
||||
m_Alignment: 4
|
||||
m_AlignByGeometry: 0
|
||||
m_RichText: 0
|
||||
m_HorizontalOverflow: 0
|
||||
m_VerticalOverflow: 0
|
||||
m_LineSpacing: 1
|
||||
m_Text: 'loginSNS
|
||||
|
||||
'
|
||||
--- !u!222 &1387388943
|
||||
CanvasRenderer:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1387388940}
|
||||
m_CullTransparentMesh: 1
|
||||
--- !u!1 &1422461756
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -2871,9 +3275,10 @@ MonoBehaviour:
|
||||
loginBtn: {fileID: 1472314935}
|
||||
logoutBtn: {fileID: 1274822430}
|
||||
getSnsBtn: {fileID: 1095319727}
|
||||
checkSnsBtn: {fileID: 514656873}
|
||||
rmSnsBtn: {fileID: 514656873}
|
||||
loginBySns: {fileID: 839565403}
|
||||
bindBtn: {fileID: 599093756}
|
||||
unbindBtn: {fileID: 730871749}
|
||||
changeBindBtn: {fileID: 385330069}
|
||||
--- !u!1 &1905578657
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using tysdk;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
@@ -28,13 +29,17 @@ public class UnbindTest : MonoBehaviour
|
||||
private Button getSnsBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button checkSnsBtn;
|
||||
private Button rmSnsBtn;
|
||||
|
||||
|
||||
[SerializeField]
|
||||
private Button loginBySns;
|
||||
|
||||
[SerializeField]
|
||||
private Button bindBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button unbindBtn;
|
||||
private Button changeBindBtn;
|
||||
|
||||
private EAccoutType accoutType;
|
||||
|
||||
@@ -56,9 +61,10 @@ public class UnbindTest : MonoBehaviour
|
||||
}); loginBtn.onClick.AddListener(OnLogin);
|
||||
logoutBtn.onClick.AddListener(OnLogout);
|
||||
getSnsBtn.onClick.AddListener(OnGetSns);
|
||||
checkSnsBtn.onClick.AddListener(OnCheckSns);
|
||||
rmSnsBtn.onClick.AddListener(OnRmSns);
|
||||
loginBySns.onClick.AddListener(OnLoginBySns);
|
||||
bindBtn.onClick.AddListener(OnBind);
|
||||
unbindBtn.onClick.AddListener(OnUnbind);
|
||||
changeBindBtn.onClick.AddListener(OnChangeBind);
|
||||
Debug.Log("========== Init =============");
|
||||
TYSdkFacade.Instance.Init();
|
||||
Debug.Log($"AccoutType {accoutType}");
|
||||
@@ -96,7 +102,14 @@ public class UnbindTest : MonoBehaviour
|
||||
t.CallStatic("GetSns", accoutType.ToString());
|
||||
}
|
||||
|
||||
private async void OnCheckSns()
|
||||
private void OnRmSns()
|
||||
{
|
||||
Debug.Log("========== Get SNS =============");
|
||||
using var t = new AndroidJavaClass(Cls);
|
||||
t.CallStatic("RmSns") ;
|
||||
}
|
||||
|
||||
private async void OnLoginBySns()
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -115,6 +128,7 @@ public class UnbindTest : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
private int buserId;
|
||||
private async void OnBind()
|
||||
{
|
||||
try
|
||||
@@ -126,6 +140,7 @@ public class UnbindTest : MonoBehaviour
|
||||
{
|
||||
var info = await PlayFabTool.GetPFPlayerInfoBySDKId(linkResult.userId, "6DC6D");
|
||||
Debug.Log(info?.ToString() ?? "[UnbindTest::OnBind] info is null");
|
||||
buserId = linkResult.userId;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -134,21 +149,17 @@ public class UnbindTest : MonoBehaviour
|
||||
}
|
||||
}
|
||||
|
||||
public void BindCallback(string message)
|
||||
private async void OnChangeBind()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnUnbind()
|
||||
{
|
||||
using (var t = new AndroidJavaClass(Cls))
|
||||
try
|
||||
{
|
||||
t.CallStatic("Unbind");
|
||||
Debug.Log("========== Change Bind =============");
|
||||
var result = await TYSdkFacade.Instance.ChangeLinkAccount(accoutType, buserId, loginInfo.userId);
|
||||
Debug.Log($"Change Bind Result Code:{result.code}, UserId:{result.userId}, msg:{result.msg}");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogException(e);
|
||||
}
|
||||
}
|
||||
|
||||
public void UnbindCallback(string message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,10 +22,10 @@ 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 CHANGELINK_CALLBACK_FUNCTION_NAME = "ChangeLinkAccountResult";
|
||||
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";
|
||||
public static final String FCM_NOTICE_FUNCTION_NAME = "FCMCallback";
|
||||
public static final String FCM_REALNAME_CALLBACK_FUNCTION_NAME = "RealNameCallback";
|
||||
|
||||
}
|
||||
|
||||
@@ -266,6 +266,41 @@ public class SDKManager {
|
||||
tmpSnsInfo = null;
|
||||
}
|
||||
|
||||
public static void ChangeLinkAccount(String type, int oldUserId, int newUserId)
|
||||
{
|
||||
if(tmpSnsInfo == null)
|
||||
{
|
||||
String msg = "{\"code\":1, \"userId\": 0, \"msg\": \"tmpSnsInfo is null\"}";
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHANGELINK_CALLBACK_FUNCTION_NAME, msg);
|
||||
return;
|
||||
}
|
||||
|
||||
SDKAPI.getIns().unbindBySnsId(tmpSnsInfo, String.valueOf(oldUserId), (unbindCode, unbindMsg) -> {
|
||||
Log.i(TAG, "unbindBySnsId code: " + unbindCode + " msg: " + unbindMsg);
|
||||
if(unbindCode == SDKCallBack.CODE_SUCCESS)
|
||||
{
|
||||
SDKAPI.getIns().bindBySnsId(tmpSnsInfo, String.valueOf(newUserId), (bindCode, bindMsg) -> {
|
||||
Log.i(TAG, "bindBySnsId code: " + bindCode + " msg: " + bindMsg);
|
||||
if(bindCode == SDKCallBack.CODE_SUCCESS)
|
||||
{
|
||||
String msg = "{\"code\":0, \"userId\": " + newUserId + ", \"msg\": \"success\"}";
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHANGELINK_CALLBACK_FUNCTION_NAME, msg);
|
||||
}
|
||||
else
|
||||
{
|
||||
String msg = String.format("{\"code\":-1, \"userId\": 0, \"msg\": \"%s\"}", bindMsg);
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHANGELINK_CALLBACK_FUNCTION_NAME, msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
String msg = String.format("{\"code\":1, \"userId\": 0, \"msg\": \"%s\"}", unbindMsg);
|
||||
UnityPlayer.UnitySendMessage(ConfigManager.UNITY_FACADE_NAME, ConfigManager.CHANGELINK_CALLBACK_FUNCTION_NAME, msg);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void LinkCheck(String type)
|
||||
{
|
||||
SDKAPI.getIns().getSnsInfo(type, (code, snsInfo, msg) -> {
|
||||
|
||||
@@ -147,6 +147,20 @@ extern "C" {
|
||||
}
|
||||
}
|
||||
|
||||
NSInteger LoginTypeToBindType(NSInteger loginType)
|
||||
{
|
||||
switch (loginType) {
|
||||
case XYLoginWithApple:
|
||||
return XYBindApple;
|
||||
case XYLoginWithFB:
|
||||
return XYBindFB;
|
||||
case XYLoginWithGoogle:
|
||||
return XYBindGoodle;
|
||||
default:
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
const char* UnityLoginBySnsInfo()
|
||||
{
|
||||
NSLog(@"TYSdkInterface UnityLoginBySnsInfo");
|
||||
@@ -387,10 +401,6 @@ extern "C" {
|
||||
}];
|
||||
}
|
||||
|
||||
void UnlinkGoogle()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LinkFacebook(const int userId)
|
||||
{
|
||||
@@ -412,10 +422,6 @@ extern "C" {
|
||||
}];
|
||||
}
|
||||
|
||||
void UnlinkFacebook()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LinkApple(const int userId)
|
||||
{
|
||||
@@ -437,11 +443,60 @@ extern "C" {
|
||||
}];
|
||||
}
|
||||
|
||||
void UnlinkApple()
|
||||
void ChangeLinkAccount(const int accoutType, const int oldUserId, const int newUserId)
|
||||
{
|
||||
NSLog(@"TYSdkInterface ChangeLinkAccount accoutType:%d oldUserId:%d newUserId:%d", accoutType, oldUserId, newUserId);
|
||||
|
||||
if (g_snsLoginType == -1)
|
||||
{
|
||||
UnitySendMessage("TYSdkFacade", "ChangeLinkAccountResult",
|
||||
"{\"code\":1, \"userId\": 0, \"msg\": \"g_snsLoginType is invalid\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
NSInteger bindTypeValue = LoginTypeToBindType(g_snsLoginType);
|
||||
if (bindTypeValue == -1)
|
||||
{
|
||||
UnitySendMessage("TYSdkFacade", "ChangeLinkAccountResult",
|
||||
"{\"code\":1, \"userId\": 0, \"msg\": \"unsupported account type\"}");
|
||||
return;
|
||||
}
|
||||
|
||||
XYBindType bindType = (XYBindType)bindTypeValue;
|
||||
|
||||
XYBindReq *unbindReq = [XYBindReq initUnBindWithPlatform:bindType UserId:(NSUInteger)oldUserId];
|
||||
[XYApi XYUnBindByBindReq:unbindReq completionHandler:^(XYResp * _Nonnull unbindResp) {
|
||||
NSLog(@"TYSdkInterface ChangeLinkAccount unbind code:%ld msg:%@", (long)unbindResp.errCode, unbindResp.errStr);
|
||||
|
||||
if (unbindResp.errCode == XYSuccess)
|
||||
{
|
||||
XYBindReq *bindReq = [XYBindReq initBindWithPlatform:bindType UserId:(NSUInteger)newUserId];
|
||||
[XYApi XYBindByBindReq:bindReq isUnbindGuest:@"false" completionHandler:^(XYResp * _Nonnull bindResp) {
|
||||
NSLog(@"TYSdkInterface ChangeLinkAccount bind code:%ld msg:%@", (long)bindResp.errCode, bindResp.errStr);
|
||||
|
||||
if (bindResp.errCode == XYSuccess)
|
||||
{
|
||||
NSString *msg = [NSString stringWithFormat:@"{\"code\":0, \"userId\": %d, \"msg\": \"success\"}", newUserId];
|
||||
UnitySendMessage("TYSdkFacade", "ChangeLinkAccountResult", AllocCString(msg));
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *errStr = bindResp.errStr ? bindResp.errStr : @"bind failed";
|
||||
NSString *msg = [NSString stringWithFormat:@"{\"code\":-1, \"userId\": 0, \"msg\": \"%@\"}", errStr];
|
||||
UnitySendMessage("TYSdkFacade", "ChangeLinkAccountResult", AllocCString(msg));
|
||||
}
|
||||
}];
|
||||
}
|
||||
else
|
||||
{
|
||||
NSString *errStr = unbindResp.errStr ? unbindResp.errStr : @"unbind failed";
|
||||
NSString *msg = [NSString stringWithFormat:@"{\"code\":1, \"userId\": 0, \"msg\": \"%@\"}", errStr];
|
||||
UnitySendMessage("TYSdkFacade", "ChangeLinkAccountResult", AllocCString(msg));
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
|
||||
void FBShareLink(const char* title, const char* content, const char* url)
|
||||
{
|
||||
NSLog(@"TYSdkInterface FBShareLink");
|
||||
|
||||
@@ -71,6 +71,49 @@ namespace tysdk
|
||||
return tcs.Task;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 重置已注册 callback 的超时时间:取消先前安排的延时 <see cref="CancellationTokenSource.Cancel"/>,
|
||||
/// 并从<strong>当前时刻</strong>起在 <paramref name="newTimeout"/> 后触发取消(与构造时传入的延时等价,见 <see cref="CancellationTokenSource.CancelAfter(System.TimeSpan)"/>)。
|
||||
/// </summary>
|
||||
/// <typeparam name="T">Callback 数据类型</typeparam>
|
||||
/// <param name="newTimeout">新的超时时间;若需立即按超时处理可使用 <see cref="TimeSpan.Zero"/></param>
|
||||
/// <returns>找到未完成 pending 并成功重置则为 true</returns>
|
||||
public bool ResetCallbackTimeout<T>(TimeSpan newTimeout) where T : class
|
||||
{
|
||||
if (_disposed)
|
||||
throw new ObjectDisposedException(nameof(TYSDKCallbackManager));
|
||||
|
||||
var callbackId = typeof(T).Name;
|
||||
|
||||
if (!_callbacks.TryGetValue(callbackId, out var entry))
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"[TYSDKCallbackManager] No pending callback found for type: {callbackId}");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (entry.Task.IsCompleted)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"[TYSDKCallbackManager] Callback {callbackId} already completed, cannot reset timeout");
|
||||
return false;
|
||||
}
|
||||
|
||||
var cts = entry.CancellationTokenSource;
|
||||
if (cts == null)
|
||||
return false;
|
||||
|
||||
try
|
||||
{
|
||||
cts.CancelAfter(newTimeout);
|
||||
UnityEngine.Debug.Log($"[TYSDKCallbackManager] Reset timeout for {callbackId} to {newTimeout.TotalSeconds}s");
|
||||
return true;
|
||||
}
|
||||
catch (ObjectDisposedException)
|
||||
{
|
||||
UnityEngine.Debug.LogWarning($"[TYSDKCallbackManager] CancellationTokenSource already disposed for {callbackId}");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 触发callback
|
||||
/// </summary>
|
||||
|
||||
@@ -38,7 +38,8 @@ namespace tysdk
|
||||
{"google", EAccoutType.hwGoogle},
|
||||
{"fb", EAccoutType.hwFacebook},
|
||||
{"tyGuest", EAccoutType.hwGuest},
|
||||
{"ios13", EAccoutType.Apple}
|
||||
{"ios13", EAccoutType.Apple},
|
||||
{AccountString.hwVkid, EAccoutType.hwVkid}
|
||||
};
|
||||
|
||||
private static EAccoutType ConvertAccoutType(string accountType)
|
||||
@@ -364,6 +365,43 @@ namespace tysdk
|
||||
UnityBridgeFunc.CleanLinkTmpSnsInfo();
|
||||
}
|
||||
|
||||
public async Task<ChangeLinkResult> ChangeLinkAccount(EAccoutType accoutType, int oldUserId, int newUserId)
|
||||
{
|
||||
var task = TYSDKCallbackManager.Instance.RegisterCallback<ChangeLinkResult>(TimeSpan.FromSeconds(30));
|
||||
UnityBridgeFunc.ChangeLinkAccount(accoutType, oldUserId, newUserId);
|
||||
try
|
||||
{
|
||||
var result = await task;
|
||||
if (result.code == 0)
|
||||
{
|
||||
_accountInfo.AddLinkedAccount(accoutType);
|
||||
_accountInfo.Save();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.LogWarning($"[TYSdkFacade] Change link account failed: {e}");
|
||||
return new ChangeLinkResult() { code = 1 };
|
||||
}
|
||||
finally
|
||||
{
|
||||
CleanLinkTempSnSInfo();
|
||||
}
|
||||
}
|
||||
|
||||
public void ChangeLinkAccountResult(string message)
|
||||
{
|
||||
JObject data = JObject.Parse(message);
|
||||
var result = new ChangeLinkResult()
|
||||
{
|
||||
code = (int)data["code"],
|
||||
userId = (int)data["userId"],
|
||||
msg = (string)data["msg"]
|
||||
};
|
||||
TYSDKCallbackManager.Instance.TryTriggerCallback(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否已经绑定
|
||||
/// <returns>
|
||||
|
||||
@@ -20,6 +20,8 @@ namespace tysdk
|
||||
|___/
|
||||
=================================================*/
|
||||
|
||||
private bool _payFirstNegativeHandled;
|
||||
|
||||
//public async Task<PaymentInfo> Pay(string prodId, string prodPrice, string prodName, int count, string pType, string price_amount_micros =null)
|
||||
public async Task<PaymentInfo> Pay(SKUDetail prod, int count, float usdprice, JObject purchaseInfo)
|
||||
{
|
||||
@@ -76,6 +78,10 @@ namespace tysdk
|
||||
Debug.LogWarning($"[TYSdkFacade::Pay] Faild {e.Message}");
|
||||
return new PaymentInfo(){code = "-1"};
|
||||
}
|
||||
finally
|
||||
{
|
||||
_payFirstNegativeHandled = false;
|
||||
}
|
||||
|
||||
|
||||
#elif UNITY_IOS
|
||||
@@ -95,6 +101,10 @@ namespace tysdk
|
||||
Debug.LogWarning($"[TYSdkFacade::Pay] Faild {e.Message}");
|
||||
return new PaymentInfo(){code = "-1"};
|
||||
}
|
||||
finally
|
||||
{
|
||||
_payFirstNegativeHandled = false;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
@@ -108,7 +118,16 @@ namespace tysdk
|
||||
result.msg = jresult["errStr"].ToString();
|
||||
if(result.code == "-1")
|
||||
{
|
||||
Debug.Log("[TYSdkFacade] pay failed: waiting next pay callback");
|
||||
if (!_payFirstNegativeHandled)
|
||||
{
|
||||
_payFirstNegativeHandled = true;
|
||||
TYSDKCallbackManager.Instance.ResetCallbackTimeout<PaymentInfo>(TimeSpan.FromSeconds(5));
|
||||
Debug.Log("[TYSdkFacade] pay failed (first time): reset timeout to 5s, waiting next pay callback");
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("[TYSdkFacade] pay failed: waiting next pay callback");
|
||||
}
|
||||
return;
|
||||
}
|
||||
TYSDKCallbackManager.Instance.TryTriggerCallback(result);
|
||||
|
||||
@@ -14,6 +14,12 @@ namespace tysdk
|
||||
none
|
||||
}
|
||||
|
||||
public static class AccountString
|
||||
{
|
||||
public const string hwVkid = "vk.global.app";
|
||||
}
|
||||
|
||||
|
||||
public class LoginInfo
|
||||
{
|
||||
public bool isSuccess;
|
||||
@@ -34,6 +40,13 @@ namespace tysdk
|
||||
public Dictionary<string, string> bindInfo;
|
||||
}
|
||||
|
||||
public class ChangeLinkResult
|
||||
{
|
||||
public int code;
|
||||
public int userId;
|
||||
public string msg;
|
||||
}
|
||||
|
||||
public class LinkCheckInfo
|
||||
{
|
||||
public int code;
|
||||
|
||||
@@ -7,7 +7,13 @@ namespace tysdk
|
||||
|
||||
public static class UnityBridgeFunc
|
||||
{
|
||||
|
||||
#if UNITY_EDITOR || UNITY_ANDROID
|
||||
private static string EAccountTypeToStr(EAccoutType accountType)
|
||||
{
|
||||
return accountType == EAccoutType.hwVkid ? AccountString.hwVkid : accountType.ToString();
|
||||
}
|
||||
|
||||
#endif
|
||||
#if UNITY_EDITOR
|
||||
//初始化sdk
|
||||
public static void InitSDK(){}
|
||||
@@ -26,7 +32,7 @@ namespace tysdk
|
||||
|
||||
|
||||
public static void LinkAccount(EAccoutType accoutType){}
|
||||
public static void UnlinkAccount(EAccoutType accoutType){}
|
||||
public static void ChangeLinkAccount(EAccoutType accoutType, int oldUserId, int newUserId){}
|
||||
public static void LinkCheck(EAccoutType accoutType){}
|
||||
|
||||
public static void UnityGetIdentityFun(string type){}
|
||||
@@ -61,8 +67,6 @@ namespace tysdk
|
||||
|
||||
public static void FBShareLink(string title, string content, string url) { }
|
||||
public static void MessengerShareLink(string title, string content, string url) { }
|
||||
|
||||
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
@@ -107,10 +111,12 @@ namespace tysdk
|
||||
|
||||
public static void UnityLogin(EAccoutType accoutType)
|
||||
{
|
||||
var accountInfo = EAccountTypeToStr(accoutType);
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityLogin", accoutType.ToString());
|
||||
sdkManager.CallStatic("UnityLogin",accountInfo);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void UnityGetIdentityFun(string type)
|
||||
@@ -124,18 +130,20 @@ namespace tysdk
|
||||
public static void UnityLogOutByChannel(EAccoutType accoutType)
|
||||
{
|
||||
|
||||
var accountInfo = EAccountTypeToStr(accoutType);
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnityLogOutByChannel", accoutType.ToString());
|
||||
sdkManager.CallStatic("UnityLogOutByChannel", accountInfo);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
string userId = TYSdkFacade.TYAccountInfo.strUserId;
|
||||
using (var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
string userId = TYSdkFacade.TYAccountInfo.strUserId;
|
||||
sdkManager.CallStatic("LinkAccount", accoutType.ToString(), userId);
|
||||
var accountInfo = EAccountTypeToStr(accoutType);
|
||||
sdkManager.CallStatic("LinkAccount",accountInfo,userId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -149,19 +157,21 @@ namespace tysdk
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnlinkAccount(EAccoutType accoutType)
|
||||
public static void ChangeLinkAccount(EAccoutType accoutType, int oldUserId, int newUserId)
|
||||
{
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
var accountInfo = EAccountTypeToStr(accoutType);
|
||||
using (var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("UnlinkAccount", accoutType.ToString());
|
||||
sdkManager.CallStatic("ChangeLinkAccount", accountInfo, oldUserId, newUserId);
|
||||
}
|
||||
}
|
||||
|
||||
public static void LinkCheck(EAccoutType accoutType)
|
||||
{
|
||||
var accountInfo = EAccountTypeToStr(accoutType);
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("LinkCheck", accoutType.ToString());
|
||||
sdkManager.CallStatic("LinkCheck",accountInfo);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +242,7 @@ namespace tysdk
|
||||
using(var sdkManager = new AndroidJavaClass(SDK_CLASS))
|
||||
{
|
||||
sdkManager.CallStatic("Review");
|
||||
// sdkManager.CallStataic("RuStoreReview");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -298,16 +309,16 @@ namespace tysdk
|
||||
}
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByGuest();
|
||||
private static extern void UnityLoginByGuest();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByGoogle();
|
||||
private static extern void UnityLoginByGoogle();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByFacebook();
|
||||
private static extern void UnityLoginByFacebook();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByApple();
|
||||
private static extern void UnityLoginByApple();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityGetIdentityFun(string type);
|
||||
@@ -364,25 +375,13 @@ namespace tysdk
|
||||
}
|
||||
}
|
||||
|
||||
public static void UnlinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
switch (accoutType)
|
||||
{
|
||||
case EAccoutType.hwGoogle:
|
||||
UnlinkGoogle();
|
||||
break;
|
||||
case EAccoutType.hwFacebook:
|
||||
UnlinkFacebook();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("__Internal")] private static extern void LinkGoogle(int userId);
|
||||
[DllImport("__Internal")] private static extern void UnlinkGoogle();
|
||||
[DllImport("__Internal")] private static extern void LinkFacebook(int userId);
|
||||
[DllImport("__Internal")] private static extern void UnlinkFacebook();
|
||||
[DllImport("__Internal")] private static extern void LinkApple(int userId);
|
||||
[DllImport("__Internal")] private static extern void UnlinkApple();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void ChangeLinkAccount(EAccoutType accoutType, int oldUserId, int newUserId);
|
||||
|
||||
public static void LinkCheck(EAccoutType accoutType)
|
||||
{
|
||||
@@ -401,6 +400,7 @@ namespace tysdk
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
[DllImport("__Internal")] public static extern void CleanLinkTmpSnsInfo();
|
||||
|
||||
[DllImport("__Internal")] private static extern void IsLinkedGoogle();
|
||||
|
||||
Reference in New Issue
Block a user