update: [DMA] 完善 iOS 取值逻辑
parent
897f39e6d9
commit
1bfbce04f1
|
|
@ -1,26 +1,30 @@
|
|||
|
||||
|
||||
#if UNITY_IOS
|
||||
namespace Guru.Editor
|
||||
{
|
||||
using UnityEditor;
|
||||
using UnityEditor.Callbacks;
|
||||
using UnityEngine;
|
||||
using System.IO;
|
||||
using NUnit.Framework;
|
||||
using UnityEditor.iOS.Xcode;
|
||||
|
||||
public class PostBuild_DMA
|
||||
{
|
||||
|
||||
|
||||
public static bool DefaultValue = true; // 配置注入默认值
|
||||
|
||||
[PostProcessBuild]
|
||||
public static void OnPostProcessBuild(BuildTarget target, string buildPath)
|
||||
{
|
||||
if (target != BuildTarget.iOS) return;
|
||||
|
||||
SetInfoPlist(buildPath);
|
||||
}
|
||||
|
||||
#if UNITY_IOS
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// inject default values
|
||||
/// </summary>
|
||||
/// <param name="buildPath"></param>
|
||||
private static void SetInfoPlist(string buildPath)
|
||||
{
|
||||
var infoPlistPath = Path.Combine(buildPath, "Info.plist");
|
||||
|
|
@ -29,9 +33,21 @@ namespace Guru.Editor
|
|||
Debug.LogError("Info.plist not found");
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
var plist = new PlistDocument();
|
||||
plist.ReadFromFile(infoPlistPath);
|
||||
|
||||
var root = plist.root;
|
||||
root.SetBoolean("GADDelayAppMeasurementInit", true);
|
||||
//--------- set all default values ----------
|
||||
root.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_STORAGE", DefaultValue);
|
||||
root.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_ANALYTICS_STORAGE", DefaultValue);
|
||||
root.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_PERSONALIZATION_SIGNALS", DefaultValue);
|
||||
root.SetBoolean("GOOGLE_ANALYTICS_DEFAULT_ALLOW_AD_USER_DATA", DefaultValue);
|
||||
|
||||
plist.WriteToFile(infoPlistPath);
|
||||
|
||||
Debug.Log($"<color=#88ff00>[Post] consent has inject dma default values {DefaultValue} to {infoPlistPath} </color>");
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -157,6 +157,18 @@ extern "C" {
|
|||
gameobjectName = [NSString stringWithUTF8String:gameobject];
|
||||
callbackName = [NSString stringWithUTF8String:method];
|
||||
}
|
||||
|
||||
// 获取GDPR状态码
|
||||
const char* unityGetTCFValue(){
|
||||
NSString *purposeConsents = [NSUserDefaults.standardUserDefaults
|
||||
stringForKey:@"IABTCF_PurposeConsents"];
|
||||
|
||||
if( purposeConsents == nil){
|
||||
return "";
|
||||
}
|
||||
|
||||
return [U3DConsent stringToChar: purposeConsents];
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ namespace Guru
|
|||
private static void OnSDKCallback(string msg)
|
||||
{
|
||||
//-------- Fetch DMA status and report -----------
|
||||
var value = Agent?.GetDMAValue() ?? "";
|
||||
var value = Agent?.GetPurposesValue() ?? "";
|
||||
GoogleDMAHelper.SetDMAStatus(value, _dmaMapRule);
|
||||
|
||||
//------- message send to unity ----------
|
||||
|
|
|
|||
|
|
@ -4,6 +4,6 @@ namespace Guru
|
|||
{
|
||||
void Init(string objectName, string callbackName);
|
||||
void RequestGDPR(string deviceId = "", int debugGeography = -1);
|
||||
string GetDMAValue();
|
||||
string GetPurposesValue();
|
||||
}
|
||||
}
|
||||
|
|
@ -53,7 +53,7 @@ namespace Guru
|
|||
/// 获取 DMA 字段
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetDMAValue()
|
||||
public string GetPurposesValue()
|
||||
{
|
||||
#if UNITY_ANDROID
|
||||
if (!_initSuccess) return "";
|
||||
|
|
|
|||
|
|
@ -7,13 +7,13 @@ namespace Guru
|
|||
public class ConsentAgentIOS:IConsentAgent
|
||||
{
|
||||
private const string DLL_INTERNAL = "__Internal";
|
||||
|
||||
#if UNITY_IOS
|
||||
[DllImport(DLL_INTERNAL)]
|
||||
private static extern void unityRequestGDPR(string deviceId, int debugGeography); // IOS 调用接口
|
||||
|
||||
[DllImport(DLL_INTERNAL)]
|
||||
private static extern void unityInitSDK(string gameobject, string callback); // IOS 调用接口
|
||||
[DllImport(DLL_INTERNAL)]
|
||||
private static extern string unityGetTCFValue(); // 获取 TFC 值
|
||||
#endif
|
||||
|
||||
private string _objName;
|
||||
|
|
@ -47,10 +47,10 @@ namespace Guru
|
|||
/// 获取 DMA 字段
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetDMAValue()
|
||||
public string GetPurposesValue()
|
||||
{
|
||||
#if UNITY_IOS
|
||||
//TODO: ios return raw value
|
||||
return unityGetTCFValue();
|
||||
#endif
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ namespace Guru
|
|||
/// 获取 DMA 字段
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string GetDMAValue()
|
||||
public string GetPurposesValue()
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue