[F] Link [A] signout
This commit is contained in:
@@ -58,6 +58,7 @@ namespace tysdk.editor
|
||||
var entitlementsContent = File.ReadAllText("Packages/tysdk/Files/Unity-iPhone.entitlements");
|
||||
File.WriteAllText($"{root}/Unity-iPhone/Unity-iPhone.entitlements", entitlementsContent);
|
||||
|
||||
proj.AddCapability(target, PBXCapabilityType.SignInWithApple, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
proj.AddCapability(target, PBXCapabilityType.KeychainSharing, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
proj.AddCapability(target, PBXCapabilityType.PushNotifications, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
//proj.AddCapability(target, PBXCapabilityType.AssociatedDomains, "Unity-iPhone/Unity-iPhone.entitlements");
|
||||
@@ -69,6 +70,7 @@ namespace tysdk.editor
|
||||
proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-all_load");
|
||||
|
||||
target = proj.TargetGuidByName("UnityFramework");
|
||||
proj.SetBuildProperty(target, "ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES", "NO");
|
||||
proj.AddBuildProperty(target, "OTHER_LDFLAGS", "-ObjC");
|
||||
proj.AddFrameworkToProject(target, "AppTrackingTransparency.framework", false);
|
||||
|
||||
@@ -102,6 +104,16 @@ namespace tysdk.editor
|
||||
urlTypesArray = infoDict.values["CFBundleURLTypes"].AsArray();
|
||||
}
|
||||
|
||||
if (!infoDict.values.ContainsKey("NSUserActivityTypes")) {
|
||||
PlistElementArray userActivityTypes = infoDict.CreateArray("NSUserActivityTypes");
|
||||
userActivityTypes.AddString("INSendMessageIntent");
|
||||
}
|
||||
else
|
||||
{
|
||||
PlistElementArray userActivityTypes = infoDict.values["NSUserActivityTypes"].AsArray();
|
||||
userActivityTypes.AddString("INSendMessageIntent");
|
||||
}
|
||||
|
||||
PlistElementArray queriesSchemesArray = null;
|
||||
if (!infoDict.values.ContainsKey("LSApplicationQueriesSchemes")) {
|
||||
queriesSchemesArray = infoDict.CreateArray("LSApplicationQueriesSchemes");
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>com.apple.developer.applesignin</key>
|
||||
<array>
|
||||
<string>Default</string>
|
||||
</array>
|
||||
<key>com.apple.developer.usernotifications.communication</key>
|
||||
<true/>
|
||||
<key>keychain-access-groups</key>
|
||||
|
||||
15
sdk-intergration/Packages/tysdk/Plugins/iOS/RequestReview.mm
Normal file
15
sdk-intergration/Packages/tysdk/Plugins/iOS/RequestReview.mm
Normal file
@@ -0,0 +1,15 @@
|
||||
// iOSReview.m
|
||||
#import <Foundation/Foundation.h>
|
||||
#import <StoreKit/StoreKit.h>
|
||||
|
||||
extern "C" {
|
||||
void RequestReview(const char* customReviewURL) {
|
||||
if (@available(iOS 10.3, *)) {
|
||||
[SKStoreReviewController requestReview];
|
||||
} else {
|
||||
NSString *url = [NSString stringWithUTF8String:customReviewURL];
|
||||
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:url]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,37 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b9382ac867441064e988d90a52bad1ca
|
||||
PluginImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
iconMap: {}
|
||||
executionOrder: {}
|
||||
defineConstraints: []
|
||||
isPreloaded: 0
|
||||
isOverridable: 1
|
||||
isExplicitlyReferenced: 0
|
||||
validateReferences: 1
|
||||
platformData:
|
||||
- first:
|
||||
Any:
|
||||
second:
|
||||
enabled: 0
|
||||
settings: {}
|
||||
- first:
|
||||
Editor: Editor
|
||||
second:
|
||||
enabled: 0
|
||||
settings:
|
||||
DefaultValueInitialized: true
|
||||
- first:
|
||||
iPhone: iOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
- first:
|
||||
tvOS: tvOS
|
||||
second:
|
||||
enabled: 1
|
||||
settings: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -98,6 +98,15 @@ extern "C" {
|
||||
}];
|
||||
}
|
||||
|
||||
void UnityLoginByApple()
|
||||
{
|
||||
XYLoginReq *req = [XYLoginReq initWithLoginType:XYLoginWithApple];
|
||||
[XYApi XYLoginWith:req completionHandler:^(XYResp * _Nonnull resp) {
|
||||
NSLog(@"TYSdkInterface UnityLoginByApple: %@", resp);
|
||||
ProcessLoginResult(resp);
|
||||
}];
|
||||
}
|
||||
|
||||
void UnityGetIdentityFun(const char* type)
|
||||
{
|
||||
|
||||
@@ -138,6 +147,12 @@ extern "C" {
|
||||
[XYApi XYLogoutChannelWithType:XYLoginWithGuest];
|
||||
}
|
||||
|
||||
void UnityLogoutApple()
|
||||
{
|
||||
NSLog(@"TYSdkInterface UnityLogoutApple");
|
||||
[XYApi XYLogoutChannelWithType:XYLoginWithApple];
|
||||
}
|
||||
|
||||
//支付
|
||||
void UnityKnow(const char* userId,const char* productId,const char* productPrice,const char* productName,const char* productCount,const char* orderid,const char* appinfo)
|
||||
{
|
||||
@@ -294,4 +309,46 @@ extern "C" {
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void LinkApple()
|
||||
{
|
||||
|
||||
NSLog(@"TYSdkInterface LinkApple");
|
||||
NSDictionary * userDic = [XYApi XYGetCurrentUserDict];
|
||||
XYBindReq *bindReq = [XYBindReq initBindWithPlatform:XYBindApple UserId: [ [userDic objectForKey:@"userId"] unsignedIntegerValue]];
|
||||
[XYApi XYBindByBindReq:bindReq isUnbindGuest:@"false" completionHandler:^(XYResp * _Nonnull resp) {
|
||||
if(resp.errCode == XYSuccess)
|
||||
{
|
||||
NSLog(@"TYSdkInterface LinkApple Success");
|
||||
UnitySendMessage("TYSdkFacade","LinkAccoutResult", "1");
|
||||
}
|
||||
else
|
||||
{
|
||||
NSLog(@"TYSdkInterface LinkApple Faild");
|
||||
UnityLogoutFacebook();
|
||||
UnitySendMessage("TYSdkFacade","LinkAccoutResult", "0");
|
||||
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
void IsLinkedApple()
|
||||
{
|
||||
[XYApi CheckUserExist:XYBindApple completion:^(XYResp * _Nonnull resp) {
|
||||
if (resp.errCode == XYSNSExist) {
|
||||
UnitySendMessage("TYSdkFacade","CheckLinkResult", "1");
|
||||
}else if (resp.errCode == XYSNSNotExist){
|
||||
UnitySendMessage("TYSdkFacade","CheckLinkResult", "0");
|
||||
} else {
|
||||
UnitySendMessage("TYSdkFacade","CheckLinkResult", "-1");
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
void UnlinkApple()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using asap.core;
|
||||
using Newtonsoft.Json.Linq;
|
||||
@@ -24,7 +26,8 @@ namespace tysdk
|
||||
private static Dictionary<string, EAccoutType> accoutTypeMap = new Dictionary<string, EAccoutType>(){
|
||||
{"google", EAccoutType.hwGoogle},
|
||||
{"fb", EAccoutType.hwFacebook},
|
||||
{"tyGuest", EAccoutType.hwGuest}
|
||||
{"tyGuest", EAccoutType.hwGuest},
|
||||
{"ios13", EAccoutType.Apple}
|
||||
};
|
||||
#endif
|
||||
|
||||
@@ -262,6 +265,59 @@ namespace tysdk
|
||||
UnityBridgeFunc.SetGaUserInfo(strUserId);
|
||||
}
|
||||
|
||||
|
||||
#if UNITY_EDITOR
|
||||
public async Task<bool> LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
await Task.Delay(300);
|
||||
return true;
|
||||
}
|
||||
#elif UNITY_IOS
|
||||
|
||||
public async Task<bool> LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
if (_accountInfo == null) return false;
|
||||
if( _accountInfo.linkedAccout.Contains(accoutType)) return true;
|
||||
|
||||
var taskSource = new TaskCompletionSource<LinkResult>();
|
||||
callbacks.Add("LinkAccoutResult", (ITYSdkCallback callback) =>
|
||||
{
|
||||
taskSource.SetResult((LinkResult)callback);
|
||||
});
|
||||
|
||||
UnityBridgeFunc.LinkAccount(accoutType);
|
||||
|
||||
var result = await taskSource.Task;
|
||||
if (result.isSuccess)
|
||||
{
|
||||
var savedInfo = AccountInfo.GetSavedAccoutInfo();
|
||||
if(savedInfo != null)
|
||||
{
|
||||
savedInfo.AddLinkedAccount(accoutType);
|
||||
savedInfo.Save();
|
||||
_accountInfo = savedInfo;
|
||||
}
|
||||
}
|
||||
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
public void LinkAccoutResult(string codestr)
|
||||
{
|
||||
var result = new LinkResult()
|
||||
{
|
||||
isSuccess = codestr == "1"
|
||||
};
|
||||
|
||||
if (callbacks.TryGetValue("LinkAccoutResult", out var action))
|
||||
{
|
||||
action.Invoke(result);
|
||||
callbacks.Remove("LoginResult");
|
||||
}
|
||||
}
|
||||
|
||||
#elif UNITY_ANDROID
|
||||
|
||||
public async Task<bool> LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
if (_accountInfo == null) return false;
|
||||
@@ -280,6 +336,8 @@ namespace tysdk
|
||||
return result.isSuccess;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// 检查是否已经绑定
|
||||
/// <returns>
|
||||
@@ -327,5 +385,91 @@ namespace tysdk
|
||||
callbacks.Remove("CheckLinkResult");
|
||||
}
|
||||
}
|
||||
|
||||
public void Signout()
|
||||
{
|
||||
List<string> list = new List<string>();
|
||||
string defaultTyurl = "https://128-hwsfsdk-sdk-online01.qijihdhk.com";
|
||||
|
||||
IConfig config = GContext.container.Resolve<IConfig>();
|
||||
var tyurl = config.Get<string>("AGG_SERVER", defaultTyurl);
|
||||
|
||||
|
||||
string tycs = tyurl == defaultTyurl ?
|
||||
"https://hwcsh.tygameworld.com /template/appCancel/note.html"
|
||||
:
|
||||
"https://customermanage-feature-test-web-test.tuyougame.cn/appCancel/note.html";
|
||||
|
||||
string sdkurl = $"sdkurl={tyurl}";
|
||||
list.Add(sdkurl);
|
||||
|
||||
string appid = "appid=20587";
|
||||
list.Add(appid);
|
||||
|
||||
#if UNITY_ANDROID
|
||||
string clientid = "Android_5.00_tyGuest,facebook.googleplay.0-hall20587.googleplay.FishingMaster";
|
||||
#elif UNITY_IOS
|
||||
string clientid = "IOS_5.00_tyGuest,facebook,appStore.appStore.0-hall20587.appStore.FishingMaster";
|
||||
#endif
|
||||
list.Add($"clientid={clientid}");
|
||||
|
||||
string uid = $"uid={_accountInfo.userId}";
|
||||
list.Add(uid);
|
||||
|
||||
string roleid = "roleid=0";
|
||||
list.Add(roleid);
|
||||
|
||||
string gameid = "gameid=20587";
|
||||
list.Add(gameid);
|
||||
|
||||
string cloudid = "cloudid=128";
|
||||
list.Add(cloudid);
|
||||
|
||||
string gamename = "gamename=FishingTravel";
|
||||
list.Add(gamename);
|
||||
|
||||
string certification = "certification=0";
|
||||
list.Add(certification);
|
||||
|
||||
string ischannel = "ischannel=1";
|
||||
list.Add(ischannel);
|
||||
|
||||
string tysdktoken = $"tysdktoken={_accountInfo.token}";
|
||||
list.Add(tysdktoken);
|
||||
|
||||
list.Sort();
|
||||
|
||||
string listStr = string.Join("&", list.ToArray());
|
||||
string sign = listStr +
|
||||
"csh-api-6dfa879490a249be9fbc92e97e4d898d-api-csh";
|
||||
//对sign进行MD5加密
|
||||
string signMd5 = CalculateMD5Hash(sign);
|
||||
string url = $"{tycs}?{listStr}&sign={signMd5}&isAbroad=1";
|
||||
Debug.Log($"[TYSdkFacade:Signout] url \n{url}");
|
||||
Application.OpenURL(url);
|
||||
}
|
||||
|
||||
private string CalculateMD5Hash(string input)
|
||||
{
|
||||
// Create a new instance of the MD5CryptoServiceProvider object.
|
||||
MD5 md5Hasher = MD5.Create();
|
||||
|
||||
// Convert the input string to a byte array and compute the hash.
|
||||
byte[] data = md5Hasher.ComputeHash(Encoding.Default.GetBytes(input));
|
||||
|
||||
// Create a new Stringbuilder to collect the bytes
|
||||
// and create a string.
|
||||
StringBuilder sBuilder = new StringBuilder();
|
||||
|
||||
// Loop through each byte of the hashed data
|
||||
// and format each one as a hexadecimal string.
|
||||
for (int i = 0; i < data.Length; i++)
|
||||
{
|
||||
sBuilder.Append(data[i].ToString("x2"));
|
||||
}
|
||||
|
||||
// Return the hexadecimal string.
|
||||
return sBuilder.ToString();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ namespace tysdk
|
||||
hwGoogle,
|
||||
hwFacebook,
|
||||
hwGuest,
|
||||
#if UNITY_IOS
|
||||
Apple,
|
||||
#endif
|
||||
none
|
||||
}
|
||||
|
||||
@@ -23,6 +26,11 @@ namespace tysdk
|
||||
public int code;
|
||||
}
|
||||
|
||||
public class LinkResult : ITYSdkCallback
|
||||
{
|
||||
public bool isSuccess;
|
||||
}
|
||||
|
||||
public class LinkCheckInfo : ITYSdkCallback
|
||||
{
|
||||
public int code;
|
||||
|
||||
@@ -220,6 +220,9 @@ namespace tysdk
|
||||
case EAccoutType.hwGuest:
|
||||
UnityLoginByGuest();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
UnityLoginByApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -232,6 +235,9 @@ namespace tysdk
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByFacebook();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityLoginByApple();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
public static extern void UnityGetIdentityFun(string type);
|
||||
|
||||
@@ -251,6 +257,9 @@ namespace tysdk
|
||||
case EAccoutType.hwGuest:
|
||||
UnityLogoutGuest();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
UnityLogoutApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -263,6 +272,9 @@ namespace tysdk
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UnityLogoutGuest();
|
||||
|
||||
[DllImport("__Internal")]
|
||||
private static extern void UnityLogoutApple();
|
||||
|
||||
public static void LinkAccount(EAccoutType accoutType)
|
||||
{
|
||||
switch (accoutType)
|
||||
@@ -273,6 +285,9 @@ namespace tysdk
|
||||
case EAccoutType.hwFacebook:
|
||||
LinkFacebook();
|
||||
break;
|
||||
case EAccoutType.Apple:
|
||||
LinkApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,6 +308,8 @@ namespace tysdk
|
||||
[DllImport("__Internal")] private static extern void UnlinkGoogle();
|
||||
[DllImport("__Internal")] private static extern void LinkFacebook();
|
||||
[DllImport("__Internal")] private static extern void UnlinkFacebook();
|
||||
[DllImport("__Internal")] private static extern void LinkApple();
|
||||
[DllImport("__Internal")] private static extern void UnlinkApple();
|
||||
|
||||
public static void LinkCheck(EAccoutType accoutType)
|
||||
{
|
||||
@@ -304,11 +321,16 @@ namespace tysdk
|
||||
case EAccoutType.hwFacebook:
|
||||
IsLinkedFacebook();
|
||||
break;
|
||||
|
||||
case EAccoutType.Apple:
|
||||
IsLinkedApple();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
[DllImport("__Internal")] private static extern void IsLinkedGoogle();
|
||||
[DllImport("__Internal")] private static extern void IsLinkedFacebook();
|
||||
[DllImport("__Internal")] private static extern void IsLinkedApple();
|
||||
|
||||
|
||||
//支付
|
||||
|
||||
Reference in New Issue
Block a user