fix:1、接入合作方的sdk。2、支付逻辑接入sdk中的接口

This commit is contained in:
2026-05-09 09:37:34 +08:00
parent 1599bf4bbb
commit ee55c03120
1011 changed files with 167108 additions and 33552 deletions
+2 -7
View File
@@ -10,24 +10,19 @@ namespace AppsFlyerSDK
}
/// <summary>
//
/// Purchase details class matching Android SDK AFPurchaseDetails
/// </summary>
public class AFPurchaseDetailsAndroid
{
public AFPurchaseType purchaseType { get; private set; }
public string purchaseToken { get; private set; }
public string productId { get; private set; }
public string price { get; private set; }
public string currency { get; private set; }
public AFPurchaseDetailsAndroid(AFPurchaseType type, String purchaseToken, String productId, String price, String currency)
public AFPurchaseDetailsAndroid(AFPurchaseType type, String purchaseToken, String productId)
{
this.purchaseType = type;
this.purchaseToken = purchaseToken;
this.productId = productId;
this.price = price;
this.currency = currency;
}
}
+15 -8
View File
@@ -4,26 +4,33 @@ using System.Collections.Generic;
namespace AppsFlyerSDK
{
/// <summary>
//
/// Purchase type enum matching iOS SDK AFSDKPurchaseType
/// </summary>
public enum AFSDKPurchaseType
{
Subscription,
OneTimePurchase
}
/// <summary>
/// Purchase details class matching iOS SDK AFSDKPurchaseDetails
/// </summary>
public class AFSDKPurchaseDetailsIOS
{
public string productId { get; private set; }
public string price { get; private set; }
public string currency { get; private set; }
public string transactionId { get; private set; }
public AFSDKPurchaseType purchaseType { get; private set; }
private AFSDKPurchaseDetailsIOS(string productId, string price, string currency, string transactionId)
private AFSDKPurchaseDetailsIOS(string productId, string transactionId, AFSDKPurchaseType purchaseType)
{
this.productId = productId;
this.price = price;
this.currency = currency;
this.transactionId = transactionId;
this.purchaseType = purchaseType;
}
public static AFSDKPurchaseDetailsIOS Init(string productId, string price, string currency, string transactionId)
public static AFSDKPurchaseDetailsIOS Init(string productId, string transactionId, AFSDKPurchaseType purchaseType)
{
return new AFSDKPurchaseDetailsIOS(productId, price, currency, transactionId);
return new AFSDKPurchaseDetailsIOS(productId, transactionId, purchaseType);
}
}
+21 -7
View File
@@ -6,7 +6,7 @@ namespace AppsFlyerSDK
{
public class AppsFlyer : MonoBehaviour
{
public static readonly string kAppsFlyerPluginVersion = "6.17.1";
public static readonly string kAppsFlyerPluginVersion = "6.17.91";
public static string CallBackObjectName = null;
private static EventHandler onRequestResponse;
private static EventHandler onInAppResponse;
@@ -768,6 +768,11 @@ namespace AppsFlyerSDK
}
}
/// <summary>
/// [Deprecated] Validates an in-app purchase on iOS.
/// Use the V2 overload with AFSDKPurchaseDetailsIOS instead.
/// </summary>
[System.Obsolete("This method is deprecated. Use validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject) instead.")]
public static void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string transactionId, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)
{
if (instance != null && instance is IAppsFlyerIOSBridge)
@@ -777,16 +782,23 @@ namespace AppsFlyerSDK
}
}
// V2
public static void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> extraEventValues, MonoBehaviour gameObject)
/// <summary>
/// Validates an in-app purchase on iOS using the V2 API.
/// </summary>
public static void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject)
{
if (instance != null && instance is IAppsFlyerIOSBridge)
{
IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance;
appsFlyeriOSInstance.validateAndSendInAppPurchase(details, extraEventValues, gameObject);
appsFlyeriOSInstance.validateAndSendInAppPurchase(details, purchaseAdditionalDetails, gameObject);
}
}
/// <summary>
/// [Deprecated] Validates an in-app purchase on Android.
/// Use the V2 overload with AFPurchaseDetailsAndroid instead.
/// </summary>
[System.Obsolete("This method is deprecated. Use validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject) instead.")]
public static void validateAndSendInAppPurchase(string publicKey, string signature, string purchaseData, string price, string currency, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)
{
if (instance != null && instance is IAppsFlyerAndroidBridge)
@@ -796,13 +808,15 @@ namespace AppsFlyerSDK
}
}
// V2
public static void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)
/// <summary>
/// Validates an in-app purchase on Android using the V2 API.
/// </summary>
public static void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject)
{
if (instance != null && instance is IAppsFlyerAndroidBridge)
{
IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance;
appsFlyerAndroidInstance.validateAndSendInAppPurchase(details, additionalParameters, gameObject);
appsFlyerAndroidInstance.validateAndSendInAppPurchase(details, purchaseAdditionalDetails, gameObject);
}
}
+6 -5
View File
@@ -484,7 +484,7 @@ namespace AppsFlyerSDK
}
/// <summary>
/// API for server verification of in-app purchases.
/// [Deprecated] API for server verification of in-app purchases - please use V2 with AFPurchaseDetailsAndroid instead.
/// An af_purchase event with the relevant values will be automatically sent if the validation is successful.
/// </summary>
/// <param name="publicKey">License Key obtained from the Google Play Console.</param>
@@ -493,6 +493,7 @@ namespace AppsFlyerSDK
/// <param name="price">Purchase price, should be derived from <code>skuDetails.getStringArrayList("DETAILS_LIST")</code></param>
/// <param name="currency">Purchase currency, should be derived from <code>skuDetails.getStringArrayList("DETAILS_LIST")</code></param>
/// <param name="additionalParameters">additionalParameters Freehand parameters to be sent with the purchase (if validated).</param>
[System.Obsolete("This method is deprecated. Use validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject) instead.")]
public void validateAndSendInAppPurchase(string publicKey, string signature, string purchaseData, string price, string currency, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)
{
#if !UNITY_EDITOR
@@ -501,15 +502,15 @@ namespace AppsFlyerSDK
}
/// <summary>
/// API for server verification of in-app purchases.
/// V2 - API for server verification of in-app purchases.
/// An af_purchase event with the relevant values will be automatically sent if the validation is successful.
/// </summary>
/// <param name="details">AFPurchaseDetailsAndroid instance.</param>
/// <param name="additionalParameters">additionalParameters Freehand parameters to be sent with the purchase (if validated).</param>
public void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)
/// <param name="purchaseAdditionalDetails">purchaseAdditionalDetails Freehand parameters to be sent with the purchase (if validated).</param>
public void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject)
{
#if !UNITY_EDITOR
appsFlyerAndroid.CallStatic("validateAndTrackInAppPurchaseV2", (int)details.purchaseType, details.purchaseToken, details.productId, details.price, details.currency, convertDictionaryToJavaMap(additionalParameters), gameObject ? gameObject.name : null);
appsFlyerAndroid.CallStatic("validateAndTrackInAppPurchaseV2", (int)details.purchaseType, details.purchaseToken, details.productId, convertDictionaryToJavaMap(purchaseAdditionalDetails), gameObject ? gameObject.name : null);
#endif
}
+7 -7
View File
@@ -335,13 +335,14 @@ public void startSDK(bool shouldCallback, string CallBackObjectName)
}
/// <summary>
/// To send and validate in app purchases you can call this method from the processPurchase method - please use v2.
/// [Deprecated] To send and validate in app purchases - please use V2 with AFSDKPurchaseDetailsIOS instead.
/// </summary>
/// <param name="productIdentifier">The product identifier.</param>
/// <param name="price">The product price.</param>
/// <param name="currency">The product currency.</param>
/// <param name="transactionId">The purchase transaction Id.</param>
/// <param name="additionalParameters">The additional param, which you want to receive it in the raw reports.</param>
[System.Obsolete("This method is deprecated. Use validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject) instead.")]
public void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string transactionId, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)
{
#if !UNITY_EDITOR
@@ -350,15 +351,14 @@ public void startSDK(bool shouldCallback, string CallBackObjectName)
}
/// <summary>
/// V2
/// To send and validate in app purchases you can call this method from the processPurchase method.
/// V2 - To send and validate in app purchases you can call this method from the processPurchase method.
/// </summary>
/// <param name="details">The AFSDKPurchaseDetailsIOS instance.</param>
/// <param name="extraEventValues">The extra params, which you want to receive it in the raw reports.</param>
public void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> extraEventValues, MonoBehaviour gameObject)
/// <param name="purchaseAdditionalDetails">The additional params, which you want to receive it in the raw reports.</param>
public void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject)
{
#if !UNITY_EDITOR
_validateAndSendInAppPurchaseV2(details.productId, details.price, details.currency, details.transactionId, AFMiniJSON.Json.Serialize(extraEventValues), gameObject ? gameObject.name : null);
_validateAndSendInAppPurchaseV2(details.productId, details.transactionId, (int)details.purchaseType, AFMiniJSON.Json.Serialize(purchaseAdditionalDetails), gameObject ? gameObject.name : null);
#endif
}
@@ -843,7 +843,7 @@ public void startSDK(bool shouldCallback, string CallBackObjectName)
#elif UNITY_STANDALONE_OSX
[DllImport("AppsFlyerBundle")]
#endif
private static extern void _validateAndSendInAppPurchaseV2(string product, string price, string currency, string transactionId, string extraEventValues, string objectName);
private static extern void _validateAndSendInAppPurchaseV2(string product, string transactionId, int purchaseType, string purchaseAdditionalDetails, string objectName);
#if UNITY_IOS
[DllImport("__Internal")]
@@ -2,15 +2,15 @@
<dependencies>
<androidPackages>
<androidPackage spec="com.appsflyer:af-android-sdk:6.17.0"></androidPackage>
<androidPackage spec="com.appsflyer:unity-wrapper:6.17.0"></androidPackage>
<androidPackage spec="com.appsflyer:af-android-sdk:6.17.6"></androidPackage>
<androidPackage spec="com.appsflyer:unity-wrapper:6.17.91"></androidPackage>
<androidPackage spec="com.android.installreferrer:installreferrer:2.1"></androidPackage>
<androidPackage spec="com.appsflyer:purchase-connector:2.1.0"></androidPackage>
<androidPackage spec="com.appsflyer:purchase-connector:2.2.0"></androidPackage>
</androidPackages>
<iosPods>
<iosPod name="AppsFlyerFramework" version="6.17.1" minTargetSdk="12.0"></iosPod>
<iosPod name="PurchaseConnector" version="6.17.1" minTargetSdk="12.0"></iosPod>
<iosPod name="AppsFlyerFramework" version="6.17.9" minTargetSdk="12.0"></iosPod>
<iosPod name="PurchaseConnector" version="6.17.9" minTargetSdk="12.0"></iosPod>
</iosPods>
</dependencies>
@@ -31,7 +31,7 @@ public class AppsFlyerObjectEditor : Editor
{
serializedObject.Update();
GUILayout.Box((Texture)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("appsflyer_logo")[0]), typeof(Texture)), new GUILayoutOption[] { GUILayout.Width(600) });
DrawLogo();
EditorGUILayout.Separator();
EditorGUILayout.HelpBox("Set your devKey and appID to init the AppsFlyer SDK and start tracking. You must modify these fields and provide:\ndevKey - Your application devKey provided by AppsFlyer.\nappId - For iOS only. Your iTunes Application ID.\nUWP app id - For UWP only. Your application app id \nMac OS app id - For MacOS app only.", MessageType.Info);
@@ -80,5 +80,25 @@ public class AppsFlyerObjectEditor : Editor
serializedObject.ApplyModifiedProperties();
}
private void DrawLogo()
{
var guids = AssetDatabase.FindAssets("appsflyer_logo");
if (guids.Length == 0) return;
Texture logo = (Texture)AssetDatabase.LoadAssetAtPath(
AssetDatabase.GUIDToAssetPath(guids[0]),
typeof(Texture));
if (logo == null) return;
float maxWidth = Mathf.Min(200, EditorGUIUtility.currentViewWidth - 40);
float aspect = (float)logo.height / logo.width;
float height = maxWidth * aspect;
Rect rect = GUILayoutUtility.GetRect(maxWidth, height, GUILayout.ExpandWidth(false));
rect.x = (EditorGUIUtility.currentViewWidth - maxWidth) * 0.5f;
rect.width = maxWidth;
GUI.DrawTexture(rect, logo, ScaleMode.ScaleToFit);
}
}
Binary file not shown.

