[M] new call back
[wip]
This commit is contained in:
40
sdk-intergration/Assets/Plugins/Android/SnsTest.java
Normal file
40
sdk-intergration/Assets/Plugins/Android/SnsTest.java
Normal file
@@ -0,0 +1,40 @@
|
||||
package com.unity3d.player;
|
||||
|
||||
import android.util.Log;
|
||||
|
||||
import com.tuyoo.gamesdk.api.SDKAPI;
|
||||
import com.tuyoo.gamesdk.api.SDKAPIConstant;
|
||||
import com.tuyoo.gamesdk.api.SDKCallBack;
|
||||
import com.tuyoo.gamesdk.api.SDKWrapper;
|
||||
|
||||
public class SnsTest {
|
||||
static final String TAG = "SNSTEST";
|
||||
|
||||
public static void Bind(String type, String guserId)
|
||||
{
|
||||
SDKAPI.getIns().getSnsInfo(type, (snscode, snsInfo, snsmsg) ->{
|
||||
if(snscode == SDKCallBack.CODE_SUCCESS && snsInfo !=null)
|
||||
{
|
||||
SDKAPI.getIns().bindBySnsId(snsInfo, guserId, (bindcode, bindmsg)->{
|
||||
if(bindcode == SDKCallBack.CODE_SUCCESS)
|
||||
{
|
||||
Log.i(TAG, "LinkSns success");
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i(TAG, String.format("LinkSns failed, code: %d, msg: %s", bindcode, bindmsg));
|
||||
}
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
Log.i(TAG, "getSnsInfo failed");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public static void Unbind(String type, int userId)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
32
sdk-intergration/Assets/Plugins/Android/SnsTest.java.meta
Normal file
32
sdk-intergration/Assets/Plugins/Android/SnsTest.java.meta
Normal file
@@ -0,0 +1,32 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0e17ee73ac07b4006a871da89b5103ae
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 0
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Android: Android
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
3321
sdk-intergration/Assets/Scenes/UnbindTest.unity
Normal file
3321
sdk-intergration/Assets/Scenes/UnbindTest.unity
Normal file
File diff suppressed because it is too large
Load Diff
7
sdk-intergration/Assets/Scenes/UnbindTest.unity.meta
Normal file
7
sdk-intergration/Assets/Scenes/UnbindTest.unity.meta
Normal file
@@ -0,0 +1,7 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e55d807d563854943a26ad6dadec548d
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
138
sdk-intergration/Assets/Scripts/UnbindTest.cs
Normal file
138
sdk-intergration/Assets/Scripts/UnbindTest.cs
Normal file
@@ -0,0 +1,138 @@
|
||||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using tysdk;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class UnbindTest : MonoBehaviour
|
||||
{
|
||||
[SerializeField]
|
||||
private Text message;
|
||||
[SerializeField]
|
||||
private Button cleanBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button initBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Dropdown accoutTypeDropdown;
|
||||
|
||||
[SerializeField]
|
||||
private Button loginBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button logoutBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button getSnsBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button checkSnsBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button bindBtn;
|
||||
|
||||
[SerializeField]
|
||||
private Button unbindBtn;
|
||||
|
||||
private EAccoutType accoutType;
|
||||
|
||||
private const string Cls = "com.unity3d.player.SnsTest";
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Start()
|
||||
{
|
||||
Screen.sleepTimeout = SleepTimeout.NeverSleep;
|
||||
message.text = string.Empty;
|
||||
accoutType = (EAccoutType)accoutTypeDropdown.value;
|
||||
|
||||
cleanBtn.onClick.AddListener(() => message.text = string.Empty);
|
||||
initBtn.onClick.AddListener(Init);
|
||||
accoutTypeDropdown.onValueChanged.AddListener((index) =>
|
||||
{
|
||||
accoutType = (EAccoutType)index;
|
||||
message.text += $"[Account Type] {accoutType.ToString()}\r\n";
|
||||
}); loginBtn.onClick.AddListener(OnLogin);
|
||||
logoutBtn.onClick.AddListener(OnLogout);
|
||||
getSnsBtn.onClick.AddListener(OnGetSns);
|
||||
checkSnsBtn.onClick.AddListener(OnCheckSns);
|
||||
bindBtn.onClick.AddListener(OnBind);
|
||||
unbindBtn.onClick.AddListener(OnUnbind);
|
||||
|
||||
Debug.Log("========== Init =============");
|
||||
TYSdkFacade.Instance.Init();
|
||||
|
||||
Debug.Log($"AccoutType {accoutType}");
|
||||
}
|
||||
|
||||
private void Init()
|
||||
{
|
||||
UnityBridgeFunc.UnityResetServerUrl("https://128-hwsfsdk-sdk-test01.qijihdhk.com");
|
||||
}
|
||||
|
||||
private void OnLogout()
|
||||
{
|
||||
Debug.Log("========== Logout =============");
|
||||
TYSdkFacade.Instance.Logout();
|
||||
}
|
||||
|
||||
private LoginInfo loginInfo;
|
||||
private async void OnLogin()
|
||||
{
|
||||
Debug.Log("========== Login =============");
|
||||
message.text += $"Login {accoutType}\r\n";
|
||||
var info = await TYSdkFacade.Instance.Login(accoutType);
|
||||
message.text = $"Login Success {info.isSuccess}\r\n";
|
||||
if(info.isSuccess)
|
||||
{
|
||||
loginInfo = info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void OnGetSns()
|
||||
{
|
||||
Debug.Log("========== Get SNS =============");
|
||||
using (var t = new AndroidJavaClass(Cls))
|
||||
{
|
||||
t.CallStatic("GetSns", accoutType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCheckSns()
|
||||
{
|
||||
Debug.Log("========== Check SNS =============");
|
||||
using (var t = new AndroidJavaClass(Cls))
|
||||
{
|
||||
t.CallStatic("CheckSns", accoutType.ToString());
|
||||
}
|
||||
}
|
||||
|
||||
private void OnBind()
|
||||
{
|
||||
Debug.Log("========== Bind =============");
|
||||
using (var t = new AndroidJavaClass(Cls))
|
||||
{
|
||||
t.CallStatic("Bind", accoutType.ToString(), loginInfo.StrUserId);
|
||||
}
|
||||
}
|
||||
|
||||
public void BindCallback(string message)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
private void OnUnbind()
|
||||
{
|
||||
using (var t = new AndroidJavaClass(Cls))
|
||||
{
|
||||
t.CallStatic("Unbind");
|
||||
}
|
||||
}
|
||||
|
||||
public void UnbindCallback(string message)
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
11
sdk-intergration/Assets/Scripts/UnbindTest.cs.meta
Normal file
11
sdk-intergration/Assets/Scripts/UnbindTest.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 52192be6b3a3b4555a714c7914c14c2b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user