c1_unity/Assets/ThirdParty/AppsFlyer/AppsFlyerObjectScript.cs
2023-04-03 11:04:31 +08:00

74 lines
2.2 KiB
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using AppsFlyerSDK;
// This class is intended to be used the the AppsFlyerObject.prefab
public class AppsFlyerObjectScript : MonoBehaviour , IAppsFlyerConversionData
{
// These fields are set from the editor so do not modify!
//******************************//
public string devKey;
public string iosDevKey;
public string appID;
public string UWPAppID;
public bool isDebug;
public bool getConversionData;
//******************************//
void Start()
{
// These fields are set from the editor so do not modify!
//******************************//
AppsFlyer.waitForCustomerUserId(true);
AppsFlyer.setIsDebug(isDebug);
#if UNITY_WSA_10_0 && !UNITY_EDITOR
AppsFlyer.initSDK(devKey, UWPAppID, getConversionData ? this : null);
#elif UNITY_IOS && !UNITY_EDITOR
// Notice: After 6.6.0 use the follow code: https://github.com/AppsFlyerSDK/appsflyer-unity-plugin
AppsFlyeriOS.waitForATTUserAuthorizationWithTimeoutInterval(60);
AppsFlyer.initSDK(iosDevKey, appID, getConversionData ? this : null);
#else
AppsFlyer.initSDK(devKey, appID, getConversionData ? this : null);
#endif
//******************************/
AppsFlyer.startSDK();
}
void Update()
{
}
// Mark AppsFlyer CallBacks
public void onConversionDataSuccess(string conversionData)
{
AppsFlyer.AFLog("didReceiveConversionData", conversionData);
Dictionary<string, object> conversionDataDictionary = AppsFlyer.CallbackStringToDictionary(conversionData);
// add deferred deeplink logic here
}
public void onConversionDataFail(string error)
{
AppsFlyer.AFLog("didReceiveConversionDataWithError", error);
}
public void onAppOpenAttribution(string attributionData)
{
AppsFlyer.AFLog("onAppOpenAttribution", attributionData);
Dictionary<string, object> attributionDataDictionary = AppsFlyer.CallbackStringToDictionary(attributionData);
// add direct deeplink logic here
}
public void onAppOpenAttributionFailure(string error)
{
AppsFlyer.AFLog("onAppOpenAttributionFailure", error);
}
}