Before

Width:  |  Height:  |  Size: 9.2 KiB

After

Width:  |  Height:  |  Size: 7.0 KiB

+1 -1
View File
@@ -22,7 +22,7 @@ namespace AppsFlyerSDK
string getAttributionId();
void handlePushNotifications();
void validateAndSendInAppPurchase(string publicKey, string signature, string purchaseData, string price, string currency, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject);
void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject);
void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject);
void setCollectOaid(bool isCollect);
void setDisableAdvertisingIdentifiers(bool disable);
void setDisableNetworkData(bool disable);
+1 -1
View File
@@ -14,7 +14,7 @@ namespace AppsFlyerSDK
void setUseReceiptValidationSandbox(bool useReceiptValidationSandbox);
void setUseUninstallSandbox(bool useUninstallSandbox);
void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string transactionId, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject);
void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> extraEventValues, MonoBehaviour gameObject);
void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary<string, string> purchaseAdditionalDetails, MonoBehaviour gameObject);
void registerUninstall(byte[] deviceToken);
void handleOpenUrl(string url, string sourceApplication, string annotation);
void waitForATTUserAuthorizationWithTimeoutInterval(int timeoutInterval);
@@ -22,6 +22,11 @@ PluginImporter:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
VisionOS: VisionOS
second:
enabled: 1
settings: {}
- first:
iPhone: iOS
second:
+16 -8
View File
@@ -34,14 +34,22 @@ static const char* stringFromdictionary(NSDictionary* dictionary) {
static NSDictionary* dictionaryFromNSError(NSError* error) {
if(error){
NSInteger code = [error code];
NSString *localizedDescription = [error localizedDescription];
NSDictionary *errorDictionary = @{
@"code" : @(code) ?: @(-1),
@"localizedDescription" : localizedDescription,
};
return errorDictionary;
NSMutableDictionary *errorDictionary = [NSMutableDictionary dictionary];
errorDictionary[@"code"] = @(error.code);
errorDictionary[@"localizedDescription"] = error.localizedDescription ?: @"";
// Include userInfo fields for enhanced error reporting (iOS SDK 6.17.8+)
if (error.userInfo[@"error_code"]) {
errorDictionary[@"error_code"] = error.userInfo[@"error_code"];
}
if (error.userInfo[@"error_message"]) {
errorDictionary[@"error_message"] = error.userInfo[@"error_message"];
}
if (error.userInfo[@"invalid_fields"]) {
errorDictionary[@"invalid_fields"] = error.userInfo[@"invalid_fields"];
}
return errorDictionary;
}
return nil;
@@ -33,7 +33,7 @@ extern "C" {
const void _startSDK(bool shouldCallback, const char* objectName) {
[[AppsFlyerLib shared] setPluginInfoWith: AFSDKPluginUnity
pluginVersion:@"6.17.1"
pluginVersion:@"6.17.91"
additionalParams:nil];
startRequestObjectName = stringFromChar(objectName);
AppsFlyeriOSWarpper.didCallStart = YES;
@@ -288,21 +288,19 @@ extern "C" {
}];
}
const void _validateAndSendInAppPurchaseV2 (const char* product, const char* price, const char* currency, const char* transactionId, const char* extraEventValues, const char* objectName) {
const void _validateAndSendInAppPurchaseV2 (const char* product, const char* transactionId, int purchaseType, const char* purchaseAdditionalDetails, const char* objectName) {
validateAndLogObjectName = stringFromChar(objectName);
AFSDKPurchaseDetails *details = [[AFSDKPurchaseDetails alloc] initWithProductId:stringFromChar(product) price:stringFromChar(price) currency:stringFromChar(currency) transactionId:stringFromChar(transactionId)];
AFSDKPurchaseDetails *details = [[AFSDKPurchaseDetails alloc] initWithProductId:stringFromChar(product) transactionId:stringFromChar(transactionId) purchaseType:(AFSDKPurchaseType)purchaseType];
[[AppsFlyerLib shared]
validateAndLogInAppPurchase:details
extraEventValues:dictionaryFromJson(extraEventValues)
completionHandler:^(AFSDKValidateAndLogResult * _Nullable result) {
if (result.status == AFSDKValidateAndLogStatusSuccess) {
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_CALLBACK, stringFromdictionary(result.result));
} else if (result.status == AFSDKValidateAndLogStatusFailure) {
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_CALLBACK, stringFromdictionary(result.errorData));
purchaseAdditionalDetails:dictionaryFromJson(purchaseAdditionalDetails)
completion:^(NSDictionary * _Nullable response, NSError * _Nullable error) {
if (error) {
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_ERROR_CALLBACK, stringFromdictionary(dictionaryFromNSError(error)));
} else {
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_ERROR_CALLBACK, stringFromdictionary(dictionaryFromNSError(result.error)));
unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_CALLBACK, stringFromdictionary(response));
}
}];
+8
View File
@@ -0,0 +1,8 @@
fileFormatVersion: 2
guid: 1f19f272c71674582bed1d93925da003
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 7b5b4579db85b4cfd8395bfb19aa309e
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
Binary file not shown.
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 642cf65ed2573419bab7e7d44fc73181
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: 3a5ccbd864ba94a9a9ba47895ff14922
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
@@ -0,0 +1,33 @@
fileFormatVersion: 2
guid: ee45ae2608f3c44d08fc6e21a94d133f
PluginImporter:
externalObjects: {}
serializedVersion: 2
iconMap: {}
executionOrder: {}
defineConstraints: []
isPreloaded: 0
isOverridable: 0
isExplicitlyReferenced: 0
validateReferences: 1
platformData:
- first:
Any:
second:
enabled: 1
settings: {}
- first:
Editor: Editor
second:
enabled: 0
settings:
DefaultValueInitialized: true
- first:
Windows Store Apps: WindowsStoreApps
second:
enabled: 0
settings:
CPU: AnyCPU
userData:
assetBundleName:
assetBundleVariant:
+24
View File
@@ -0,0 +1,24 @@
{
"name": "Tests",
"references": [
"UnityEngine.TestRunner",
"UnityEditor.TestRunner",
"AppsFlyer"
],
"includePlatforms": [],
"excludePlatforms": [],
"allowUnsafeCode": false,
"overrideReferences": true,
"precompiledReferences": [
"nunit.framework.dll",
"NSubstitute.dll",
"Castle.Core.dll",
"System.Threading.Tasks.Extensions.dll"
],
"autoReferenced": false,
"defineConstraints": [
"UNITY_INCLUDE_TESTS"
],
"versionDefines": [],
"noEngineReferences": false
}
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: 1f155a0e4c9ab48eeb4b54b2dc0aeba7
AssemblyDefinitionImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+810
View File
@@ -0,0 +1,810 @@
using System.Collections.Generic;
using NUnit.Framework;
using UnityEngine;
using NSubstitute;
namespace AppsFlyerSDK.Tests
{
public class NewTestScript
{
[Test]
public void test_startSDK_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.startSDK();
AppsFlyerMOCKInterface.Received().startSDK(Arg.Any<bool>(), Arg.Any<string>());
}
[Test]
public void test_sendEvent_withValues()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
var eventParams = new Dictionary<string, string>();
eventParams.Add("key", "value");
AppsFlyer.sendEvent("testevent", eventParams);
AppsFlyerMOCKInterface.Received().sendEvent("testevent", eventParams, false, null);
}
[Test]
public void test_sendEvent_withNullParams()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.sendEvent("testevent", null);
AppsFlyerMOCKInterface.Received().sendEvent("testevent", null,false, null);
}
[Test]
public void test_isSDKStopped_true()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.stopSDK(true);
AppsFlyerMOCKInterface.Received().stopSDK(true);
}
[Test]
public void test_isSDKStopped_false()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.stopSDK(false);
AppsFlyerMOCKInterface.Received().stopSDK(false);
}
[Test]
public void test_isSDKStopped_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
var isSDKStopped = AppsFlyer.isSDKStopped();
AppsFlyerMOCKInterface.Received().isSDKStopped();
}
[Test]
public void test_isSDKStopped_receveivedFalse()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
var isSDKStopped = AppsFlyer.isSDKStopped();
Assert.AreEqual(AppsFlyerMOCKInterface.Received().isSDKStopped(), false);
}
[Test]
public void test_getSdkVersion_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.getSdkVersion();
AppsFlyerMOCKInterface.Received().getSdkVersion();
}
[Test]
public void test_setCustomerUserId_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setCustomerUserId("test");
AppsFlyerMOCKInterface.Received().setCustomerUserId("test");
}
[Test]
public void Test_setAppInviteOneLinkID_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setAppInviteOneLinkID("2f36");
AppsFlyerMOCKInterface.Received().setAppInviteOneLinkID("2f36");
}
[Test]
public void Test_setAdditionalData_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
var customData = new Dictionary<string, string>();
customData.Add("test", "test");
AppsFlyer.setAdditionalData(customData);
AppsFlyerMOCKInterface.Received().setAdditionalData(customData);
}
[Test]
public void Test_setResolveDeepLinkURLs_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setResolveDeepLinkURLs("url1", "url2");
AppsFlyerMOCKInterface.Received().setResolveDeepLinkURLs("url1", "url2");
}
[Test]
public void Test_setOneLinkCustomDomain_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setOneLinkCustomDomain("url1", "url2");
AppsFlyerMOCKInterface.Received().setOneLinkCustomDomain("url1", "url2");
}
[Test]
public void Test_setCurrencyCode_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setCurrencyCode("usd");
AppsFlyerMOCKInterface.Received().setCurrencyCode("usd");
}
[Test]
public void Test_recordLocation_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.recordLocation(0.3, 5.2);
AppsFlyerMOCKInterface.Received().recordLocation(0.3, 5.2);
}
[Test]
public void Test_anonymizeUser_true()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.anonymizeUser(true);
AppsFlyerMOCKInterface.Received().anonymizeUser(true);
}
[Test]
public void Test_anonymizeUser_false()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.anonymizeUser(false);
AppsFlyerMOCKInterface.Received().anonymizeUser(false);
}
[Test]
public void Test_getAppsFlyerId_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.getAppsFlyerId();
AppsFlyerMOCKInterface.Received().getAppsFlyerId();
}
[Test]
public void Test_setMinTimeBetweenSessions_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setMinTimeBetweenSessions(3);
AppsFlyerMOCKInterface.Received().setMinTimeBetweenSessions(3);
}
[Test]
public void Test_setHost_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setHost("prefix", "name");
AppsFlyerMOCKInterface.Received().setHost("prefix", "name");
}
[Test]
public void Test_setPhoneNumber_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setPhoneNumber("002");
AppsFlyerMOCKInterface.Received().setPhoneNumber("002");
}
[Test]
[System.Obsolete]
public void Test_setSharingFilterForAllPartners_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setSharingFilterForAllPartners();
AppsFlyerMOCKInterface.Received().setSharingFilterForAllPartners();
}
[Test]
[System.Obsolete]
public void Test_setSharingFilter_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setSharingFilter("filter1", "filter2");
AppsFlyerMOCKInterface.Received().setSharingFilter("filter1", "filter2");
}
[Test]
public void Test_getConversionData_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.getConversionData("ObjectName");
AppsFlyerMOCKInterface.Received().getConversionData("ObjectName");
}
[Test]
public void Test_attributeAndOpenStore_called_withParams()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("af_sub1", "val");
parameters.Add("custom_param", "val2");
AppsFlyer.attributeAndOpenStore("appid", "campaign", parameters, new MonoBehaviour());
AppsFlyerMOCKInterface.Received().attributeAndOpenStore("appid", "campaign", parameters, Arg.Any<MonoBehaviour>());
}
[Test]
public void Test_attributeAndOpenStore_called_nullParams()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.attributeAndOpenStore("appid", "campaign", null, new MonoBehaviour());
AppsFlyerMOCKInterface.Received().attributeAndOpenStore("appid", "campaign", null, Arg.Any<MonoBehaviour>());
}
[Test]
public void Test_recordCrossPromoteImpression_calledWithParameters()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
Dictionary<string, string> parameters = new Dictionary<string, string>();
parameters.Add("af_sub1", "val");
parameters.Add("custom_param", "val2");
AppsFlyer.recordCrossPromoteImpression("appid", "campaign", parameters);
AppsFlyerMOCKInterface.Received().recordCrossPromoteImpression("appid", "campaign", parameters);
}
[Test]
public void Test_recordCrossPromoteImpression_calledWithoutParameters()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.recordCrossPromoteImpression("appid", "campaign", null);
AppsFlyerMOCKInterface.Received().recordCrossPromoteImpression("appid", "campaign", null);
}
[Test]
public void Test_generateUserInviteLink_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.generateUserInviteLink(new Dictionary<string, string>(), new MonoBehaviour());
AppsFlyerMOCKInterface.Received().generateUserInviteLink(Arg.Any<Dictionary<string, string>>(), Arg.Any<MonoBehaviour>());
}
[Test]
public void Test_addPushNotificationDeepLinkPath_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerNativeBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.addPushNotificationDeepLinkPath("path1", "path2");
AppsFlyerMOCKInterface.Received().addPushNotificationDeepLinkPath("path1", "path2");
}
#if UNITY_ANDROID
[Test]
public void updateServerUninstallToken_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.updateServerUninstallToken("tokenTest");
AppsFlyerMOCKInterface.Received().updateServerUninstallToken("tokenTest");
}
[Test]
public void setImeiData_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setImeiData("imei");
AppsFlyerMOCKInterface.Received().setImeiData("imei");
}
[Test]
public void setAndroidIdData_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setAndroidIdData("androidId");
AppsFlyerMOCKInterface.Received().setAndroidIdData("androidId");
}
[Test]
public void waitForCustomerUserId_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.waitForCustomerUserId(true);
AppsFlyerMOCKInterface.Received().waitForCustomerUserId(true);
}
[Test]
public void setCustomerIdAndStartSDK_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setCustomerIdAndStartSDK("01234");
AppsFlyerMOCKInterface.Received().setCustomerIdAndStartSDK("01234");
}
[Test]
public void getOutOfStore_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.getOutOfStore();
AppsFlyerMOCKInterface.Received().getOutOfStore();
}
[Test]
public void setOutOfStore_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setOutOfStore("test");
AppsFlyerMOCKInterface.Received().setOutOfStore("test");
}
[Test]
public void setCollectAndroidID_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setCollectAndroidID(true);
AppsFlyerMOCKInterface.Received().setCollectAndroidID(true);
}
[Test]
public void setCollectIMEI_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setCollectIMEI(true);
AppsFlyerMOCKInterface.Received().setCollectIMEI(true);
}
[Test]
public void setIsUpdate_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setIsUpdate(true);
AppsFlyerMOCKInterface.Received().setIsUpdate(true);
}
[Test]
public void setPreinstallAttribution_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setPreinstallAttribution("mediaSourceTestt", "campaign", "sideId");
AppsFlyerMOCKInterface.Received().setPreinstallAttribution("mediaSourceTestt", "campaign", "sideId");
}
[Test]
public void isPreInstalledApp_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.isPreInstalledApp();
AppsFlyerMOCKInterface.Received().isPreInstalledApp();
}
[Test]
public void getAttributionId_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.getAttributionId();
AppsFlyerMOCKInterface.Received().getAttributionId();
}
[Test]
public void handlePushNotifications_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.handlePushNotifications();
AppsFlyerMOCKInterface.Received().handlePushNotifications();
}
[Test]
public void validateAndSendInAppPurchase_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.validateAndSendInAppPurchase("ewjkekwjekw","hewjehwj", "purchaseData", "3.0", "USD", null, null);
AppsFlyerMOCKInterface.Received().validateAndSendInAppPurchase("ewjkekwjekw", "hewjehwj", "purchaseData", "3.0", "USD", null, null);
}
[Test]
public void setCollectOaid_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setCollectOaid(true);
AppsFlyerMOCKInterface.Received().setCollectOaid(true);
}
[Test]
public void setDisableAdvertisingIdentifiers_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setDisableAdvertisingIdentifiers(true);
AppsFlyerMOCKInterface.Received().setDisableAdvertisingIdentifiers(true);
}
[Test]
public void setDisableNetworkData_called() {
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerAndroidBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setDisableNetworkData(true);
AppsFlyerMOCKInterface.Received().setDisableNetworkData(true);
}
#elif UNITY_IOS
[Test]
public void setDisableCollectAppleAdSupport_called_true()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setDisableCollectAppleAdSupport(true);
AppsFlyerMOCKInterface.Received().setDisableCollectAppleAdSupport(true);
}
[Test]
public void setDisableCollectAppleAdSupport_called_false()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setDisableCollectAppleAdSupport(false);
AppsFlyerMOCKInterface.Received().setDisableCollectAppleAdSupport(false);
}
[Test]
[System.Obsolete]
public void setShouldCollectDeviceName_called_true()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setShouldCollectDeviceName(true);
AppsFlyerMOCKInterface.Received().setShouldCollectDeviceName(true);
}
[Test]
[System.Obsolete]
public void setShouldCollectDeviceName_called_false()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setShouldCollectDeviceName(false);
AppsFlyerMOCKInterface.Received().setShouldCollectDeviceName(false);
}
[Test]
public void setDisableCollectIAd_called_true()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setDisableCollectIAd(true);
AppsFlyerMOCKInterface.Received().setDisableCollectIAd(true);
}
[Test]
public void setDisableCollectIAd_called_false()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setDisableCollectIAd(false);
AppsFlyerMOCKInterface.Received().setDisableCollectIAd(false);
}
[Test]
public void setUseReceiptValidationSandbox_called_true()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setUseReceiptValidationSandbox(true);
AppsFlyerMOCKInterface.Received().setUseReceiptValidationSandbox(true);
}
[Test]
public void setUseReceiptValidationSandbox_called_false()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setUseReceiptValidationSandbox(false);
AppsFlyerMOCKInterface.Received().setUseReceiptValidationSandbox(false);
}
[Test]
public void ssetUseUninstallSandbox_called_true()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setUseUninstallSandbox(true);
AppsFlyerMOCKInterface.Received().setUseUninstallSandbox(true);
}
[Test]
public void setUseUninstallSandbox_called_false()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setUseUninstallSandbox(false);
AppsFlyerMOCKInterface.Received().setUseUninstallSandbox(false);
}
[Test]
public void validateAndSendInAppPurchase_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.validateAndSendInAppPurchase("3d2", "5.0","USD", "45", null, null);
AppsFlyerMOCKInterface.Received().validateAndSendInAppPurchase("3d2", "5.0", "USD", "45", null, null);
}
[Test]
public void registerUninstall_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
byte[] token = System.Text.Encoding.UTF8.GetBytes("740f4707 bebcf74f 9b7c25d4 8e335894 5f6aa01d a5ddb387 462c7eaf 61bb78ad");
AppsFlyer.registerUninstall(token);
AppsFlyerMOCKInterface.Received().registerUninstall(token);
}
[Test]
public void handleOpenUrl_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.handleOpenUrl("www.test.com", "appTest", "test");
AppsFlyerMOCKInterface.Received().handleOpenUrl("www.test.com", "appTest", "test");
}
[Test]
public void waitForATTUserAuthorizationWithTimeoutInterval_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.waitForATTUserAuthorizationWithTimeoutInterval(30);
AppsFlyerMOCKInterface.Received().waitForATTUserAuthorizationWithTimeoutInterval(30);
}
[Test]
public void setCurrentDeviceLanguage_called()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.setCurrentDeviceLanguage("en");
AppsFlyerMOCKInterface.Received().setCurrentDeviceLanguage("en");
}
[Test]
public void disableSKAdNetwork_called_true()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.disableSKAdNetwork(true);
AppsFlyerMOCKInterface.Received().disableSKAdNetwork(true);
}
[Test]
public void disableSKAdNetwork_called_false()
{
var AppsFlyerMOCKInterface = Substitute.For<IAppsFlyerIOSBridge>();
AppsFlyer.instance = AppsFlyerMOCKInterface;
AppsFlyer.disableSKAdNetwork(false);
AppsFlyerMOCKInterface.Received().disableSKAdNetwork(false);
}
#endif
}
}
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 1b1a24aa01166451d804d7c03c14a3db
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+145 -145
View File
@@ -1,145 +1,145 @@
//#define AFSDK_WIN_DEBUG
//#define UNITY_WSA_10_0
//#define ENABLE_WINMD_SUPPORT
#if UNITY_WSA_10_0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.ComponentModel;
using UnityEngine;
using System.Threading.Tasks;
#if ENABLE_WINMD_SUPPORT
using AppsFlyerLib;
#endif
namespace AppsFlyerSDK
{
public class AppsFlyerWindows
{
#if ENABLE_WINMD_SUPPORT
static private MonoBehaviour _gameObject = null;
#endif
public static void InitSDK(string devKey, string appId, MonoBehaviour gameObject)
{
#if ENABLE_WINMD_SUPPORT
#if AFSDK_WIN_DEBUG
// Remove callstack
Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
#endif
Log("[InitSDK]: devKey: {0}, appId: {1}, gameObject: {2}", devKey, appId, gameObject == null ? "null" : gameObject.ToString());
AppsFlyerTracker tracker = AppsFlyerTracker.GetAppsFlyerTracker();
tracker.devKey = devKey;
tracker.appId = appId;
// Interface
_gameObject = gameObject;
#endif
}
public static string GetAppsFlyerId()
{
#if ENABLE_WINMD_SUPPORT
Log("[GetAppsFlyerId]");
return AppsFlyerTracker.GetAppsFlyerTracker().GetAppsFlyerUID();
#else
return "";
#endif
}
public static void SetCustomerUserId(string customerUserId)
{
#if ENABLE_WINMD_SUPPORT
Log("[SetCustomerUserId] customerUserId: {0}", customerUserId);
if (customerUserId.Contains("test_device:"))
{
string testDeviceId = customerUserId.Substring(12);
AppsFlyerTracker.GetAppsFlyerTracker().testDeviceId = testDeviceId;
}
AppsFlyerTracker.GetAppsFlyerTracker().customerUserId = customerUserId;
#endif
}
public static void Start()
{
#if ENABLE_WINMD_SUPPORT
Log("[Start]");
AppsFlyerTracker.GetAppsFlyerTracker().TrackAppLaunchAsync(Callback);
#endif
}
#if ENABLE_WINMD_SUPPORT
public static void Callback(AppsFlyerLib.ServerStatusCode code)
{
Log("[Callback]: {0}", code.ToString());
AppsFlyerRequestEventArgs eventArgs = new AppsFlyerRequestEventArgs((int)code, code.ToString());
if (_gameObject != null) {
var method = _gameObject.GetType().GetMethod("AppsFlyerOnRequestResponse");
if (method != null) {
method.Invoke(_gameObject, new object[] { AppsFlyerTracker.GetAppsFlyerTracker(), eventArgs });
}
}
}
#endif
public static void LogEvent(string eventName, Dictionary<string, string> eventValues)
{
#if ENABLE_WINMD_SUPPORT
if (eventValues == null)
{
eventValues = new Dictionary<string, string>();
}
IDictionary<string, object> result = new Dictionary<string, object>();
foreach (KeyValuePair<string, string> kvp in eventValues)
{
result.Add(kvp.Key.ToString(), kvp.Value);
}
Log("[LogEvent]: eventName: {0} result: {1}", eventName, result.ToString());
AppsFlyerTracker tracker = AppsFlyerTracker.GetAppsFlyerTracker();
tracker.TrackEvent(eventName, result);
#endif
}
public static void GetConversionData(string _reserved)
{
#if ENABLE_WINMD_SUPPORT
Task.Run(async () =>
{
AppsFlyerLib.AppsFlyerTracker tracker = AppsFlyerLib.AppsFlyerTracker.GetAppsFlyerTracker();
string conversionData = await tracker.GetConversionDataAsync();
IAppsFlyerConversionData conversionDataHandler = _gameObject as IAppsFlyerConversionData;
if (conversionDataHandler != null)
{
Log("[GetConversionData] Will call `onConversionDataSuccess` with: {0}", conversionData);
conversionDataHandler.onConversionDataSuccess(conversionData);
} else {
Log("[GetConversionData] Object with `IAppsFlyerConversionData` interface not found! Check `InitSDK` implementation");
}
// _gameObject.GetType().GetMethod("onConversionDataSuccess").Invoke(_gameObject, new[] { conversionData });
});
#endif
}
private static void Log(string format, params string[] args)
{
#if AFSDK_WIN_DEBUG
#if ENABLE_WINMD_SUPPORT
Debug.Log("AF_UNITY_WSA_10_0" + String.Format(format, args));
#endif
#endif
}
}
}
#endif
//#define AFSDK_WIN_DEBUG
//#define UNITY_WSA_10_0
//#define ENABLE_WINMD_SUPPORT
#if UNITY_WSA_10_0
using System;
using System.Collections;
using System.Collections.Generic;
using System.Reflection;
using System.ComponentModel;
using UnityEngine;
using System.Threading.Tasks;
#if ENABLE_WINMD_SUPPORT
using AppsFlyerLib;
#endif
namespace AppsFlyerSDK
{
public class AppsFlyerWindows
{
#if ENABLE_WINMD_SUPPORT
static private MonoBehaviour _gameObject = null;
#endif
public static void InitSDK(string devKey, string appId, MonoBehaviour gameObject)
{
#if ENABLE_WINMD_SUPPORT
#if AFSDK_WIN_DEBUG
// Remove callstack
Application.SetStackTraceLogType(LogType.Log, StackTraceLogType.None);
#endif
Log("[InitSDK]: devKey: {0}, appId: {1}, gameObject: {2}", devKey, appId, gameObject == null ? "null" : gameObject.ToString());
AppsFlyerTracker tracker = AppsFlyerTracker.GetAppsFlyerTracker();
tracker.devKey = devKey;
tracker.appId = appId;
// Interface
_gameObject = gameObject;
#endif
}
public static string GetAppsFlyerId()
{
#if ENABLE_WINMD_SUPPORT
Log("[GetAppsFlyerId]");
return AppsFlyerTracker.GetAppsFlyerTracker().GetAppsFlyerUID();
#else
return "";
#endif
}
public static void SetCustomerUserId(string customerUserId)
{
#if ENABLE_WINMD_SUPPORT
Log("[SetCustomerUserId] customerUserId: {0}", customerUserId);
if (customerUserId.Contains("test_device:"))
{
string testDeviceId = customerUserId.Substring(12);
AppsFlyerTracker.GetAppsFlyerTracker().testDeviceId = testDeviceId;
}
AppsFlyerTracker.GetAppsFlyerTracker().customerUserId = customerUserId;
#endif
}
public static void Start()
{
#if ENABLE_WINMD_SUPPORT
Log("[Start]");
AppsFlyerTracker.GetAppsFlyerTracker().TrackAppLaunchAsync(Callback);
#endif
}
#if ENABLE_WINMD_SUPPORT
public static void Callback(AppsFlyerLib.ServerStatusCode code)
{
Log("[Callback]: {0}", code.ToString());
AppsFlyerRequestEventArgs eventArgs = new AppsFlyerRequestEventArgs((int)code, code.ToString());
if (_gameObject != null) {
var method = _gameObject.GetType().GetMethod("AppsFlyerOnRequestResponse");
if (method != null) {
method.Invoke(_gameObject, new object[] { AppsFlyerTracker.GetAppsFlyerTracker(), eventArgs });
}
}
}
#endif
public static void LogEvent(string eventName, Dictionary<string, string> eventValues)
{
#if ENABLE_WINMD_SUPPORT
if (eventValues == null)
{
eventValues = new Dictionary<string, string>();
}
IDictionary<string, object> result = new Dictionary<string, object>();
foreach (KeyValuePair<string, string> kvp in eventValues)
{
result.Add(kvp.Key.ToString(), kvp.Value);
}
Log("[LogEvent]: eventName: {0} result: {1}", eventName, result.ToString());
AppsFlyerTracker tracker = AppsFlyerTracker.GetAppsFlyerTracker();
tracker.TrackEvent(eventName, result);
#endif
}
public static void GetConversionData(string _reserved)
{
#if ENABLE_WINMD_SUPPORT
Task.Run(async () =>
{
AppsFlyerLib.AppsFlyerTracker tracker = AppsFlyerLib.AppsFlyerTracker.GetAppsFlyerTracker();
string conversionData = await tracker.GetConversionDataAsync();
IAppsFlyerConversionData conversionDataHandler = _gameObject as IAppsFlyerConversionData;
if (conversionDataHandler != null)
{
Log("[GetConversionData] Will call `onConversionDataSuccess` with: {0}", conversionData);
conversionDataHandler.onConversionDataSuccess(conversionData);
} else {
Log("[GetConversionData] Object with `IAppsFlyerConversionData` interface not found! Check `InitSDK` implementation");
}
// _gameObject.GetType().GetMethod("onConversionDataSuccess").Invoke(_gameObject, new[] { conversionData });
});
#endif
}
private static void Log(string format, params string[] args)
{
#if AFSDK_WIN_DEBUG
#if ENABLE_WINMD_SUPPORT
Debug.Log("AF_UNITY_WSA_10_0" + String.Format(format, args));
#endif
#endif
}
}
}
#endif
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "appsflyer-unity-plugin",
"displayName": "AppsFlyer",
"description": "AppsFlyer Unity plugin",
"version": "6.17.1",
"version": "6.17.91",
"unity": "2019.4",
"license": "MIT"
}