diff --git a/AFAdRevenueData.cs b/AFAdRevenueData.cs new file mode 100644 index 00000000..64d53dee --- /dev/null +++ b/AFAdRevenueData.cs @@ -0,0 +1,71 @@ +using System; +using System.Collections.Generic; + +namespace AppsFlyerSDK +{ + public enum MediationNetwork : ulong + { + GoogleAdMob = 1, + IronSource = 2, + ApplovinMax = 3, + Fyber = 4, + Appodeal = 5, + Admost = 6, + Topon = 7, + Tradplus = 8, + Yandex = 9, + ChartBoost = 10, + Unity = 11, + ToponPte = 12, + Custom = 13, + DirectMonetization = 14 + } + + public static class AdRevenueScheme + { + /** + * code ISO 3166-1 format + */ + public const string COUNTRY = "country"; + + /** + * ID of the ad unit for the impression + */ + public const string AD_UNIT = "ad_unit"; + + /** + * Format of the ad + */ + public const string AD_TYPE = "ad_type"; + + /** + * ID of the ad placement for the impression + */ + public const string PLACEMENT = "placement"; + } + + /// + // Data class representing ad revenue information. + // + // @property monetizationNetwork The name of the network that monetized the ad. + // @property mediationNetwork An instance of MediationNetwork representing the mediation service used. + // @property currencyIso4217Code The ISO 4217 currency code describing the currency of the revenue. + // @property eventRevenue The amount of revenue generated by the ad. + /// + public class AFAdRevenueData + { + public string monetizationNetwork { get; private set; } + public MediationNetwork mediationNetwork { get; private set; } + public string currencyIso4217Code { get; private set; } + public double eventRevenue { get; private set; } + + public AFAdRevenueData(string monetization, MediationNetwork mediation, string currency, double revenue) + { + monetizationNetwork = monetization; + mediationNetwork = mediation; + currencyIso4217Code = currency; + eventRevenue = revenue; + } + } + +} \ No newline at end of file diff --git a/AFAdRevenueData.cs.meta b/AFAdRevenueData.cs.meta new file mode 100644 index 00000000..3106aaea --- /dev/null +++ b/AFAdRevenueData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 49e1906ae949e4bfea400bd1da9f7e39 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AFInAppEvents.cs b/AFInAppEvents.cs new file mode 100644 index 00000000..1f6d1fe6 --- /dev/null +++ b/AFInAppEvents.cs @@ -0,0 +1,72 @@ +using UnityEngine; +using System.Collections; + +public class AFInAppEvents { + /** + * Event Type + * */ + public const string LEVEL_ACHIEVED = "af_level_achieved"; + public const string ADD_PAYMENT_INFO = "af_add_payment_info"; + public const string ADD_TO_CART = "af_add_to_cart"; + public const string ADD_TO_WISH_LIST = "af_add_to_wishlist"; + public const string COMPLETE_REGISTRATION = "af_complete_registration"; + public const string TUTORIAL_COMPLETION = "af_tutorial_completion"; + public const string INITIATED_CHECKOUT = "af_initiated_checkout"; + public const string PURCHASE = "af_purchase"; + public const string RATE = "af_rate"; + public const string SEARCH = "af_search"; + public const string SPENT_CREDIT = "af_spent_credits"; + public const string ACHIEVEMENT_UNLOCKED = "af_achievement_unlocked"; + public const string CONTENT_VIEW = "af_content_view"; + public const string TRAVEL_BOOKING = "af_travel_booking"; + public const string SHARE = "af_share"; + public const string INVITE = "af_invite"; + public const string LOGIN = "af_login"; + public const string RE_ENGAGE = "af_re_engage"; + public const string UPDATE = "af_update"; + public const string OPENED_FROM_PUSH_NOTIFICATION = "af_opened_from_push_notification"; + public const string LOCATION_CHANGED = "af_location_changed"; + public const string LOCATION_COORDINATES = "af_location_coordinates"; + public const string ORDER_ID = "af_order_id"; + /** + * Event Parameter Name + * **/ + public const string LEVEL = "af_level"; + public const string SCORE = "af_score"; + public const string SUCCESS = "af_success"; + public const string PRICE = "af_price"; + public const string CONTENT_TYPE = "af_content_type"; + public const string CONTENT_ID = "af_content_id"; + public const string CONTENT_LIST = "af_content_list"; + public const string CURRENCY = "af_currency"; + public const string QUANTITY = "af_quantity"; + public const string REGSITRATION_METHOD = "af_registration_method"; + public const string PAYMENT_INFO_AVAILIBLE = "af_payment_info_available"; + public const string MAX_RATING_VALUE = "af_max_rating_value"; + public const string RATING_VALUE = "af_rating_value"; + public const string SEARCH_STRING = "af_search_string"; + public const string DATE_A = "af_date_a"; + public const string DATE_B = "af_date_b"; + public const string DESTINATION_A = "af_destination_a"; + public const string DESTINATION_B = "af_destination_b"; + public const string DESCRIPTION = "af_description"; + public const string CLASS = "af_class"; + public const string EVENT_START = "af_event_start"; + public const string EVENT_END = "af_event_end"; + public const string LATITUDE = "af_lat"; + public const string LONGTITUDE = "af_long"; + public const string CUSTOMER_USER_ID = "af_customer_user_id"; + public const string VALIDATED = "af_validated"; + public const string REVENUE = "af_revenue"; + public const string RECEIPT_ID = "af_receipt_id"; + public const string PARAM_1 = "af_param_1"; + public const string PARAM_2 = "af_param_2"; + public const string PARAM_3 = "af_param_3"; + public const string PARAM_4 = "af_param_4"; + public const string PARAM_5 = "af_param_5"; + public const string PARAM_6 = "af_param_6"; + public const string PARAM_7 = "af_param_7"; + public const string PARAM_8 = "af_param_8"; + public const string PARAM_9 = "af_param_9"; + public const string PARAM_10 = "af_param_10"; +} \ No newline at end of file diff --git a/AFInAppEvents.cs.meta b/AFInAppEvents.cs.meta new file mode 100644 index 00000000..b31364ef --- /dev/null +++ b/AFInAppEvents.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4075c6cf6f3d94b9a9f37f826e6a0e6f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AFMiniJSON.cs b/AFMiniJSON.cs new file mode 100755 index 00000000..d02bf2f6 --- /dev/null +++ b/AFMiniJSON.cs @@ -0,0 +1,547 @@ +/* + * Copyright (c) 2013 Calvin Rien + * + * Based on the JSON parser by Patrick van Bergen + * http://techblog.procurios.nl/k/618/news/view/14605/14863/How-do-I-write-my-own-parser-for-JSON.html + * + * Simplified it so that it doesn't throw exceptions + * and can be used in Unity iPhone with maximum code stripping. + * + * Permission is hereby granted, free of charge, to any person obtaining + * a copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sublicense, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice shall be + * included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY + * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Text; + +namespace AFMiniJSON { + // Example usage: + // + // using UnityEngine; + // using System.Collections; + // using System.Collections.Generic; + // using MiniJSON; + // + // public class MiniJSONTest : MonoBehaviour { + // void Start () { + // var jsonString = "{ \"array\": [1.44,2,3], " + + // "\"object\": {\"key1\":\"value1\", \"key2\":256}, " + + // "\"string\": \"The quick brown fox \\\"jumps\\\" over the lazy dog \", " + + // "\"unicode\": \"\\u3041 Men\u00fa sesi\u00f3n\", " + + // "\"int\": 65536, " + + // "\"float\": 3.1415926, " + + // "\"bool\": true, " + + // "\"null\": null }"; + // + // var dict = Json.Deserialize(jsonString) as Dictionary; + // + // Debug.Log("deserialized: " + dict.GetType()); + // Debug.Log("dict['array'][0]: " + ((List) dict["array"])[0]); + // Debug.Log("dict['string']: " + (string) dict["string"]); + // Debug.Log("dict['float']: " + (double) dict["float"]); // floats come out as doubles + // Debug.Log("dict['int']: " + (long) dict["int"]); // ints come out as longs + // Debug.Log("dict['unicode']: " + (string) dict["unicode"]); + // + // var str = Json.Serialize(dict); + // + // Debug.Log("serialized: " + str); + // } + // } + + /// + /// This class encodes and decodes JSON strings. + /// Spec. details, see http://www.json.org/ + /// + /// JSON uses Arrays and Objects. These correspond here to the datatypes IList and IDictionary. + /// All numbers are parsed to doubles. + /// + public static class Json { + /// + /// Parses the string json into a value + /// + /// A JSON string. + /// An List<object>, a Dictionary<string, object>, a double, an integer,a string, null, true, or false + public static object Deserialize(string json) { + // save the string for debug information + if (json == null) { + return null; + } + + return Parser.Parse(json); + } + + sealed class Parser : IDisposable { + const string WORD_BREAK = "{}[],:\""; + + public static bool IsWordBreak(char c) { + return Char.IsWhiteSpace(c) || WORD_BREAK.IndexOf(c) != -1; + } + + enum TOKEN { + NONE, + CURLY_OPEN, + CURLY_CLOSE, + SQUARED_OPEN, + SQUARED_CLOSE, + COLON, + COMMA, + STRING, + NUMBER, + TRUE, + FALSE, + NULL + }; + + StringReader json; + + Parser(string jsonString) { + json = new StringReader(jsonString); + } + + public static object Parse(string jsonString) { + using (var instance = new Parser(jsonString)) { + return instance.ParseValue(); + } + } + + public void Dispose() { + json.Dispose(); + json = null; + } + + Dictionary ParseObject() { + Dictionary table = new Dictionary(); + + // ditch opening brace + json.Read(); + + // { + while (true) { + switch (NextToken) { + case TOKEN.NONE: + return null; + case TOKEN.COMMA: + continue; + case TOKEN.CURLY_CLOSE: + return table; + default: + // name + string name = ParseString(); + if (name == null) { + return null; + } + + // : + if (NextToken != TOKEN.COLON) { + return null; + } + // ditch the colon + json.Read(); + + // value + table[name] = ParseValue(); + break; + } + } + } + + List ParseArray() { + List array = new List(); + + // ditch opening bracket + json.Read(); + + // [ + var parsing = true; + while (parsing) { + TOKEN nextToken = NextToken; + + switch (nextToken) { + case TOKEN.NONE: + return null; + case TOKEN.COMMA: + continue; + case TOKEN.SQUARED_CLOSE: + parsing = false; + break; + default: + object value = ParseByToken(nextToken); + + array.Add(value); + break; + } + } + + return array; + } + + object ParseValue() { + TOKEN nextToken = NextToken; + return ParseByToken(nextToken); + } + + object ParseByToken(TOKEN token) { + switch (token) { + case TOKEN.STRING: + return ParseString(); + case TOKEN.NUMBER: + return ParseNumber(); + case TOKEN.CURLY_OPEN: + return ParseObject(); + case TOKEN.SQUARED_OPEN: + return ParseArray(); + case TOKEN.TRUE: + return true; + case TOKEN.FALSE: + return false; + case TOKEN.NULL: + return null; + default: + return null; + } + } + + string ParseString() { + StringBuilder s = new StringBuilder(); + char c; + + // ditch opening quote + json.Read(); + + bool parsing = true; + while (parsing) { + + if (json.Peek() == -1) { + parsing = false; + break; + } + + c = NextChar; + switch (c) { + case '"': + parsing = false; + break; + case '\\': + if (json.Peek() == -1) { + parsing = false; + break; + } + + c = NextChar; + switch (c) { + case '"': + case '\\': + case '/': + s.Append(c); + break; + case 'b': + s.Append('\b'); + break; + case 'f': + s.Append('\f'); + break; + case 'n': + s.Append('\n'); + break; + case 'r': + s.Append('\r'); + break; + case 't': + s.Append('\t'); + break; + case 'u': + var hex = new char[4]; + + for (int i=0; i< 4; i++) { + hex[i] = NextChar; + } + + s.Append((char) Convert.ToInt32(new string(hex), 16)); + break; + } + break; + default: + s.Append(c); + break; + } + } + + return s.ToString(); + } + + object ParseNumber() { + string number = NextWord; + + if (number.IndexOf('.') == -1) { + long parsedInt; + Int64.TryParse(number, out parsedInt); + return parsedInt; + } + + double parsedDouble; + Double.TryParse(number, out parsedDouble); + return parsedDouble; + } + + void EatWhitespace() { + while (Char.IsWhiteSpace(PeekChar)) { + json.Read(); + + if (json.Peek() == -1) { + break; + } + } + } + + char PeekChar { + get { + return Convert.ToChar(json.Peek()); + } + } + + char NextChar { + get { + return Convert.ToChar(json.Read()); + } + } + + string NextWord { + get { + StringBuilder word = new StringBuilder(); + + while (!IsWordBreak(PeekChar)) { + word.Append(NextChar); + + if (json.Peek() == -1) { + break; + } + } + + return word.ToString(); + } + } + + TOKEN NextToken { + get { + EatWhitespace(); + + if (json.Peek() == -1) { + return TOKEN.NONE; + } + + switch (PeekChar) { + case '{': + return TOKEN.CURLY_OPEN; + case '}': + json.Read(); + return TOKEN.CURLY_CLOSE; + case '[': + return TOKEN.SQUARED_OPEN; + case ']': + json.Read(); + return TOKEN.SQUARED_CLOSE; + case ',': + json.Read(); + return TOKEN.COMMA; + case '"': + return TOKEN.STRING; + case ':': + return TOKEN.COLON; + case '0': + case '1': + case '2': + case '3': + case '4': + case '5': + case '6': + case '7': + case '8': + case '9': + case '-': + return TOKEN.NUMBER; + } + + switch (NextWord) { + case "false": + return TOKEN.FALSE; + case "true": + return TOKEN.TRUE; + case "null": + return TOKEN.NULL; + } + + return TOKEN.NONE; + } + } + } + + /// + /// Converts a IDictionary / IList object or a simple type (string, int, etc.) into a JSON string + /// + /// A Dictionary<string, object> / List<object> + /// A JSON encoded string, or null if object 'json' is not serializable + public static string Serialize(object obj) { + return Serializer.Serialize(obj); + } + + sealed class Serializer { + StringBuilder builder; + + Serializer() { + builder = new StringBuilder(); + } + + public static string Serialize(object obj) { + var instance = new Serializer(); + + instance.SerializeValue(obj); + + return instance.builder.ToString(); + } + + void SerializeValue(object value) { + IList asList; + IDictionary asDict; + string asStr; + + if (value == null) { + builder.Append("null"); + } else if ((asStr = value as string) != null) { + SerializeString(asStr); + } else if (value is bool) { + builder.Append((bool) value ? "true" : "false"); + } else if ((asList = value as IList) != null) { + SerializeArray(asList); + } else if ((asDict = value as IDictionary) != null) { + SerializeObject(asDict); + } else if (value is char) { + SerializeString(new string((char) value, 1)); + } else { + SerializeOther(value); + } + } + + void SerializeObject(IDictionary obj) { + bool first = true; + + builder.Append('{'); + + foreach (object e in obj.Keys) { + if (!first) { + builder.Append(','); + } + + SerializeString(e.ToString()); + builder.Append(':'); + + SerializeValue(obj[e]); + + first = false; + } + + builder.Append('}'); + } + + void SerializeArray(IList anArray) { + builder.Append('['); + + bool first = true; + + foreach (object obj in anArray) { + if (!first) { + builder.Append(','); + } + + SerializeValue(obj); + + first = false; + } + + builder.Append(']'); + } + + void SerializeString(string str) { + builder.Append('\"'); + + char[] charArray = str.ToCharArray(); + foreach (var c in charArray) { + switch (c) { + case '"': + builder.Append("\\\""); + break; + case '\\': + builder.Append("\\\\"); + break; + case '\b': + builder.Append("\\b"); + break; + case '\f': + builder.Append("\\f"); + break; + case '\n': + builder.Append("\\n"); + break; + case '\r': + builder.Append("\\r"); + break; + case '\t': + builder.Append("\\t"); + break; + default: + int codepoint = Convert.ToInt32(c); + if ((codepoint >= 32) && (codepoint <= 126)) { + builder.Append(c); + } else { + builder.Append("\\u"); + builder.Append(codepoint.ToString("x4")); + } + break; + } + } + + builder.Append('\"'); + } + + void SerializeOther(object value) { + // NOTE: decimals lose precision during serialization. + // They always have, I'm just letting you know. + // Previously floats and doubles lost precision too. + if (value is float) { + builder.Append(((float) value).ToString("R")); + } else if (value is int + || value is uint + || value is long + || value is sbyte + || value is byte + || value is short + || value is ushort + || value is ulong) { + builder.Append(value); + } else if (value is double + || value is decimal) { + builder.Append(Convert.ToDouble(value).ToString("R")); + } else { + SerializeString(value.ToString()); + } + } + } + } +} diff --git a/AFMiniJSON.cs.meta b/AFMiniJSON.cs.meta new file mode 100644 index 00000000..11ec5c9e --- /dev/null +++ b/AFMiniJSON.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: bc3d1c806d507463e9b560eb09d8eb0e +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AFPurchaseDetailsAndroid.cs b/AFPurchaseDetailsAndroid.cs new file mode 100644 index 00000000..6762c97f --- /dev/null +++ b/AFPurchaseDetailsAndroid.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace AppsFlyerSDK +{ + public enum AFPurchaseType + { + Subscription = 0, + OneTimePurchase = 1 + } + + /// + // + /// + 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) + { + this.purchaseType = type; + this.purchaseToken = purchaseToken; + this.productId = productId; + this.price = price; + this.currency = currency; + } + + } + +} \ No newline at end of file diff --git a/AFPurchaseDetailsAndroid.cs.meta b/AFPurchaseDetailsAndroid.cs.meta new file mode 100644 index 00000000..6d0024d8 --- /dev/null +++ b/AFPurchaseDetailsAndroid.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d71b3864006f94ac08938b2ebdc940bc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AFSDKPurchaseDetailsIOS.cs b/AFSDKPurchaseDetailsIOS.cs new file mode 100644 index 00000000..f159eea4 --- /dev/null +++ b/AFSDKPurchaseDetailsIOS.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; + +namespace AppsFlyerSDK +{ + /// + // + /// + 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; } + + private AFSDKPurchaseDetailsIOS(string productId, string price, string currency, string transactionId) + { + this.productId = productId; + this.price = price; + this.currency = currency; + this.transactionId = transactionId; + } + + public static AFSDKPurchaseDetailsIOS Init(string productId, string price, string currency, string transactionId) + { + return new AFSDKPurchaseDetailsIOS(productId, price, currency, transactionId); + } + } + +} \ No newline at end of file diff --git a/AFSDKPurchaseDetailsIOS.cs.meta b/AFSDKPurchaseDetailsIOS.cs.meta new file mode 100644 index 00000000..f33ebcc5 --- /dev/null +++ b/AFSDKPurchaseDetailsIOS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 44bb6c4472701416080eb050732075ea +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AFSDKValidateAndLogResult.cs b/AFSDKValidateAndLogResult.cs new file mode 100644 index 00000000..e877fbd9 --- /dev/null +++ b/AFSDKValidateAndLogResult.cs @@ -0,0 +1,38 @@ +using System; +using System.Collections.Generic; + +namespace AppsFlyerSDK +{ + public enum AFSDKValidateAndLogStatus + { + AFSDKValidateAndLogStatusSuccess, + AFSDKValidateAndLogStatusFailure, + AFSDKValidateAndLogStatusError + } + + + /// + // + /// + public class AFSDKValidateAndLogResult + { + public AFSDKValidateAndLogStatus status { get; private set; } + public Dictionary result { get; private set; } + public Dictionary errorData { get; private set; } + public string error { get; private set; } + + private AFSDKValidateAndLogResult(AFSDKValidateAndLogStatus status, Dictionary result, Dictionary errorData, string error) + { + this.status = status; + this.result = result; + this.errorData = errorData; + this.error = error; + } + + public static AFSDKValidateAndLogResult Init(AFSDKValidateAndLogStatus status, Dictionary result, Dictionary errorData, string error) + { + return new AFSDKValidateAndLogResult(status, result, errorData, error); + } + } + +} \ No newline at end of file diff --git a/AFSDKValidateAndLogResult.cs.meta b/AFSDKValidateAndLogResult.cs.meta new file mode 100644 index 00000000..63d48354 --- /dev/null +++ b/AFSDKValidateAndLogResult.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2df1c6f1eab2e4849bf2762a8d78933f +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyer.asmdef b/AppsFlyer.asmdef new file mode 100644 index 00000000..381ee000 --- /dev/null +++ b/AppsFlyer.asmdef @@ -0,0 +1,13 @@ +{ + "name": "AppsFlyer", + "references": [], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/AppsFlyer.asmdef.meta b/AppsFlyer.asmdef.meta new file mode 100644 index 00000000..380f36a1 --- /dev/null +++ b/AppsFlyer.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 2a37df438292d4903b4e5159c5de3bf9 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyer.cs b/AppsFlyer.cs new file mode 100644 index 00000000..3759c9e4 --- /dev/null +++ b/AppsFlyer.cs @@ -0,0 +1,1099 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace AppsFlyerSDK +{ + public class AppsFlyer : MonoBehaviour + { + public static readonly string kAppsFlyerPluginVersion = "6.15.2"; + public static string CallBackObjectName = null; + private static EventHandler onRequestResponse; + private static EventHandler onInAppResponse; + private static EventHandler onDeepLinkReceived; + public static IAppsFlyerNativeBridge instance = null; + public delegate void unityCallBack(string message); + + + /// + /// Initialize the AppsFlyer SDK with your devKey and appID. + /// The dev key is required on all platforms, and the appID is required for iOS. + /// If you app is for Android only pass null for the appID. + /// + /// AppsFlyer's Dev-Key, which is accessible from your AppsFlyer account under 'App Settings' in the dashboard. + /// Your app's Apple ID. + /// + /// + /// AppsFlyer.initSDK("K2***********99", "41*****44""); + /// + /// + public static void initSDK(string devKey, string appID) + { + initSDK(devKey, appID, null); + } + + /// + /// Initialize the AppsFlyer SDK with your devKey and appID. + /// The dev key is required on all platforms, and the appID is required for iOS. + /// If you app is for Android only pass null for the appID. + /// + /// AppsFlyer's Dev-Key, which is accessible from your AppsFlyer account under 'App Settings' in the dashboard. + /// Your app's Apple ID. + /// pass the script of the game object being used. + /// + /// + /// AppsFlyer.initSDK("K2***********99", 41*****44, this); + /// + /// + public static void initSDK(string devKey, string appID, MonoBehaviour gameObject) + { + + if (gameObject != null) + { +#if UNITY_STANDALONE_OSX + CallBackObjectName = gameObject.GetType().ToString(); +#else + CallBackObjectName = gameObject.name; +#endif + } + +#if UNITY_IOS || UNITY_STANDALONE_OSX + if (instance == null || !instance.isInit) + { + instance = new AppsFlyeriOS(devKey, appID, gameObject); + instance.isInit = true; + } +#elif UNITY_ANDROID + if (instance == null || !instance.isInit) + { + AppsFlyerAndroid appsFlyerAndroid = new AppsFlyerAndroid(); + appsFlyerAndroid.initSDK(devKey, gameObject); + instance = appsFlyerAndroid; + instance.isInit = true; + + } +#elif UNITY_WSA_10_0 + AppsFlyerWindows.InitSDK(devKey, appID, gameObject); + if (gameObject != null) + { + AppsFlyerWindows.GetConversionData(gameObject.name); + } +#else + +#endif + } + + + /// + /// Once this API is invoked, our SDK will start. + /// Once the API is called a sessions will be immediately sent, and all background forground transitions will send a session. + /// + public static void startSDK() + { +#if UNITY_WSA_10_0 + AppsFlyerWindows.Start(); + +#else + if (instance != null) + { + instance.startSDK(onRequestResponse != null, CallBackObjectName); + } +#endif + } + + + + + + + /// + /// Send an In-App Event. + /// In-App Events provide insight on what is happening in your app. + /// + /// Event Name as String. + /// Event Values as Dictionary. + public static void sendEvent(string eventName, Dictionary eventValues) + { +#if UNITY_WSA_10_0 && !UNITY_EDITOR + AppsFlyerWindows.LogEvent(eventName, eventValues); +#else + if (instance != null) + { + instance.sendEvent(eventName, eventValues, onInAppResponse != null, CallBackObjectName); + } +#endif + } + /// + /// Once this API is invoked, our SDK no longer communicates with our servers and stops functioning. + /// In some extreme cases you might want to shut down all SDK activity due to legal and privacy compliance. + /// This can be achieved with the stopSDK API. + /// + /// should sdk be stopped. + public static void stopSDK(bool isSDKStopped) + { + if (instance != null) + { + instance.stopSDK(isSDKStopped); + } + } + + // + /// Was the stopSDK(boolean) API set to true. + /// + /// boolean isSDKStopped. + public static bool isSDKStopped() + { + if (instance != null) + { + return instance.isSDKStopped(); + } + + return false; + } + + /// + /// Get the AppsFlyer SDK version used in app. + /// + /// The current SDK version. + public static string getSdkVersion() + { + if (instance != null) + { + return instance.getSdkVersion(); + } + + return ""; + + } + + /// + /// Enables Debug logs for the AppsFlyer SDK. + /// Should only be set to true in development / debug. + /// + /// shouldEnable boolean. + public static void setIsDebug(bool shouldEnable) + { + if (instance != null) + { + instance.setIsDebug(shouldEnable); + } else { +#if UNITY_IOS || UNITY_STANDALONE_OSX + instance = new AppsFlyeriOS(); + instance.setIsDebug(shouldEnable); +#elif UNITY_ANDROID + instance = new AppsFlyerAndroid(); + instance.setIsDebug(shouldEnable); +#else + +#endif + } + + } + + /// + /// Setting your own customer ID enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and the other devices’ IDs. + /// This ID is available in AppsFlyer CSV reports along with Postback APIs for cross-referencing with your internal IDs. + /// + /// Customer ID for client. + public static void setCustomerUserId(string id) + { +#if UNITY_WSA_10_0 && !UNITY_EDITOR + AppsFlyerWindows.SetCustomerUserId(id); +#else + if (instance != null) + { + instance.setCustomerUserId(id); + } +#endif + } + + /// + /// Set the OneLink ID that should be used for User-Invite-API. + /// The link that is generated for the user invite will use this OneLink as the base link. + /// + /// OneLink ID obtained from the AppsFlyer Dashboard. + public static void setAppInviteOneLinkID(string oneLinkId) + { + + if (instance != null) + { + instance.setAppInviteOneLinkID(oneLinkId); + } + + + } + + /// + /// Set the deepLink timeout value that should be used for DDL. + /// + /// deepLink timeout in milliseconds. + public static void setDeepLinkTimeout(long deepLinkTimeout) + { + + if (instance != null) + { + instance.setDeepLinkTimeout(deepLinkTimeout); + } + + + } + + /// + /// Set additional data to be sent to AppsFlyer. + /// + /// additional data Dictionary. + public static void setAdditionalData(Dictionary customData) + { + + if (instance != null) + { + instance.setAdditionalData(customData); + } + + + } + + /// + /// Advertisers can wrap AppsFlyer OneLink within another Universal Link. + /// This Universal Link will invoke the app but any deep linking data will not propagate to AppsFlyer. + /// + /// Array of urls. + public static void setResolveDeepLinkURLs(params string[] urls) + { + + if (instance != null) + { + instance.setResolveDeepLinkURLs(urls); + } + + + } + + + /// + /// Advertisers can use this method to set vanity onelink domains. + /// + /// Array of domains. + public static void setOneLinkCustomDomain(params string[] domains) + { + + if (instance != null) + { + instance.setOneLinkCustomDomain(domains); + } + else + { +#if UNITY_IOS || UNITY_STANDALONE_OSX + instance = new AppsFlyeriOS(); +#elif UNITY_ANDROID + instance = new AppsFlyerAndroid(); +#else + +#endif + + + + } + } + + /// + /// Setting user local currency code for in-app purchases. + /// The currency code should be a 3 character ISO 4217 code. (default is USD). + /// You can set the currency code for all events by calling the following method. + /// + /// 3 character ISO 4217 code. + public static void setCurrencyCode(string currencyCode) + { + + if (instance != null) + { + instance.setCurrencyCode(currencyCode); + } else { +#if UNITY_IOS || UNITY_STANDALONE_OSX + instance = new AppsFlyeriOS(); + instance.setCurrencyCode(currencyCode); +#elif UNITY_ANDROID + instance = new AppsFlyerAndroid(); + instance.setCurrencyCode(currencyCode); +#else +#endif + } + } + + /// + /// Sets or updates the user consent data related to GDPR and DMA regulations for advertising and data usage purposes within the application. + /// + /// instance of AppsFlyerConsent. + public static void setConsentData(AppsFlyerConsent appsFlyerConsent) + { + if (instance != null) + { + instance.setConsentData(appsFlyerConsent); + } + } + + /// + /// Logs ad revenue data along with additional parameters if provided. + /// + /// instance of AFAdRevenueData containing ad revenue information. + /// An optional map of additional parameters to be logged with ad revenue data. This can be null if there are no additional parameters. + public static void logAdRevenue(AFAdRevenueData adRevenueData, Dictionary additionalParameters) + { + if (instance != null) + { + instance.logAdRevenue(adRevenueData, additionalParameters); + } + } + + /// + /// Manually record the location of the user. + /// + /// latitude as double. + /// longitude as double. + public static void recordLocation(double latitude, double longitude) + { + + if (instance != null) + { + instance.recordLocation(latitude, longitude); + } + + + } + + /// + /// Anonymize user Data. + /// Use this API during the SDK Initialization to explicitly anonymize a user's installs, events and sessions. + /// Default is false. + /// + /// shouldAnonymizeUser boolean. + public static void anonymizeUser(bool shouldAnonymizeUser) + { + + if (instance != null) + { + instance.anonymizeUser(shouldAnonymizeUser); + } + + + } + + /// + /// Calling enableTCFDataCollection(true) will enable collecting and sending any TCF related data. + /// Calling enableTCFDataCollection(false) will disable the collection of TCF related data and from sending it. + /// + /// should start TCF Data collection boolean. + public static void enableTCFDataCollection(bool shouldCollectTcfData) + { + if (instance != null) + { + instance.enableTCFDataCollection(shouldCollectTcfData); + } + } + + /// + /// Get AppsFlyer's unique device ID which is created for every new install of an app. + /// + /// AppsFlyer's unique device ID. + public static string getAppsFlyerId() + { +#if UNITY_WSA_10_0 && !UNITY_EDITOR + return AppsFlyerWindows.GetAppsFlyerId(); +#else + if (instance != null) + { + return instance.getAppsFlyerId(); + } +#endif + return string.Empty; + + } + + /// + /// Set a custom value for the minimum required time between sessions. + /// By default, at least 5 seconds must lapse between 2 app launches to count as separate 2 sessions. + /// + /// minimum time between 2 separate sessions in seconds. + public static void setMinTimeBetweenSessions(int seconds) + { + + if (instance != null) + { + instance.setMinTimeBetweenSessions(seconds); + } + + + } + + /// + /// Set a custom host. + /// + /// Host prefix. + /// Host name. + public static void setHost(string hostPrefixName, string hostName) + { + + if (instance != null) + { + instance.setHost(hostPrefixName, hostName); + } else { +#if UNITY_IOS || UNITY_STANDALONE_OSX + instance = new AppsFlyeriOS(); + instance.setHost(hostPrefixName, hostName); +#elif UNITY_ANDROID + instance = new AppsFlyerAndroid(); + instance.setHost(hostPrefixName, hostName); +#else +#endif + } + } + + /// + /// Set the user emails and encrypt them. + /// cryptMethod Encryption method: + /// EmailCryptType.EmailCryptTypeMD5 + /// EmailCryptType.EmailCryptTypeSHA1 + /// EmailCryptType.EmailCryptTypeSHA256 + /// EmailCryptType.EmailCryptTypeNone + /// + /// Encryption method. + /// User emails. + public static void setUserEmails(EmailCryptType cryptType, params string[] userEmails) + { + + if (instance != null) + { + instance.setUserEmails(cryptType, userEmails); + } + + } + + public static void updateServerUninstallToken(string token) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.updateServerUninstallToken(token); + } + } + + /// + /// Set the user phone number. + /// + /// phoneNumber string + public static void setPhoneNumber(string phoneNumber) + { + + if (instance != null) + { + instance.setPhoneNumber(phoneNumber); + } + + } + + public static void setImeiData(string aImei) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setImeiData(aImei); + } + } + + /// + /// Used by advertisers to exclude all networks/integrated partners from getting data. + /// + [Obsolete("Please use setSharingFilterForPartners api")] + public static void setSharingFilterForAllPartners() + { + + if (instance != null) + { + instance.setSharingFilterForAllPartners(); + } + + + } + + public static void setAndroidIdData(string aAndroidId) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setAndroidIdData(aAndroidId); + } + } + + public static void waitForCustomerUserId(bool wait) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.waitForCustomerUserId(wait); + } + } + + /// + /// Used by advertisers to set some (one or more) networks/integrated partners to exclude from getting data. + /// + /// partners to exclude from getting data + [Obsolete("Please use setSharingFilterForPartners api")] + public static void setSharingFilter(params string[] partners) + { + + if (instance != null) + { + instance.setSharingFilter(partners); + } + + + } + + public static void setCustomerIdAndStartSDK(string id) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setCustomerIdAndStartSDK(id); + } + } + + /// + /// Lets you configure how which partners should the SDK exclude from data-sharing. + /// + /// partners to exclude from getting data + public static void setSharingFilterForPartners(params string[] partners) + { +#if UNITY_IOS || UNITY_STANDALONE_OSX + AppsFlyeriOS.setSharingFilterForPartners(partners); +#elif UNITY_ANDROID + AppsFlyerAndroid.setSharingFilterForPartners(partners); +#else + +#endif + } + + public static string getOutOfStore() + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + return appsFlyerAndroidInstance.getOutOfStore(); + } + return string.Empty; + } + + public static void setOutOfStore(string sourceName) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setOutOfStore(sourceName); + } + } + + /// + /// Register a Conversion Data Listener. + /// Allows the developer to access the user attribution data in real-time for every new install, directly from the SDK level. + /// By doing this you can serve users with personalized content or send them to specific activities within the app, + /// which can greatly enhance their engagement with your app. + /// + /// + /// + /// AppsFlyer.getConversionData(this.name); + /// + /// + public static void getConversionData(string objectName) + { +#if UNITY_WSA_10_0 && !UNITY_EDITOR + AppsFlyerWindows.GetConversionData(""); +#else + if (instance != null) + { + instance.getConversionData(objectName); + } +#endif + + } + + public static void setCollectAndroidID(bool isCollect) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setCollectAndroidID(isCollect); + } + } + + public static void setIsUpdate(bool isUpdate) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setIsUpdate(isUpdate); + } + } + + public static void setCollectIMEI(bool isCollect) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setCollectIMEI(isCollect); + } + } + + public static void setDisableCollectAppleAdSupport(bool disable) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.setDisableCollectAppleAdSupport(disable); + } + } + + public static void setShouldCollectDeviceName(bool shouldCollectDeviceName) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.setShouldCollectDeviceName(shouldCollectDeviceName); + } + } + + + /// + /// Use the following API to attribute the click and launch the app store's app page. + /// + /// promoted App ID + /// cross promotion campaign + /// additional user params + /// + /// + /// Dictionary parameters = new Dictionary(); + /// parameters.Add("af_sub1", "val"); + /// parameters.Add("custom_param", "val2"); + /// AppsFlyer.attributeAndOpenStore("123456789", "test campaign", parameters, this); + /// + /// + public static void attributeAndOpenStore(string appID, string campaign, Dictionary userParams, MonoBehaviour gameObject) + { + + if (instance != null) + { + instance.attributeAndOpenStore(appID, campaign, userParams, gameObject); + } + + } + + public static void setPreinstallAttribution(string mediaSource, string campaign, string siteId) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setPreinstallAttribution(mediaSource, campaign, siteId); + } + } + + public static void setDisableCollectIAd(bool disableCollectIAd) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.setDisableCollectIAd(disableCollectIAd); + } + } + + public static bool isPreInstalledApp() + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + return appsFlyerAndroidInstance.isPreInstalledApp(); + } + return false; + } + + public static void setUseReceiptValidationSandbox(bool useReceiptValidationSandbox) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.setUseReceiptValidationSandbox(useReceiptValidationSandbox); + } + } + + /// + /// To attribute an impression use the following API call. + /// Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard. + /// + /// promoted App ID. + /// cross promotion campaign. + /// parameters Dictionary. + public static void recordCrossPromoteImpression(string appID, string campaign, Dictionary parameters) + { + + if (instance != null) + { + instance.recordCrossPromoteImpression(appID, campaign, parameters); + } + + } + + public static void setUseUninstallSandbox(bool useUninstallSandbox) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.setUseUninstallSandbox(useUninstallSandbox); + } + } + + public static string getAttributionId() + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + return appsFlyerAndroidInstance.getAttributionId(); + } + return string.Empty; + } + + public static void handlePushNotifications() + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.handlePushNotifications(); + } + } + + public static void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string transactionId, Dictionary additionalParameters, MonoBehaviour gameObject) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.validateAndSendInAppPurchase(productIdentifier, price, currency, transactionId, additionalParameters, gameObject); + } + } + + // V2 + public static void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary extraEventValues, MonoBehaviour gameObject) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.validateAndSendInAppPurchase(details, extraEventValues, gameObject); + } + } + + public static void validateAndSendInAppPurchase(string publicKey, string signature, string purchaseData, string price, string currency, Dictionary additionalParameters, MonoBehaviour gameObject) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.validateAndSendInAppPurchase(publicKey, signature,purchaseData, price, currency, additionalParameters, gameObject); + } + } + + // V2 + public static void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary additionalParameters, MonoBehaviour gameObject) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.validateAndSendInAppPurchase(details, additionalParameters, gameObject); + } + } + + public static void handleOpenUrl(string url, string sourceApplication, string annotation) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.handleOpenUrl(url, sourceApplication, annotation); + } + } + + public static void registerUninstall(byte[] deviceToken) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.registerUninstall(deviceToken); + } + } + + public static void waitForATTUserAuthorizationWithTimeoutInterval(int timeoutInterval) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.waitForATTUserAuthorizationWithTimeoutInterval(timeoutInterval); + } + } + + public static void setCurrentDeviceLanguage(string language) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.setCurrentDeviceLanguage(language); + } + } + + /// + /// The LinkGenerator class builds the invite URL according to various setter methods which allow passing on additional information on the click. + /// See - https://support.appsflyer.com/hc/en-us/articles/115004480866-User-invite-attribution- + /// + /// parameters Dictionary. + public static void generateUserInviteLink(Dictionary parameters, MonoBehaviour gameObject) + { + + if (instance != null) + { + instance.generateUserInviteLink(parameters, gameObject); + } + + } + + public static void disableSKAdNetwork(bool isDisabled) + { + if (instance != null && instance is IAppsFlyerIOSBridge) + { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.disableSKAdNetwork(isDisabled); + } else { +#if UNITY_IOS || UNITY_STANDALONE_OSX + instance = new AppsFlyeriOS(); + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.disableSKAdNetwork(isDisabled); +#else +#endif + } + } + + public static void setCollectOaid(bool isCollect) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setCollectOaid(isCollect); + } + } + + + /// + /// Use this method if you’re integrating your app with push providers + /// that don’t use the default push notification JSON schema the SDK expects. + /// See docs for more info. + /// + /// array of nested json path + public static void addPushNotificationDeepLinkPath(params string[] paths) + { + + if (instance != null) + { + instance.addPushNotificationDeepLinkPath(paths); + } + + } + + public static void setDisableAdvertisingIdentifiers(bool disable) + { + if (instance != null && instance is IAppsFlyerAndroidBridge) + { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setDisableAdvertisingIdentifiers(disable); + } + } + + /// + /// Subscribe for unified deeplink API. + /// This is called automatically from OnDeepLinkReceived. + /// CallBackObjectName is set in the init method. + /// + public static void subscribeForDeepLink() + { + + if (instance != null) + { + instance.subscribeForDeepLink(CallBackObjectName); + } + + } + + /// + /// Allows sending custom data for partner integration purposes. + /// partnerId : id of the partner + /// partnerInfo: customer data + /// + public static void setPartnerData(string partnerId, Dictionary partnerInfo) + { + if (instance != null) + { + instance.setPartnerData(partnerId, partnerInfo); + } + + } + + /// + /// Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device. + /// + public static void setDisableNetworkData(bool disable) { + if (instance != null && instance is IAppsFlyerAndroidBridge) { + IAppsFlyerAndroidBridge appsFlyerAndroidInstance = (IAppsFlyerAndroidBridge)instance; + appsFlyerAndroidInstance.setDisableNetworkData(disable); + } + } + + + /// + /// Use to disable app vendor identifier (IDFV) collection, 'true' to disable. + /// + public static void disableIDFVCollection(bool isDisabled) + { +#if UNITY_IOS || UNITY_STANDALONE_OSX + if (instance == null) { + instance = new AppsFlyeriOS(); + } + if (instance != null && instance is IAppsFlyerIOSBridge) { + IAppsFlyerIOSBridge appsFlyeriOSInstance = (IAppsFlyerIOSBridge)instance; + appsFlyeriOSInstance.disableIDFVCollection(isDisabled); + } +#else +#endif + } + + /// + /// Start callback event. + /// + public static event EventHandler OnRequestResponse + { + add + { + onRequestResponse += value; + } + remove + { + onRequestResponse -= value; + } + } + + /// + /// In-App callback event. + /// + public static event EventHandler OnInAppResponse + { + add + { + onInAppResponse += value; + } + remove + { + onInAppResponse -= value; + } + } + + /// + /// Unified DeepLink Event + /// + public static event EventHandler OnDeepLinkReceived + { + add + { + onDeepLinkReceived += value; + subscribeForDeepLink(); + } + remove + { + onDeepLinkReceived -= value; + } + } + + /// + /// Used to accept start callback from UnitySendMessage on native side. + /// + public void inAppResponseReceived(string response) + { + if (onInAppResponse != null) + { + onInAppResponse.Invoke(null, parseRequestCallback(response)); + } + } + + /// + /// Used to accept in-app callback from UnitySendMessage on native side. + /// + public void requestResponseReceived(string response) + { + if (onRequestResponse != null) + { + onRequestResponse.Invoke(null, parseRequestCallback(response)); + } + } + + /// + /// Used to accept deeplink callback from UnitySendMessage on native side. + /// + public void onDeepLinking(string response) + { + + DeepLinkEventsArgs args = new DeepLinkEventsArgs(response); + + if (onDeepLinkReceived != null) + { + onDeepLinkReceived.Invoke(null, args); + } + } + + private static AppsFlyerRequestEventArgs parseRequestCallback(string response) + { + int responseCode = 0; + string errorDescription = ""; + + try + { + Dictionary dictionary = CallbackStringToDictionary(response); + var errorResponse = dictionary.ContainsKey("errorDescription") ? dictionary["errorDescription"] : ""; + errorDescription = (string)errorResponse; + responseCode = (int)(long) dictionary["statusCode"]; + } + catch (Exception e) + { + AFLog("parseRequestCallback", String.Format("{0} Exception caught.", e)); + } + + return new AppsFlyerRequestEventArgs(responseCode, errorDescription); + } + + /// + /// Helper method to convert json strings to dictionary. + /// + /// json string + /// dictionary representing the input json string. + public static Dictionary CallbackStringToDictionary(string str) + { + return AFMiniJSON.Json.Deserialize(str) as Dictionary; + } + + /// + /// Helper method to log AppsFlyer events and callbacks. + /// + /// method name + /// message to log + public static void AFLog(string methodName, string str) + { + Debug.Log(string.Format("AppsFlyer_Unity_v{0} {1} called with {2}", kAppsFlyerPluginVersion, methodName, str)); + } + } + + public enum EmailCryptType + { + // None + EmailCryptTypeNone = 0, + // SHA256 + EmailCryptTypeSHA256 = 1, + } + +} \ No newline at end of file diff --git a/AppsFlyer.cs.meta b/AppsFlyer.cs.meta new file mode 100644 index 00000000..48d98d5a --- /dev/null +++ b/AppsFlyer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 45161025a517d427381d3d06153a5ad3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyerAndroid.cs b/AppsFlyerAndroid.cs new file mode 100644 index 00000000..54164889 --- /dev/null +++ b/AppsFlyerAndroid.cs @@ -0,0 +1,846 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace AppsFlyerSDK +{ + +#if UNITY_ANDROID + public class AppsFlyerAndroid : IAppsFlyerAndroidBridge + { + public bool isInit { get; set; } + + private static AndroidJavaClass appsFlyerAndroid = new AndroidJavaClass("com.appsflyer.unity.AppsFlyerAndroidWrapper"); + + public AppsFlyerAndroid() { } + + /// + /// Use this method to init the sdk for the application. + /// Call this method before startSDK. + /// + /// AppsFlyer's Dev-Key, which is accessible from your AppsFlyer account under 'App Settings' in the dashboard. + /// The current game object. This is used to get the conversion data callbacks. Pass null if you do not need the callbacks. + public void initSDK(string devkey, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("initSDK", devkey, gameObject ? gameObject.name : null); +#endif + } + + /// + /// Use this method to start the sdk for the application. + /// The AppsFlyer's Dev-Key must be provided. + /// + /// AppsFlyer's Dev-Key, which is accessible from your AppsFlyer account under 'App Settings' in the dashboard. + public void startSDK(bool onRequestResponse, string CallBackObjectName) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("startTracking", onRequestResponse, CallBackObjectName); +#endif + } + + /// + /// Once this API is invoked, our SDK no longer communicates with our servers and stops functioning. + /// In some extreme cases you might want to shut down all SDK activity due to legal and privacy compliance. + /// This can be achieved with the stopSDK API. + /// + /// boolean should SDK be stopped. + public void stopSDK(bool isSDKStopped) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("stopTracking", isSDKStopped); +#endif + } + + /// + /// Get the AppsFlyer SDK version used in app. + /// + /// AppsFlyer SDK version. + public string getSdkVersion() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("getSdkVersion"); +#else + return ""; +#endif + } + + /// + /// Manually pass the Firebase / GCM Device Token for Uninstall measurement. + /// + /// Firebase Device Token. + public void updateServerUninstallToken(string token) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("updateServerUninstallToken", token); +#endif + } + + /// + /// Enables Debug logs for the AppsFlyer SDK. + /// Should only be set to true in development / debug. + /// + /// shouldEnable boolean. + public void setIsDebug(bool shouldEnable) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setIsDebug", shouldEnable); +#endif + } + + /// + /// By default, IMEI and Android ID are not collected by the SDK if the OS version is higher than KitKat (4.4) + /// and the device contains Google Play Services(on SDK versions 4.8.8 and below the specific app needed GPS). + /// Use this API to explicitly send IMEI to AppsFlyer. + /// + /// device's IMEI. + public void setImeiData(string aImei) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setImeiData", aImei); +#endif + } + + /// + /// By default, IMEI and Android ID are not collected by the SDK if the OS version is higher than KitKat(4.4) + /// and the device contains Google Play Services(on SDK versions 4.8.8 and below the specific app needed GPS). + /// Use this API to explicitly send Android ID to AppsFlyer. + /// + /// device's Android ID. + public void setAndroidIdData(string aAndroidId) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setAndroidIdData", aAndroidId); +#endif + } + + /// + /// Setting your own customer ID enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and the other devices’ IDs. + /// This ID is available in AppsFlyer CSV reports along with Postback APIs for cross-referencing with your internal IDs. + /// + /// Customer ID for client. + public void setCustomerUserId(string id) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setCustomerUserId", id); +#endif + } + + /// + /// It is possible to delay the SDK Initialization until the customerUserID is set. + /// This feature makes sure that the SDK doesn't begin functioning until the customerUserID is provided. + /// If this API is used, all in-app events and any other SDK API calls are discarded, until the customerUserID is provided. + /// + /// wait boolean. + public void waitForCustomerUserId(bool wait) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("waitForCustomerUserId", wait); +#endif + } + + /// + /// Use this API to provide the SDK with the relevant customer user id and trigger the SDK to begin its normal activity. + /// + /// Customer ID for client. + public void setCustomerIdAndStartSDK(string id) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setCustomerIdAndTrack", id); +#endif + } + + /// + /// Get the current AF_STORE value. + /// + /// AF_Store value. + public string getOutOfStore() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("getOutOfStore"); +#else + return ""; +#endif + } + + /// + /// Manually set the AF_STORE value. + /// + /// value to be set. + public void setOutOfStore(string sourceName) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setOutOfStore", sourceName); +#endif + } + + /// + /// Set the OneLink ID that should be used for User-Invites. + /// The link that is generated for the user invite will use this OneLink as the base link. + /// + /// OneLink ID obtained from the AppsFlyer Dashboard. + public void setAppInviteOneLinkID(string oneLinkId) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setAppInviteOneLinkID", oneLinkId); +#endif + } + + /// + /// Set additional data to be sent to AppsFlyer. + /// + /// additional data Dictionary. + public void setAdditionalData(Dictionary customData) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setAdditionalData", convertDictionaryToJavaMap(customData)); +#endif + } + + //// + /// Set the deepLink timeout value that should be used for DDL. + /// + /// deepLink timeout in milliseconds. + public void setDeepLinkTimeout(long deepLinkTimeout) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setDeepLinkTimeout", deepLinkTimeout); +#endif + } + + /// + /// Set the user emails. + /// + /// User emails. + public void setUserEmails(params string[] userEmails) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setUserEmails", (object)userEmails); +#endif + } + + + /// + /// Set the user phone number. + /// + /// User phoneNumber. + public void setPhoneNumber(string phoneNumber){ +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setPhoneNumber", phoneNumber); +#endif + } + + /// + /// Set the user emails and encrypt them. + /// cryptMethod Encryption method: + /// EmailCryptType.EmailCryptTypeMD5 + /// EmailCryptType.EmailCryptTypeSHA1 + /// EmailCryptType.EmailCryptTypeSHA256 + /// EmailCryptType.EmailCryptTypeNone + /// + /// Encryption method. + /// User emails. + public void setUserEmails(EmailCryptType cryptMethod, params string[] emails) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setUserEmails", getEmailType(cryptMethod), (object)emails); +#endif + } + + /// + /// Opt-out of collection of Android ID. + /// If the app does NOT contain Google Play Services, Android ID is collected by the SDK. + /// However, apps with Google play services should avoid Android ID collection as this is in violation of the Google Play policy. + /// + /// boolean, false to opt-out. + public void setCollectAndroidID(bool isCollect) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setCollectAndroidID", isCollect); +#endif + } + + /// + /// Opt-out of collection of IMEI. + /// If the app does NOT contain Google Play Services, device IMEI is collected by the SDK. + /// However, apps with Google play services should avoid IMEI collection as this is in violation of the Google Play policy. + /// + /// boolean, false to opt-out. + public void setCollectIMEI(bool isCollect) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setCollectIMEI", isCollect); +#endif + } + + /// + /// Advertisers can wrap AppsFlyer OneLink within another Universal Link. + /// This Universal Link will invoke the app but any deep linking data will not propagate to AppsFlyer. + /// + /// Array of urls. + public void setResolveDeepLinkURLs(params string[] urls) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setResolveDeepLinkURLs", (object)urls); +#endif + } + + + /// + /// Advertisers can use this method to set vanity onelink domains. + /// + /// Array of domains. + public void setOneLinkCustomDomain(params string[] domains) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setOneLinkCustomDomain", (object)domains); +#endif + } + + /// + /// Manually set that the application was updated. + /// + /// isUpdate boolean value. + public void setIsUpdate(bool isUpdate) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setIsUpdate", isUpdate); +#endif + } + + /// + /// Setting user local currency code for in-app purchases. + /// The currency code should be a 3 character ISO 4217 code. (default is USD). + /// You can set the currency code for all events by calling the following method. + /// + /// 3 character ISO 4217 code. + public void setCurrencyCode(string currencyCode) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setCurrencyCode", currencyCode); +#endif + } + + /// + /// Manually record the location of the user. + /// + /// latitude as double. + /// longitude as double. + public void recordLocation(double latitude, double longitude) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("trackLocation", latitude, longitude); +#endif + } + + /// + /// Send an In-App Event. + /// In-App Events provide insight on what is happening in your app. + /// + /// Event Name as String. + /// Event Values as Dictionary. + public void sendEvent(string eventName, Dictionary eventValues) + { + sendEvent(eventName, eventValues, false, AppsFlyer.CallBackObjectName); + } + + public void sendEvent(string eventName, Dictionary eventValues, bool shouldCallback, string callBackObjectName) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("trackEvent", eventName, convertDictionaryToJavaMap(eventValues), shouldCallback, callBackObjectName); +#endif + } + + /// + /// Anonymize user Data. + /// Use this API during the SDK Initialization to explicitly anonymize a user's installs, events and sessions. + /// Default is false. + /// + /// isDisabled boolean. + public void anonymizeUser(bool isDisabled) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setDeviceTrackingDisabled", isDisabled); +#endif + } + + /// + /// Calling enableTCFDataCollection(true) will enable collecting and sending any TCF related data. + /// Calling enableTCFDataCollection(false) will disable the collection of TCF related data and from sending it. + /// + /// should start TCF Data collection boolean. + public void enableTCFDataCollection(bool shouldCollectTcfData) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("enableTCFDataCollection", shouldCollectTcfData); +#endif + } + + /// + /// Enable the collection of Facebook Deferred AppLinks. + /// Requires Facebook SDK and Facebook app on target/client device. + /// This API must be invoked prior to initializing the AppsFlyer SDK in order to function properly. + /// + /// should Facebook's deferred app links be processed by the AppsFlyer SDK. + public void enableFacebookDeferredApplinks(bool isEnabled) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("enableFacebookDeferredApplinks", isEnabled); +#endif + } + + /// + /// Sets or updates the user consent data related to GDPR and DMA regulations for advertising and data usage purposes within the application. + /// call this method when GDPR user is true + /// + /// hasConsentForDataUsage boolean. + /// hasConsentForAdsPersonalization boolean. + public void setConsentData(AppsFlyerConsent appsFlyerConsent) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setConsentData", appsFlyerConsent.isUserSubjectToGDPR, appsFlyerConsent.hasConsentForDataUsage, appsFlyerConsent.hasConsentForAdsPersonalization); +#endif + } + + /// + /// Logs ad revenue data along with additional parameters if provided. + /// instance of AFAdRevenueData containing ad revenue information. + /// An optional map of additional parameters to be logged with ad revenue data. This can be null if there are no additional parameters. + public void logAdRevenue(AFAdRevenueData adRevenueData, Dictionary additionalParameters) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("logAdRevenue", adRevenueData.monetizationNetwork, getMediationNetwork(adRevenueData.mediationNetwork), adRevenueData.currencyIso4217Code, adRevenueData.eventRevenue, convertDictionaryToJavaMap(additionalParameters)); +#endif + } + + /// + /// Restrict reengagement via deep-link to once per each unique deep-link. + /// Otherwise deep re-occurring deep-links will be permitted for non-singleTask Activities and deep-linking via AppsFlyer deep-links. + /// The default value is false. + /// + /// doConsume boolean. + public void setConsumeAFDeepLinks(bool doConsume) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setConsumeAFDeepLinks", doConsume); +#endif + } + + /// + /// Specify the manufacturer or media source name to which the preinstall is attributed. + /// + /// Manufacturer or media source name for preinstall attribution. + /// Campaign name for preinstall attribution. + /// Site ID for preinstall attribution. + public void setPreinstallAttribution(string mediaSource, string campaign, string siteId) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setPreinstallAttribution", mediaSource, campaign, siteId); +#endif + } + + /// + /// Boolean indicator for preinstall by Manufacturer. + /// + /// boolean isPreInstalledApp. + public bool isPreInstalledApp() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("isPreInstalledApp"); +#else + return false; +#endif + } + + /// + /// Get the Facebook attribution ID, if one exists. + /// + /// string Facebook attribution ID. + public string getAttributionId() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("getAttributionId"); +#else + return ""; +#endif + } + + /// + /// Get AppsFlyer's unique device ID is created for every new install of an app. + /// + /// AppsFlyer's unique device ID. + public string getAppsFlyerId() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("getAppsFlyerId"); +#else + return ""; +#endif + } + + /// + /// 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. + /// + /// License Key obtained from the Google Play Console. + /// data.INAPP_DATA_SIGNATURE from onActivityResult(int requestCode, int resultCode, Intent data) + /// data.INAPP_PURCHASE_DATA from onActivityResult(int requestCode, int resultCode, Intent data) + /// Purchase price, should be derived from skuDetails.getStringArrayList("DETAILS_LIST") + /// Purchase currency, should be derived from skuDetails.getStringArrayList("DETAILS_LIST") + /// additionalParameters Freehand parameters to be sent with the purchase (if validated). + public void validateAndSendInAppPurchase(string publicKey, string signature, string purchaseData, string price, string currency, Dictionary additionalParameters, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("validateAndTrackInAppPurchase", publicKey, signature, purchaseData, price, currency, convertDictionaryToJavaMap(additionalParameters), gameObject ? gameObject.name : null); +#endif + } + + /// + /// 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. + /// + /// AFPurchaseDetailsAndroid instance. + /// additionalParameters Freehand parameters to be sent with the purchase (if validated). + public void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary additionalParameters, 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); +#endif + } + + /// + /// Was the stopSDK(boolean) API set to true. + /// + /// boolean isSDKStopped. + public bool isSDKStopped() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("isTrackingStopped"); +#else + return false; +#endif + } + + /// + /// Set a custom value for the minimum required time between sessions. + /// By default, at least 5 seconds must lapse between 2 app launches to count as separate 2 sessions. + /// + /// minimum time between 2 separate sessions in seconds. + public void setMinTimeBetweenSessions(int seconds) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setMinTimeBetweenSessions", seconds); +#endif + } + + /// + /// Set a custom host. + /// + /// Host prefix. + /// Host name. + public void setHost(string hostPrefixName, string hostName) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setHost", hostPrefixName, hostName); +#endif + } + + /// + /// Get the host name. + /// Default value is "appsflyer.com". + /// + /// Host name. + public string getHostName() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("getHostName"); +#else + return ""; +#endif + } + + /// + /// Get the custom host prefix. + /// + /// Host prefix. + public string getHostPrefix() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("getHostPrefix"); +#else + return ""; +#endif + } + + /// + /// Used by advertisers to exclude all networks/integrated partners from getting data. + /// + public void setSharingFilterForAllPartners() + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setSharingFilterForAllPartners"); +#endif + } + + /// + /// Used by advertisers to set some (one or more) networks/integrated partners to exclude from getting data. + /// + /// partners to exclude from getting data + public void setSharingFilter(params string[] partners) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setSharingFilter", (object)partners); +#endif + } + + /// + /// Lets you configure how which partners should the SDK exclude from data-sharing. + /// + /// partners to exclude from getting data + public static void setSharingFilterForPartners(params string[] partners) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setSharingFilterForPartners", (object)partners); +#endif + } + + /// + /// Register a Conversion Data Listener. + /// Allows the developer to access the user attribution data in real-time for every new install, directly from the SDK level. + /// By doing this you can serve users with personalized content or send them to specific activities within the app, + /// which can greatly enhance their engagement with your app. + /// + public void getConversionData(string objectName) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("getConversionData", objectName); +#endif + } + + /// + /// Register a validation listener for the validateAndSendInAppPurchase API. + /// + public void initInAppPurchaseValidatorListener(MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("initInAppPurchaseValidatorListener", gameObject ? gameObject.name : null); +#endif + } + + /// + /// setCollectOaid + /// You must include the appsflyer oaid library for this api to work. + /// + /// isCollect oaid - set fasle to opt out + public void setCollectOaid(bool isCollect) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setCollectOaid", isCollect); +#endif + } + + /// + /// Use the following API to attribute the click and launch the app store's app page. + /// + /// promoted App ID + /// cross promotion campaign + /// additional user params + public void attributeAndOpenStore(string promoted_app_id, string campaign, Dictionary userParams, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("attributeAndOpenStore", promoted_app_id, campaign, convertDictionaryToJavaMap(userParams)); +#endif + } + + /// + /// To attribute an impression use the following API call. + /// Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard. + /// + /// promoted App ID. + /// cross promotion campaign. + /// parameters Dictionary. + public void recordCrossPromoteImpression(string appID, string campaign, Dictionary parameters) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("recordCrossPromoteImpression", appID, campaign, convertDictionaryToJavaMap(parameters)); +#endif + } + + /// + /// The LinkGenerator class builds the invite URL according to various setter methods which allow passing on additional information on the click. + /// See - https://support.appsflyer.com/hc/en-us/articles/115004480866-User-invite-attribution- + /// + /// parameters Dictionary. + public void generateUserInviteLink(Dictionary parameters, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("createOneLinkInviteListener", convertDictionaryToJavaMap(parameters), gameObject ? gameObject.name : null); +#endif + } + + /// + /// To measure push notifications as part of a retargeting campaign. + /// + public void handlePushNotifications(){ +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("handlePushNotifications"); +#endif + } + + /// + /// Use this method if you’re integrating your app with push providers + /// that don’t use the default push notification JSON schema the SDK expects. + /// See docs for more info. + /// + /// array of nested json path + public void addPushNotificationDeepLinkPath(params string[] paths) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("addPushNotificationDeepLinkPath", (object)paths); +#endif + } + + /// + /// subscribe to unified deep link callbacks + /// + public void subscribeForDeepLink(string objectName){ +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("subscribeForDeepLink", objectName); +#endif + } + + /// + /// Disables collection of various Advertising IDs by the SDK. This includes Google Advertising ID (GAID), OAID and Amazon Advertising ID (AAID) + /// + /// disable boolean. + public void setDisableAdvertisingIdentifiers(bool disable) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setDisableAdvertisingIdentifiers", disable); +#endif + } + + /// + /// Allows sending custom data for partner integration purposes. + /// + public void setPartnerData(string partnerId, Dictionary partnerInfo) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setPartnerData", partnerId, convertDictionaryToJavaMap(partnerInfo)); +#endif + } + + /// + /// Use to opt-out of collecting the network operator name (carrier) and sim operator name from the device. + /// + public void setDisableNetworkData(bool disable) { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setDisableNetworkData", disable); +#endif + } + + /// + /// Internal Helper Method. + /// + private static AndroidJavaObject getEmailType(EmailCryptType cryptType) + { + AndroidJavaClass emailsCryptTypeEnum = new AndroidJavaClass("com.appsflyer.AppsFlyerProperties$EmailsCryptType"); + AndroidJavaObject emailsCryptType; + + switch (cryptType) + { + case EmailCryptType.EmailCryptTypeSHA256: + emailsCryptType = emailsCryptTypeEnum.GetStatic("SHA256"); + break; + default: + emailsCryptType = emailsCryptTypeEnum.GetStatic("NONE"); + break; + } + + return emailsCryptType; + } + + /// + /// Internal Helper Method. + /// + private static AndroidJavaObject getMediationNetwork(MediationNetwork mediationNetwork) + { + AndroidJavaClass mediationNetworkEnumClass = new AndroidJavaClass("com.appsflyer.MediationNetwork"); + AndroidJavaObject mediationNetworkObject; + + switch (mediationNetwork) + { + case MediationNetwork.IronSource: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("IRONSOURCE"); + break; + case MediationNetwork.ApplovinMax: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("APPLOVIN_MAX"); + break; + case MediationNetwork.GoogleAdMob: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("GOOGLE_ADMOB"); + break; + case MediationNetwork.Fyber: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("FYBER"); + break; + case MediationNetwork.Appodeal: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("APPODEAL"); + break; + case MediationNetwork.Admost: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("ADMOST"); + break; + case MediationNetwork.Topon: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("TOPON"); + break; + case MediationNetwork.Tradplus: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("TRADPLUS"); + break; + case MediationNetwork.Yandex: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("YANDEX"); + break; + case MediationNetwork.ChartBoost: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("CHARTBOOST"); + break; + case MediationNetwork.Unity: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("UNITY"); + break; + case MediationNetwork.ToponPte: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("TOPON_PTE"); + break; + case MediationNetwork.Custom: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("CUSTOM_MEDIATION"); + break; + case MediationNetwork.DirectMonetization: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("DIRECT_MONETIZATION_NETWORK"); + break; + default: + mediationNetworkObject = mediationNetworkEnumClass.GetStatic("NONE"); + break; + } + return mediationNetworkObject; + } + + /// + /// Internal Helper Method. + /// + private static AndroidJavaObject convertDictionaryToJavaMap(Dictionary dictionary) + { + AndroidJavaObject map = new AndroidJavaObject("java.util.HashMap"); + IntPtr putMethod = AndroidJNIHelper.GetMethodID(map.GetRawClass(), "put", "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + jvalue[] val; + if (dictionary != null) + { + foreach (var entry in dictionary) + { + val = AndroidJNIHelper.CreateJNIArgArray(new object[] { entry.Key, entry.Value }); + AndroidJNI.CallObjectMethod(map.GetRawObject(), putMethod,val); + AndroidJNI.DeleteLocalRef(val[0].l); + AndroidJNI.DeleteLocalRef(val[1].l); + } + } + + return map; + } + } +#endif + +} \ No newline at end of file diff --git a/AppsFlyerAndroid.cs.meta b/AppsFlyerAndroid.cs.meta new file mode 100644 index 00000000..d7ce7229 --- /dev/null +++ b/AppsFlyerAndroid.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 172d18dd98e7e4ed3b30110568b0fae4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyerConsent.cs b/AppsFlyerConsent.cs new file mode 100644 index 00000000..341e5308 --- /dev/null +++ b/AppsFlyerConsent.cs @@ -0,0 +1,51 @@ +using System; +using System.Collections.Generic; + +namespace AppsFlyerSDK +{ + /// + // Data class representing a user's consent for data processing in accordance with GDPR and DMA + // (Digital Markets Act) compliance, specifically regarding advertising preferences. + + // This class should be used to notify and record the user's applicability + // under GDPR, their general consent to data usage, and their consent to personalized + // advertisements based on user data. + + // Note that the consent for data usage and ads personalization pair is only applicable when the user is + // subject to GDPR guidelines. Therefore, the following factory methods should be used accordingly: + // - Use [forGDPRUser] when the user is subject to GDPR. + // - Use [forNonGDPRUser] when the user is not subject to GDPR. + + // @property isUserSubjectToGDPR Indicates whether GDPR regulations apply to the user (true if the user is + // a subject of GDPR). It also serves as a flag for compliance with relevant aspects of DMA regulations. + // @property hasConsentForDataUsage Indicates whether the user has consented to the use of their data for advertising + // purposes under both GDPR and DMA guidelines (true if the user has consented, nullable if not subject to GDPR). + // @property hasConsentForAdsPersonalization Indicates whether the user has consented to the use of their data for + // personalized advertising within the boundaries of GDPR and DMA rules (true if the user has consented to + // personalized ads, nullable if not subject to GDPR). + /// + public class AppsFlyerConsent + { + public bool isUserSubjectToGDPR { get; private set; } + public bool hasConsentForDataUsage { get; private set; } + public bool hasConsentForAdsPersonalization { get; private set; } + + private AppsFlyerConsent(bool isGDPR, bool hasForDataUsage, bool hasForAdsPersonalization) + { + isUserSubjectToGDPR = isGDPR; + hasConsentForDataUsage = hasForDataUsage; + hasConsentForAdsPersonalization = hasForAdsPersonalization; + } + + public static AppsFlyerConsent ForGDPRUser(bool hasConsentForDataUsage, bool hasConsentForAdsPersonalization) + { + return new AppsFlyerConsent(true, hasConsentForDataUsage, hasConsentForAdsPersonalization); + } + + public static AppsFlyerConsent ForNonGDPRUser() + { + return new AppsFlyerConsent(false, false, false); + } + } + +} \ No newline at end of file diff --git a/AppsFlyerConsent.cs.meta b/AppsFlyerConsent.cs.meta new file mode 100644 index 00000000..5a881dee --- /dev/null +++ b/AppsFlyerConsent.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a97c986fe4ee0461badf7042e08db3f3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyerEventArgs.cs b/AppsFlyerEventArgs.cs new file mode 100644 index 00000000..511db67d --- /dev/null +++ b/AppsFlyerEventArgs.cs @@ -0,0 +1,218 @@ +using System; +using System.Collections.Generic; + +namespace AppsFlyerSDK +{ + + /// + /// Event args for AppsFlyer requests. + /// Used for sessions and in-app events. + /// Used to handle post request logic. + /// + /// Examples: + /// statusCode / errorDescription + /// + /// 200 - null + /// + /// 10 - "Event timeout. Check 'minTimeBetweenSessions' param" + /// 11 - "Skipping event because 'isStopTracking' enabled" + /// 40 - Network error: Error description comes from Android + /// 41 - "No dev key" + /// 50 - "Status code failure" + actual response code from the server + /// + /// + public class AppsFlyerRequestEventArgs : EventArgs + { + public AppsFlyerRequestEventArgs(int code, string description) + { + statusCode = code; + errorDescription = description; + } + + public int statusCode { get; } + public string errorDescription { get; } + } + + /// + /// Event args for OnDeepLinkReceived. + /// Used to handle deep linking results. + /// + public class DeepLinkEventsArgs : EventArgs + { + + /// + /// DeepLink dictionary to get additional parameters + /// + public Dictionary deepLink; + + /// + /// DeepLink status: FOUND, NOT_FOUND, ERROR + /// + public DeepLinkStatus status { get; } + + /// + /// DeepLink error: TIMEOUT, NETWORK, HTTP_STATUS_CODE, UNEXPECTED + /// + public DeepLinkError error { get; } + + public string getMatchType() + { + return getDeepLinkParameter("match_type"); + } + + public string getDeepLinkValue() + { + return getDeepLinkParameter("deep_link_value"); + } + + public string getClickHttpReferrer() + { + return getDeepLinkParameter("click_http_referrer"); + } + + public string getMediaSource() + { + return getDeepLinkParameter("media_source"); + } + + public string getCampaign() + { + return getDeepLinkParameter("campaign"); + } + + public string getCampaignId() + { + return getDeepLinkParameter("campaign_id"); + } + + public string getAfSub1() + { + return getDeepLinkParameter("af_sub1"); + } + + public string getAfSub2() + { + return getDeepLinkParameter("af_sub2"); + } + + public string getAfSub3() + { + return getDeepLinkParameter("af_sub3"); + } + + public string getAfSub4() + { + return getDeepLinkParameter("af_sub4"); + } + + public string getAfSub5() + { + return getDeepLinkParameter("af_sub5"); + } + + public bool isDeferred() + { + if (deepLink != null && deepLink.ContainsKey("is_deferred")) + { + try + { + return (bool)deepLink["is_deferred"]; + } + catch (Exception e) + { + AppsFlyer.AFLog("DeepLinkEventsArgs.isDeferred", String.Format("{0} Exception caught.", e)); + } + } + return false; + } + + public Dictionary getDeepLinkDictionary() + { + return deepLink; + } + + public DeepLinkEventsArgs(string str) + { + try + { + Dictionary dictionary = AppsFlyer.CallbackStringToDictionary(str); + + string status = ""; + string error = ""; + + + if (dictionary.ContainsKey("status") && dictionary["status"] != null) + { + status = dictionary["status"].ToString(); + } + + if (dictionary.ContainsKey("error") && dictionary["error"] != null) + { + error = dictionary["error"].ToString(); + } + + if (dictionary.ContainsKey("deepLink") && dictionary["deepLink"] != null) + { + this.deepLink = AppsFlyer.CallbackStringToDictionary(dictionary["deepLink"].ToString()); + } + if (dictionary.ContainsKey("is_deferred")) + { + this.deepLink["is_deferred"] = dictionary["is_deferred"]; + } + + switch (status) + { + case "FOUND": + this.status = DeepLinkStatus.FOUND; + break; + case "NOT_FOUND": + this.status = DeepLinkStatus.NOT_FOUND; + break; + default: + this.status = DeepLinkStatus.ERROR; + break; + } + + switch (error) + { + case "TIMEOUT": + this.error = DeepLinkError.TIMEOUT; + break; + case "NETWORK": + this.error = DeepLinkError.NETWORK; + break; + case "HTTP_STATUS_CODE": + this.error = DeepLinkError.HTTP_STATUS_CODE; + break; + default: + this.error = DeepLinkError.UNEXPECTED; + break; + } + + } + catch (Exception e) + { + AppsFlyer.AFLog("DeepLinkEventsArgs.parseDeepLink", String.Format("{0} Exception caught.", e)); + } + } + + private string getDeepLinkParameter(string name) + { + if (deepLink != null && deepLink.ContainsKey(name) && deepLink[name] != null) + { + return deepLink[name].ToString(); + } + + return null; + } + + } + + public enum DeepLinkStatus { + FOUND, NOT_FOUND, ERROR + } + + public enum DeepLinkError { + TIMEOUT, NETWORK, HTTP_STATUS_CODE, UNEXPECTED + } +} diff --git a/AppsFlyerEventArgs.cs.meta b/AppsFlyerEventArgs.cs.meta new file mode 100644 index 00000000..056bce27 --- /dev/null +++ b/AppsFlyerEventArgs.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: a0fc241ad5a9b43a7b461a6147dbc74c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyerObject.prefab b/AppsFlyerObject.prefab new file mode 100644 index 00000000..f3bbb450 --- /dev/null +++ b/AppsFlyerObject.prefab @@ -0,0 +1,49 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &7315102894599890749 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6207133488976360133} + - component: {fileID: 4405976200006927252} + m_Layer: 0 + m_Name: AppsFlyerObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6207133488976360133 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7315102894599890749} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!114 &4405976200006927252 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7315102894599890749} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2a2ec6ba1ee8b48749524f015ed572a6, type: 3} + m_Name: + m_EditorClassIdentifier: + devKey: + appID: + isDebug: 0 + getConversionData: 0 diff --git a/AppsFlyerObject.prefab.meta b/AppsFlyerObject.prefab.meta new file mode 100644 index 00000000..1acd1cf9 --- /dev/null +++ b/AppsFlyerObject.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0bfe3b149145747cc92dc53bb4df4e9b +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyerObjectScript.cs b/AppsFlyerObjectScript.cs new file mode 100644 index 00000000..266a848c --- /dev/null +++ b/AppsFlyerObjectScript.cs @@ -0,0 +1,70 @@ +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 appID; + public string UWPAppID; + public string macOSAppID; + public bool isDebug; + public bool getConversionData; + //******************************// + + + void Start() + { + // These fields are set from the editor so do not modify! + //******************************// + AppsFlyer.setIsDebug(isDebug); +#if UNITY_WSA_10_0 && !UNITY_EDITOR + AppsFlyer.initSDK(devKey, UWPAppID, getConversionData ? this : null); +#elif UNITY_STANDALONE_OSX && !UNITY_EDITOR + AppsFlyer.initSDK(devKey, macOSAppID, 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 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 attributionDataDictionary = AppsFlyer.CallbackStringToDictionary(attributionData); + // add direct deeplink logic here + } + + public void onAppOpenAttributionFailure(string error) + { + AppsFlyer.AFLog("onAppOpenAttributionFailure", error); + } + +} diff --git a/AppsFlyerObjectScript.cs.meta b/AppsFlyerObjectScript.cs.meta new file mode 100644 index 00000000..65ccedc6 --- /dev/null +++ b/AppsFlyerObjectScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2a2ec6ba1ee8b48749524f015ed572a6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyeriOS.cs b/AppsFlyeriOS.cs new file mode 100644 index 00000000..c7907989 --- /dev/null +++ b/AppsFlyeriOS.cs @@ -0,0 +1,1016 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; +using System.Reflection; + + + +namespace AppsFlyerSDK +{ + +#if UNITY_IOS || UNITY_STANDALONE_OSX + + public class AppsFlyeriOS: IAppsFlyerIOSBridge + { + public bool isInit { get; set; } + + public AppsFlyeriOS() { } + + public AppsFlyeriOS(string devKey, string appID, MonoBehaviour gameObject) + { + setAppsFlyerDevKey(devKey); + setAppleAppID(appID); + if (gameObject != null) + { +#if UNITY_IOS + getConversionData(gameObject.name); +#elif UNITY_STANDALONE_OSX + getConversionData(gameObject.GetType().ToString()); +#endif + } + } + + + + /// + /// Start Session. + /// This will record a session and then record all background forground sessions during the lifecycle of the app. + /// +public void startSDK(bool shouldCallback, string CallBackObjectName) + { +#if UNITY_STANDALONE_OSX && !UNITY_EDITOR + _startSDK(shouldCallback, CallBackObjectName, getCallback); +#elif UNITY_IOS && !UNITY_EDITOR + _startSDK(shouldCallback, CallBackObjectName); +#endif + } + + /// + /// Send an In-App Event. + /// In-App Events provide insight on what is happening in your app. + /// + /// Name of event. + /// Contains dictionary of values for handling by backend. + public void sendEvent(string eventName, Dictionary eventValues) + { + sendEvent(eventName, eventValues, false, AppsFlyer.CallBackObjectName); + } + + public void sendEvent(string eventName, Dictionary eventValues, bool shouldCallback, string callBackObjectName) + { +#if !UNITY_EDITOR + _afSendEvent(eventName, AFMiniJSON.Json.Serialize(eventValues), shouldCallback, callBackObjectName); +#endif + } + + /// + /// Get the conversion data. + /// Allows the developer to access the user attribution data in real-time for every new install, directly from the SDK level. + /// By doing this you can serve users with personalized content or send them to specific activities within the app, + /// which can greatly enhance their engagement with your app. + /// + public void getConversionData(string objectName) + { +#if !UNITY_EDITOR + _getConversionData(objectName); +#endif + } + + /// + /// In case you use your own user ID in your app, you can set this property to that ID. + /// Enables you to cross-reference your own unique ID with AppsFlyer’s unique ID and the other devices’ IDs. + /// + /// Customer ID for client. + public void setCustomerUserId(string customerUserID) + { +#if !UNITY_EDITOR + _setCustomerUserID(customerUserID); +#endif + } + + /// + /// In case you use custom data and you want to receive it in the raw reports. + /// see [Setting additional custom data] (https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS#setting-additional-custom-data) for more information. + /// + /// additional data Dictionary. + public void setAdditionalData(Dictionary customData) + { +#if !UNITY_EDITOR + _setAdditionalData(AFMiniJSON.Json.Serialize(customData)); +#endif + } + + /// + /// Use this method to set your AppsFlyer's dev key. + /// + /// AppsFlyer's Dev-Key, which is accessible from your AppsFlyer account under 'App Settings' in the dashboard. + public void setAppsFlyerDevKey(string appsFlyerDevKey) + { +#if !UNITY_EDITOR + _setAppsFlyerDevKey(appsFlyerDevKey); +#endif + } + + /// + /// Use this method to set your app's Apple ID(taken from the app's page on iTunes Connect). + /// + /// your app's Apple ID. + public void setAppleAppID(string appleAppID) + { +#if !UNITY_EDITOR + _setAppleAppID(appleAppID); +#endif + } + + /// + /// Setting user local currency code for in-app purchases. + /// The currency code should be a 3 character ISO 4217 code. (default is USD). + /// You can set the currency code for all events by calling the following method. + /// + /// 3 character ISO 4217 code. + public void setCurrencyCode(string currencyCode) + { +#if !UNITY_EDITOR + _setCurrencyCode(currencyCode); +#endif + } + + /// + /// AppsFlyer SDK collect Apple's `advertisingIdentifier` if the `AdSupport.framework` included in the SDK. + /// You can disable this behavior by setting the following property to true. + /// + /// boolean to disableCollectAppleAdSupport + public void setDisableCollectAppleAdSupport(bool disableCollectAppleAdSupport) + { +#if !UNITY_EDITOR + _setDisableCollectAppleAdSupport(disableCollectAppleAdSupport); +#endif + } + + /// + /// Enables Debug logs for the AppsFlyer SDK. + /// Should only be set to true in development / debug. + /// The default value is false. + /// + /// shouldEnable boolean.. + public void setIsDebug(bool isDebug) + { +#if !UNITY_EDITOR + _setIsDebug(isDebug); +#endif + } + + /// + /// Set this flag to true, to collect the current device name(e.g. "My iPhone"). Default value is false. + /// + /// boolean shouldCollectDeviceName. + [System.Obsolete("This is deprecated")] + public void setShouldCollectDeviceName(bool shouldCollectDeviceName) + { +#if !UNITY_EDITOR + _setShouldCollectDeviceName(shouldCollectDeviceName); +#endif + } + + /// + /// Set the OneLink ID that should be used for User-Invites. + /// The link that is generated for the user invite will use this OneLink as the base link. + /// + /// OneLink ID obtained from the AppsFlyer Dashboard. + public void setAppInviteOneLinkID(string appInviteOneLinkID) + { +#if !UNITY_EDITOR + _setAppInviteOneLinkID(appInviteOneLinkID); +#endif + } + + /// + /// Set the deepLink timeout value that should be used for DDL. + /// + /// deepLink timeout in milliseconds. + public void setDeepLinkTimeout(long deepLinkTimeout) + { +#if !UNITY_EDITOR + _setDeepLinkTimeout(deepLinkTimeout); +#endif + } + + /// + /// Calling enableTCFDataCollection(true) will enable collecting and sending any TCF related data. + /// Calling enableTCFDataCollection(false) will disable the collection of TCF related data and from sending it. + /// + /// should start TCF Data collection boolean. + public void enableTCFDataCollection(bool shouldCollectTcfData) + { +#if !UNITY_EDITOR + _enableTCFDataCollection(shouldCollectTcfData); +#endif + } + + /// + /// Sets or updates the user consent data related to GDPR and DMA regulations for advertising and data usage purposes within the application. + /// + /// instance of AppsFlyerConsent. + public void setConsentData(AppsFlyerConsent appsFlyerConsent) + { +#if !UNITY_EDITOR + _setConsentData(appsFlyerConsent.isUserSubjectToGDPR, appsFlyerConsent.hasConsentForDataUsage, appsFlyerConsent.hasConsentForAdsPersonalization); +#endif + } + + /// + /// Logs ad revenue data along with additional parameters if provided. + /// + /// instance of AFAdRevenueData containing ad revenue information. + /// An optional map of additional parameters to be logged with ad revenue data. This can be null if there are no additional parameters. + public void logAdRevenue(AFAdRevenueData adRevenueData, Dictionary additionalParameters) + { +#if !UNITY_EDITOR + _logAdRevenue(adRevenueData.monetizationNetwork, adRevenueData.mediationNetwork, adRevenueData.currencyIso4217Code, adRevenueData.eventRevenue, AFMiniJSON.Json.Serialize(additionalParameters)); +#endif + } + + /// + /// Anonymize user Data. + /// Use this API during the SDK Initialization to explicitly anonymize a user's installs, events and sessions. + /// Default is false + /// + /// boolean shouldAnonymizeUser. + public void anonymizeUser(bool shouldAnonymizeUser) + { +#if !UNITY_EDITOR + _anonymizeUser(shouldAnonymizeUser); +#endif + } + + /// + /// Opt-out for Apple Search Ads attributions. + /// + /// boolean disableCollectIAd. + public void setDisableCollectIAd(bool disableCollectIAd) + { +#if !UNITY_EDITOR + _setDisableCollectIAd(disableCollectIAd); +#endif + } + + /// + /// In app purchase receipt validation Apple environment(production or sandbox). The default value is false. + /// + /// boolean useReceiptValidationSandbox. + public void setUseReceiptValidationSandbox(bool useReceiptValidationSandbox) + { +#if !UNITY_EDITOR + _setUseReceiptValidationSandbox(useReceiptValidationSandbox); +#endif + } + + /// + /// Set this flag to test uninstall on Apple environment(production or sandbox). The default value is false. + /// + /// boolean useUninstallSandbox. + public void setUseUninstallSandbox(bool useUninstallSandbox) + { +#if !UNITY_EDITOR + _setUseUninstallSandbox(useUninstallSandbox); +#endif + } + + /// + /// For advertisers who wrap OneLink within another Universal Link. + /// An advertiser will be able to deeplink from a OneLink wrapped within another Universal Link and also record this retargeting conversion. + /// + /// Array of urls. + public void setResolveDeepLinkURLs(params string[] resolveDeepLinkURLs) + { +#if !UNITY_EDITOR + _setResolveDeepLinkURLs(resolveDeepLinkURLs.Length,resolveDeepLinkURLs); +#endif + } + + /// + /// For advertisers who use vanity OneLinks. + /// + /// Array of domains. + public void setOneLinkCustomDomain(params string[] oneLinkCustomDomains) + { +#if !UNITY_EDITOR + _setOneLinkCustomDomains(oneLinkCustomDomains.Length, oneLinkCustomDomains); +#endif + } + + /// + /// Set the user emails and encrypt them. + /// cryptMethod Encryption method: + /// EmailCryptType.EmailCryptTypeMD5 + /// EmailCryptType.EmailCryptTypeSHA1 + /// EmailCryptType.EmailCryptTypeSHA256 + /// EmailCryptType.EmailCryptTypeNone + /// + /// type Hash algoritm. + /// length of userEmails array. + /// userEmails The list of strings that hold mails.} + + public void setUserEmails(EmailCryptType cryptType, params string[] userEmails) + { +#if !UNITY_EDITOR + _setUserEmails(cryptType, userEmails.Length, userEmails); +#endif + } + + /// + /// Set the user phone number. + /// + /// User phoneNumber. + public void setPhoneNumber(string phoneNumber){ +#if !UNITY_EDITOR + _setPhoneNumber(phoneNumber); +#endif + } + + /// + /// To send and validate in app purchases you can call this method from the processPurchase method - please use v2. + /// + /// The product identifier. + /// The product price. + /// The product currency. + /// The purchase transaction Id. + /// The additional param, which you want to receive it in the raw reports. + public void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string transactionId, Dictionary additionalParameters, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + _validateAndSendInAppPurchase(productIdentifier, price, currency, transactionId, AFMiniJSON.Json.Serialize(additionalParameters), gameObject ? gameObject.name : null); +#endif + } + + /// + /// V2 + /// To send and validate in app purchases you can call this method from the processPurchase method. + /// + /// The AFSDKPurchaseDetailsIOS instance. + /// The extra params, which you want to receive it in the raw reports. + public void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary extraEventValues, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + _validateAndSendInAppPurchaseV2(details.productId, details.price, details.currency, details.transactionId, AFMiniJSON.Json.Serialize(extraEventValues), gameObject ? gameObject.name : null); +#endif + } + + /// + /// To record location for geo-fencing. Does the same as code below. + /// + /// The location longitude. + /// The location latitude. + public void recordLocation(double longitude, double latitude) + { +#if !UNITY_EDITOR + _recordLocation(longitude, latitude); +#endif + } + + /// + /// Get AppsFlyer's unique device ID, which is created for every new install of an app. + /// + public string getAppsFlyerId() + { +#if !UNITY_EDITOR + return _getAppsFlyerId(); +#else + return ""; +#endif + } + + /// + /// Register uninstall - you should register for remote notification and provide AppsFlyer the push device token. + /// + /// deviceToken The `deviceToken` from `-application:didRegisterForRemoteNotificationsWithDeviceToken:`. + public void registerUninstall(byte[] deviceToken) + { +#if !UNITY_EDITOR + _registerUninstall(deviceToken); +#endif + } + + /// + /// Enable AppsFlyer to handle a push notification. + /// + /// pushPayload The `userInfo` from received remote notification. One of root keys should be @"af".. + public void handlePushNotification(Dictionary pushPayload) + { +#if !UNITY_EDITOR + _handlePushNotification(AFMiniJSON.Json.Serialize(pushPayload)); +#endif + } + + /// + /// Get SDK version. + /// + public string getSdkVersion() + { +#if !UNITY_EDITOR + return _getSDKVersion(); +#else + return ""; +#endif + } + + /// + /// This property accepts a string value representing the host name for all endpoints. + /// Can be used to Zero rate your application’s data usage.Contact your CSM for more information. + /// + /// Host Name. + /// Host prefix. + public void setHost(string hostPrefix, string host) + { +#if !UNITY_EDITOR + _setHost(host, hostPrefix); +#endif + } + + /// + /// This property is responsible for timeout between sessions in seconds. + /// Default value is 5 seconds. + /// + /// minimum time between 2 separate sessions in seconds. + public void setMinTimeBetweenSessions(int minTimeBetweenSessions) + { +#if !UNITY_EDITOR + _setMinTimeBetweenSessions(minTimeBetweenSessions); +#endif + } + + /// + /// Once this API is invoked, our SDK no longer communicates with our servers and stops functioning. + /// In some extreme cases you might want to shut down all SDK activity due to legal and privacy compliance. + /// This can be achieved with the stopSDK API. + /// + /// boolean isSDKStopped. + public void stopSDK(bool isSDKStopped) + { +#if !UNITY_EDITOR + _stopSDK(isSDKStopped); +#endif + } + + // + /// Was the stopSDK(boolean) API set to true. + /// + /// boolean isSDKStopped. + public bool isSDKStopped() + { +#if !UNITY_EDITOR + return _isSDKStopped(); +#else + return false; +#endif + } + + /// + /// In case you want to track deep linking manually call handleOpenUrl. + /// The continueUserActivity and onOpenURL are implemented in the AppsFlyerAppController.mm class, so + /// only use this method if the other methods do not cover your apps deeplinking needs. + /// + /// The URL to be passed to your AppDelegate. + /// The sourceApplication to be passed to your AppDelegate. + /// The annotation to be passed to your app delegate. + public void handleOpenUrl(string url, string sourceApplication, string annotation) + { +#if !UNITY_EDITOR + _handleOpenUrl(url, sourceApplication, annotation); +#endif + } + + /// + /// Used by advertisers to exclude all networks/integrated partners from getting data. + /// + public void setSharingFilterForAllPartners() + { +#if !UNITY_EDITOR + _setSharingFilterForAllPartners(); +#endif + } + + /// + /// Used by advertisers to set some (one or more) networks/integrated partners to exclude from getting data. + /// + /// partners to exclude from getting data + public void setSharingFilter(params string[] partners) + { +#if !UNITY_EDITOR + _setSharingFilter(partners.Length, partners); +#endif + } + + + /// + /// Lets you configure how which partners should the SDK exclude from data-sharing. + /// partners to exclude from getting data + public static void setSharingFilterForPartners(params string[] partners) + { +#if !UNITY_EDITOR + _setSharingFilterForPartners(partners.Length, partners); +#endif + } + + /// + /// To record an impression use the following API call. + /// Make sure to use the promoted App ID as it appears within the AppsFlyer dashboard. + /// + /// promoted App ID. + /// cross promotion campaign. + /// parameters Dictionary. + public void recordCrossPromoteImpression(string appID, string campaign, Dictionary parameters) + { +#if !UNITY_EDITOR + _recordCrossPromoteImpression(appID, campaign, AFMiniJSON.Json.Serialize(parameters)); +#endif + } + + /// + /// Use the following API to attribute the click and launch the app store's app page. + /// + /// promoted App ID + /// cross promotion campaign + /// additional user params + public void attributeAndOpenStore(string appID, string campaign, Dictionary parameters, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + _attributeAndOpenStore(appID, campaign, AFMiniJSON.Json.Serialize(parameters), gameObject ? gameObject.name : null); +#endif + } + + /// + /// The LinkGenerator class builds the invite URL according to various setter methods which allow passing on additional information on the click. + /// See - https://support.appsflyer.com/hc/en-us/articles/115004480866-User-invite-attribution- + /// + /// parameters Dictionary. + public void generateUserInviteLink(Dictionary parameters, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + _generateUserInviteLink(AFMiniJSON.Json.Serialize(parameters), gameObject ? gameObject.name : null); +#endif + } + + /// + /// It is recommended to generate an in-app event after the invite is sent to record the invites from the senders' perspective. + /// This enables you to find the users that tend most to invite friends, and the media sources that get you these users. + /// + /// channel string. + /// parameters Dictionary.. + public void recordInvite(string channel, Dictionary parameters) + { +#if !UNITY_EDITOR + _recordInvite(channel, AFMiniJSON.Json.Serialize(parameters)); +#endif + } + + /// + /// Waits for request user authorization to access app-related data + /// + /// time to wait until session starts + public void waitForATTUserAuthorizationWithTimeoutInterval(int timeoutInterval) + { +#if !UNITY_EDITOR + _waitForATTUserAuthorizationWithTimeoutInterval(timeoutInterval); +#endif + } + + /// + /// + /// bool should diable + public void disableSKAdNetwork(bool isDisabled) + { +#if !UNITY_EDITOR + _disableSKAdNetwork(isDisabled); +#endif + } + + /// + /// Use this method if you’re integrating your app with push providers + /// that don’t use the default push notification JSON schema the SDK expects. + /// See docs for more info. + /// + /// array of nested json path + public void addPushNotificationDeepLinkPath(params string[] paths) + { +#if !UNITY_EDITOR + _addPushNotificationDeepLinkPath(paths.Length, paths); +#endif + } + + /// + /// subscribe to unified deep link callbacks + /// + public void subscribeForDeepLink(string objectName){ +#if !UNITY_EDITOR + _subscribeForDeepLink(objectName); +#endif + } + + /// + /// Set the language of the device. + /// + public void setCurrentDeviceLanguage(string language){ +#if !UNITY_EDITOR + _setCurrentDeviceLanguage(language); +#endif + } + + /// + /// Allows sending custom data for partner integration purposes. + /// + public void setPartnerData(string partnerId, Dictionary partnerInfo){ +#if !UNITY_EDITOR + _setPartnerData(partnerId, AFMiniJSON.Json.Serialize(partnerInfo)); +#endif + } + + /// + /// Use to disable app vendor identifier (IDFV) collection, 'true' to disable. + /// + public void disableIDFVCollection(bool isDisabled){ +#if !UNITY_EDITOR + _disableIDFVCollection(isDisabled); +#endif + } + + delegate void unityCallBack(string message); + + [AOT.MonoPInvokeCallback(typeof(unityCallBack))] + public static void getCallback(string gameObjectName, string callbackName, string message) + { + GameObject go = GameObject.Find("AppsFlyerObject"); + var afscript = go.GetComponent("AppsFlyerObjectScript") as AppsFlyerObjectScript; + Type type = typeof(AppsFlyerObjectScript); + MethodInfo info = type.GetMethod(callbackName); + info.Invoke(afscript, new[] { message }); + + } + + + /* + * AppsFlyer ios method mapping + */ + + +#if UNITY_IOS + [DllImport("__Internal")] + private static extern void _startSDK(bool shouldCallback, string objectName); +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] + private static extern void _startSDK(bool shouldCallback, string objectName, Action getCallback); + +#endif + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _getConversionData(string objectName); + + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setCustomerUserID(string customerUserID); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setAdditionalData(string customData); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setAppsFlyerDevKey(string appsFlyerDevKey); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setAppleAppID(string appleAppID); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setCurrencyCode(string currencyCode); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setDisableCollectAppleAdSupport(bool disableCollectAppleAdSupport); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setIsDebug(bool isDebug); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setShouldCollectDeviceName(bool shouldCollectDeviceName); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setAppInviteOneLinkID(string appInviteOneLinkID); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setDeepLinkTimeout(long deepLinkTimeout); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _anonymizeUser(bool shouldAnonymizeUser); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _enableTCFDataCollection(bool shouldCollectTcfData); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setConsentData(bool isUserSubjectToGDPR, bool hasConsentForDataUsage, bool hasConsentForAdsPersonalization); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _logAdRevenue(string monetizationNetwork, MediationNetwork mediationNetwork, string currencyIso4217Code, double eventRevenue, string additionalParameters); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setDisableCollectIAd(bool disableCollectIAd); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setUseReceiptValidationSandbox(bool useReceiptValidationSandbox); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setUseUninstallSandbox(bool useUninstallSandbox); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setResolveDeepLinkURLs(int length, params string[] resolveDeepLinkURLs); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setOneLinkCustomDomains(int length, params string[] oneLinkCustomDomains); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setUserEmails(EmailCryptType cryptType, int length, params string[] userEmails); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setPhoneNumber(string phoneNumber); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _afSendEvent(string eventName, string eventValues, bool shouldCallback, string objectName); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string transactionId, string additionalParameters, string objectName); + + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _validateAndSendInAppPurchaseV2(string product, string price, string currency, string transactionId, string extraEventValues, string objectName); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _recordLocation(double longitude, double latitude); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern string _getAppsFlyerId(); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _registerUninstall(byte[] deviceToken); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _handlePushNotification(string pushPayload); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern string _getSDKVersion(); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setHost(string host, string hostPrefix); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setMinTimeBetweenSessions(int minTimeBetweenSessions); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _stopSDK(bool isStopSDK); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern bool _isSDKStopped(); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _handleOpenUrl(string url, string sourceApplication, string annotation); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setSharingFilterForAllPartners(); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setSharingFilter(int length, params string[] partners); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setSharingFilterForPartners(int length, params string[] partners); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _recordCrossPromoteImpression(string appID, string campaign, string parameters); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _attributeAndOpenStore(string appID, string campaign, string parameters, string gameObject); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _generateUserInviteLink(string parameters, string gameObject); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _recordInvite(string channel, string parameters); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _waitForATTUserAuthorizationWithTimeoutInterval(int timeoutInterval); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _disableSKAdNetwork(bool isDisabled); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _addPushNotificationDeepLinkPath(int length, params string[] paths); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _subscribeForDeepLink(string objectName); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setCurrentDeviceLanguage(string language); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _setPartnerData(string partnerId, string partnerInfo); + +#if UNITY_IOS + [DllImport("__Internal")] +#elif UNITY_STANDALONE_OSX + [DllImport("AppsFlyerBundle")] +#endif + private static extern void _disableIDFVCollection(bool isDisabled); + + } + +#endif + + +} \ No newline at end of file diff --git a/AppsFlyeriOS.cs.meta b/AppsFlyeriOS.cs.meta new file mode 100644 index 00000000..36b719fc --- /dev/null +++ b/AppsFlyeriOS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: b34371b3cc09641ebb007ffc4e9500f0 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor.meta b/Editor.meta new file mode 100644 index 00000000..a7682127 --- /dev/null +++ b/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9f84c02aa78da4ac9b444d98d97f7cc4 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/AppsFlyer.Editor.asmdef b/Editor/AppsFlyer.Editor.asmdef new file mode 100644 index 00000000..a63b5278 --- /dev/null +++ b/Editor/AppsFlyer.Editor.asmdef @@ -0,0 +1,17 @@ +{ + "name": "AppsFlyer.Editor", + "references": [ + "AppsFlyer" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Editor/AppsFlyer.Editor.asmdef.meta b/Editor/AppsFlyer.Editor.asmdef.meta new file mode 100644 index 00000000..f61dfd3b --- /dev/null +++ b/Editor/AppsFlyer.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d008146f00dea44d38752b4289e5f65b +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/AppsFlyerDependencies.xml b/Editor/AppsFlyerDependencies.xml new file mode 100644 index 00000000..70624d15 --- /dev/null +++ b/Editor/AppsFlyerDependencies.xml @@ -0,0 +1,18 @@ + + + + + + + + + + + + + + + + + + diff --git a/Editor/AppsFlyerDependencies.xml.meta b/Editor/AppsFlyerDependencies.xml.meta new file mode 100644 index 00000000..1e4d57ec --- /dev/null +++ b/Editor/AppsFlyerDependencies.xml.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a03558dbbfeac45db9afe9e9c2df5a85 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/AppsFlyerObjectEditor.cs b/Editor/AppsFlyerObjectEditor.cs new file mode 100644 index 00000000..f18e3fa5 --- /dev/null +++ b/Editor/AppsFlyerObjectEditor.cs @@ -0,0 +1,84 @@ +using UnityEditor; +using UnityEngine; + + +[CustomEditor(typeof(AppsFlyerObjectScript))] +[CanEditMultipleObjects] +public class AppsFlyerObjectEditor : Editor +{ + + SerializedProperty devKey; + SerializedProperty appID; + SerializedProperty UWPAppID; + SerializedProperty macOSAppID; + SerializedProperty isDebug; + SerializedProperty getConversionData; + + + void OnEnable() + { + devKey = serializedObject.FindProperty("devKey"); + appID = serializedObject.FindProperty("appID"); + UWPAppID = serializedObject.FindProperty("UWPAppID"); + macOSAppID = serializedObject.FindProperty("macOSAppID"); + isDebug = serializedObject.FindProperty("isDebug"); + getConversionData = serializedObject.FindProperty("getConversionData"); + } + + + + public override void OnInspectorGUI() + { + serializedObject.Update(); + + GUILayout.Box((Texture)AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(AssetDatabase.FindAssets("appsflyer_logo")[0]), typeof(Texture)), new GUILayoutOption[] { GUILayout.Width(600) }); + + 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); + + EditorGUILayout.PropertyField(devKey); + EditorGUILayout.PropertyField(appID); + EditorGUILayout.PropertyField(UWPAppID); + EditorGUILayout.PropertyField(macOSAppID); + EditorGUILayout.Separator(); + EditorGUILayout.HelpBox("Enable get conversion data to allow your app to recive deeplinking callbacks", MessageType.None); + EditorGUILayout.PropertyField(getConversionData); + EditorGUILayout.Separator(); + EditorGUILayout.HelpBox("Debugging should be restricted to development phase only.\n Do not distribute the app to app stores with debugging enabled", MessageType.Warning); + EditorGUILayout.PropertyField(isDebug); + EditorGUILayout.Separator(); + + EditorGUILayout.HelpBox("For more information on setting up AppsFlyer check out our relevant docs.", MessageType.None); + + + if (GUILayout.Button("AppsFlyer Unity Docs", new GUILayoutOption[] { GUILayout.Width(200) })) + { + Application.OpenURL("https://support.appsflyer.com/hc/en-us/articles/213766183-Unity-SDK-integration-for-developers"); + } + + if (GUILayout.Button("AppsFlyer Android Docs", new GUILayoutOption[] { GUILayout.Width(200) })) + { + Application.OpenURL("https://support.appsflyer.com/hc/en-us/articles/207032126-Android-SDK-integration-for-developers"); + } + + if (GUILayout.Button("AppsFlyer iOS Docs", new GUILayoutOption[] { GUILayout.Width(200) })) + { + Application.OpenURL("https://support.appsflyer.com/hc/en-us/articles/207032066-AppsFlyer-SDK-Integration-iOS"); + } + + if (GUILayout.Button("AppsFlyer Deeplinking Docs", new GUILayoutOption[] { GUILayout.Width(200) })) + { + Application.OpenURL("https://support.appsflyer.com/hc/en-us/articles/208874366-OneLink-deep-linking-guide#Setups"); + } + + if (GUILayout.Button("AppsFlyer Windows Docs", new GUILayoutOption[] { GUILayout.Width(200) })) + { + Application.OpenURL("https://support.appsflyer.com/hc/en-us/articles/207032026-Windows-and-Xbox-SDK-integration-for-developers"); + } + + + serializedObject.ApplyModifiedProperties(); + } + + +} \ No newline at end of file diff --git a/Editor/AppsFlyerObjectEditor.cs.meta b/Editor/AppsFlyerObjectEditor.cs.meta new file mode 100644 index 00000000..53d8abb2 --- /dev/null +++ b/Editor/AppsFlyerObjectEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d248a134cf494486fb1d6a2e95a05d87 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/appsflyer_logo.png b/Editor/appsflyer_logo.png new file mode 100644 index 00000000..01c2b8ca Binary files /dev/null and b/Editor/appsflyer_logo.png differ diff --git a/Editor/appsflyer_logo.png.meta b/Editor/appsflyer_logo.png.meta new file mode 100644 index 00000000..90005e83 --- /dev/null +++ b/Editor/appsflyer_logo.png.meta @@ -0,0 +1,92 @@ +fileFormatVersion: 2 +guid: bc7fa5a6b64b944a4b2900fd877acb8b +TextureImporter: + internalIDToNameTable: [] + externalObjects: {} + serializedVersion: 11 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + sRGBTexture: 1 + linearTexture: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapsPreserveCoverage: 0 + alphaTestReferenceValue: 0.5 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + streamingMipmaps: 0 + streamingMipmapsPriority: 0 + grayScaleToAlpha: 0 + generateCubemap: 6 + cubemapConvolution: 0 + seamlessCubemap: 0 + textureFormat: 1 + maxTextureSize: 2048 + textureSettings: + serializedVersion: 2 + filterMode: -1 + aniso: -1 + mipBias: -100 + wrapU: -1 + wrapV: -1 + wrapW: -1 + nPOTScale: 1 + lightmap: 0 + compressionQuality: 50 + spriteMode: 0 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spritePixelsToUnits: 100 + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spriteGenerateFallbackPhysicsShape: 1 + alphaUsage: 1 + alphaIsTransparency: 0 + spriteTessellationDetail: -1 + textureType: 0 + textureShape: 1 + singleChannelComponent: 0 + maxTextureSizeSet: 0 + compressionQualitySet: 0 + textureFormatSet: 0 + applyGammaDecoding: 0 + platformSettings: + - serializedVersion: 3 + buildTarget: DefaultTexturePlatform + maxTextureSize: 2048 + resizeAlgorithm: 0 + textureFormat: -1 + textureCompression: 1 + compressionQuality: 50 + crunchedCompression: 0 + allowsAlphaSplitting: 0 + overridden: 0 + androidETC2FallbackOverride: 0 + forceMaximumCompressionQuality_BC6H_BC7: 0 + spriteSheet: + serializedVersion: 2 + sprites: [] + outline: [] + physicsShape: [] + bones: [] + spriteID: + internalID: 0 + vertices: [] + indices: + edges: [] + weights: [] + secondaryTextures: [] + spritePackingTag: + pSDRemoveMatte: 0 + pSDShowRemoveMatteOption: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/IAppsFlyerAndroidBridge.cs b/IAppsFlyerAndroidBridge.cs new file mode 100644 index 00000000..b4c81885 --- /dev/null +++ b/IAppsFlyerAndroidBridge.cs @@ -0,0 +1,31 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AppsFlyerSDK +{ + + public interface IAppsFlyerAndroidBridge : IAppsFlyerNativeBridge + { + void updateServerUninstallToken(string token); + void setImeiData(string imei); + void setAndroidIdData(string androidId); + void waitForCustomerUserId(bool wait); + void setCustomerIdAndStartSDK(string id); + string getOutOfStore(); + void setOutOfStore(string sourceName); + void setCollectAndroidID(bool isCollect); + void setCollectIMEI(bool isCollect); + void setIsUpdate(bool isUpdate); + void setPreinstallAttribution(string mediaSource, string campaign, string siteId); + bool isPreInstalledApp(); + string getAttributionId(); + void handlePushNotifications(); + void validateAndSendInAppPurchase(string publicKey, string signature, string purchaseData, string price, string currency, Dictionary additionalParameters, MonoBehaviour gameObject); + void validateAndSendInAppPurchase(AFPurchaseDetailsAndroid details, Dictionary additionalParameters, MonoBehaviour gameObject); + void setCollectOaid(bool isCollect); + void setDisableAdvertisingIdentifiers(bool disable); + void setDisableNetworkData(bool disable); + + } +} \ No newline at end of file diff --git a/IAppsFlyerAndroidBridge.cs.meta b/IAppsFlyerAndroidBridge.cs.meta new file mode 100644 index 00000000..8157bc65 --- /dev/null +++ b/IAppsFlyerAndroidBridge.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: cdf9d1bc41a8244b3bc2d249fb6cd7aa +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IAppsFlyerConversionData.cs b/IAppsFlyerConversionData.cs new file mode 100644 index 00000000..454eaa65 --- /dev/null +++ b/IAppsFlyerConversionData.cs @@ -0,0 +1,31 @@ +namespace AppsFlyerSDK +{ + public interface IAppsFlyerConversionData + { + /// + /// `conversionData` contains information about install. Organic/non-organic, etc. + /// https://support.appsflyer.com/hc/en-us/articles/360000726098-Conversion-Data-Scenarios#Introduction + /// + /// JSON string of the returned conversion data. + void onConversionDataSuccess(string conversionData); + + /// + /// Any errors that occurred during the conversion request. + /// + /// A string describing the error. + void onConversionDataFail(string error); + + /// + /// `attributionData` contains information about OneLink, deeplink. + /// https://support.appsflyer.com/hc/en-us/articles/208874366-OneLink-Deep-Linking-Guide#Intro + /// + /// JSON string of the returned deeplink data. + void onAppOpenAttribution(string attributionData); + + /// + /// Any errors that occurred during the attribution request. + /// + /// A string describing the error. + void onAppOpenAttributionFailure(string error); + } +} \ No newline at end of file diff --git a/IAppsFlyerConversionData.cs.meta b/IAppsFlyerConversionData.cs.meta new file mode 100644 index 00000000..3133eaaf --- /dev/null +++ b/IAppsFlyerConversionData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d2f1d4dadb7cb44628f25f1ffd8fc104 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IAppsFlyerIOSBridge.cs b/IAppsFlyerIOSBridge.cs new file mode 100644 index 00000000..86211fbd --- /dev/null +++ b/IAppsFlyerIOSBridge.cs @@ -0,0 +1,26 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + + +namespace AppsFlyerSDK +{ + + public interface IAppsFlyerIOSBridge : IAppsFlyerNativeBridge + { + void setDisableCollectAppleAdSupport(bool disable); + void setShouldCollectDeviceName(bool shouldCollectDeviceName); + void setDisableCollectIAd(bool disableCollectIAd); + void setUseReceiptValidationSandbox(bool useReceiptValidationSandbox); + void setUseUninstallSandbox(bool useUninstallSandbox); + void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string transactionId, Dictionary additionalParameters, MonoBehaviour gameObject); + void validateAndSendInAppPurchase(AFSDKPurchaseDetailsIOS details, Dictionary extraEventValues, MonoBehaviour gameObject); + void registerUninstall(byte[] deviceToken); + void handleOpenUrl(string url, string sourceApplication, string annotation); + void waitForATTUserAuthorizationWithTimeoutInterval(int timeoutInterval); + void setCurrentDeviceLanguage(string language); + void disableSKAdNetwork(bool isDisabled); + void disableIDFVCollection(bool isDisabled); + + } +} \ No newline at end of file diff --git a/IAppsFlyerIOSBridge.cs.meta b/IAppsFlyerIOSBridge.cs.meta new file mode 100644 index 00000000..8e200ea1 --- /dev/null +++ b/IAppsFlyerIOSBridge.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6847fb337898040288c165e3667101a3 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IAppsFlyerNativeBridge.cs b/IAppsFlyerNativeBridge.cs new file mode 100644 index 00000000..23a107cd --- /dev/null +++ b/IAppsFlyerNativeBridge.cs @@ -0,0 +1,76 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +namespace AppsFlyerSDK +{ + + public interface IAppsFlyerNativeBridge + { + bool isInit { get; set; } + + void startSDK(bool onRequestResponse, string CallBackObjectName); + + void sendEvent(string eventName, Dictionary eventValues, bool onInAppResponse, string CallBackObjectName); + + void stopSDK(bool isSDKStopped); + + bool isSDKStopped(); + + string getSdkVersion(); + + void setCustomerUserId(string id); + + void setAppInviteOneLinkID(string oneLinkId); + + void setAdditionalData(Dictionary customData); + + void setDeepLinkTimeout(long deepLinkTimeout); + + void setResolveDeepLinkURLs(params string[] urls); + + void setOneLinkCustomDomain(params string[] domains); + + void setCurrencyCode(string currencyCode); + + void recordLocation(double latitude, double longitude); + + void anonymizeUser(bool shouldAnonymizeUser); + + string getAppsFlyerId(); + + void enableTCFDataCollection(bool shouldCollectTcfData); + + void setConsentData(AppsFlyerConsent appsFlyerConsent); + + void logAdRevenue(AFAdRevenueData adRevenueData, Dictionary additionalParameters); + + void setMinTimeBetweenSessions(int seconds); + + void setHost(string hostPrefixName, string hostName); + + void setPhoneNumber(string phoneNumber); + + void setSharingFilterForAllPartners(); + + void setSharingFilter(params string[] partners); + + void getConversionData(string objectName); + + void attributeAndOpenStore(string appID, string campaign, Dictionary userParams, MonoBehaviour gameObject); + + void recordCrossPromoteImpression(string appID, string campaign, Dictionary parameters); + + void generateUserInviteLink(Dictionary parameters, MonoBehaviour gameObject); + + void addPushNotificationDeepLinkPath(params string[] paths); + + void setUserEmails(EmailCryptType cryptType, params string[] userEmails); + + void subscribeForDeepLink(string objectName); + + void setIsDebug(bool shouldEnable); + + void setPartnerData(string partnerId, Dictionary partnerInfo); + } +} diff --git a/IAppsFlyerNativeBridge.cs.meta b/IAppsFlyerNativeBridge.cs.meta new file mode 100644 index 00000000..dd432572 --- /dev/null +++ b/IAppsFlyerNativeBridge.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 409b8302434664a3785ce55d075e7f58 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IAppsFlyerUserInvite.cs b/IAppsFlyerUserInvite.cs new file mode 100644 index 00000000..aac109e1 --- /dev/null +++ b/IAppsFlyerUserInvite.cs @@ -0,0 +1,26 @@ +namespace AppsFlyerSDK +{ + public interface IAppsFlyerUserInvite + { + /// + /// The success callback for generating OneLink URLs. + /// + /// A string of the newly created url. + void onInviteLinkGenerated(string link); + + /// + /// The error callback for generating OneLink URLs + /// + /// A string describing the error. + void onInviteLinkGeneratedFailure(string error); + + /// + /// (ios only) iOS allows you to utilize the StoreKit component to open + /// the App Store while remaining in the context of your app. + /// More details at https://support.appsflyer.com/hc/en-us/articles/115004481946-Cross-Promotion-Tracking#tracking-cross-promotion-impressions + /// + /// openStore callback Contains promoted `clickURL` + void onOpenStoreLinkGenerated(string link); + + } +} \ No newline at end of file diff --git a/IAppsFlyerUserInvite.cs.meta b/IAppsFlyerUserInvite.cs.meta new file mode 100644 index 00000000..85305286 --- /dev/null +++ b/IAppsFlyerUserInvite.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 5a4cdfa023cb8497b94bb39720052fef +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IAppsFlyerValidateAndLog.cs b/IAppsFlyerValidateAndLog.cs new file mode 100644 index 00000000..a5c02cf0 --- /dev/null +++ b/IAppsFlyerValidateAndLog.cs @@ -0,0 +1,19 @@ +namespace AppsFlyerSDK +{ + public interface IAppsFlyerValidateAndLog + { + /// + /// The success callback for validateAndSendInAppPurchase API. + /// For Android : the callback will return JSON string. + /// For iOS : the callback will return a JSON string from apples verifyReceipt API. + /// + /// + void onValidateAndLogComplete(string result); + + /// + /// The error callback for validateAndSendInAppPurchase API. + /// + /// A string describing the error. + void onValidateAndLogFailure(string error); + } +} \ No newline at end of file diff --git a/IAppsFlyerValidateAndLog.cs.meta b/IAppsFlyerValidateAndLog.cs.meta new file mode 100644 index 00000000..459cc855 --- /dev/null +++ b/IAppsFlyerValidateAndLog.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1a5adb7eab3284dd39a76ec56c06457c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/IAppsFlyerValidateReceipt.cs b/IAppsFlyerValidateReceipt.cs new file mode 100644 index 00000000..90490e21 --- /dev/null +++ b/IAppsFlyerValidateReceipt.cs @@ -0,0 +1,19 @@ +namespace AppsFlyerSDK +{ + public interface IAppsFlyerValidateReceipt + { + /// + /// The success callback for validateAndSendInAppPurchase API. + /// For Android : the callback will return "Validate success". + /// For iOS : the callback will return a JSON string from apples verifyReceipt API. + /// + /// + void didFinishValidateReceipt(string result); + + /// + /// The error callback for validateAndSendInAppPurchase API. + /// + /// A string describing the error. + void didFinishValidateReceiptWithError(string error); + } +} \ No newline at end of file diff --git a/IAppsFlyerValidateReceipt.cs.meta b/IAppsFlyerValidateReceipt.cs.meta new file mode 100644 index 00000000..38efa671 --- /dev/null +++ b/IAppsFlyerValidateReceipt.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 6385b1d184efa400a98515735e1f17bc +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Mac.meta b/Mac.meta new file mode 100644 index 00000000..fd182bd5 --- /dev/null +++ b/Mac.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 96a328019e42349aabc478b546b8605e +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Mac/AppsFlyerBundle.bundle.meta b/Mac/AppsFlyerBundle.bundle.meta new file mode 100644 index 00000000..a7aa6da5 --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: 682114f7790724ab3b9410e89bbc076c +folderAsset: yes +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + DefaultValueInitialized: true + - first: + Standalone: OSXUniversal + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Mac/AppsFlyerBundle.bundle/Contents.meta b/Mac/AppsFlyerBundle.bundle/Contents.meta new file mode 100644 index 00000000..4b066045 --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle/Contents.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 28175da64865f4e398b3b9ddfbe97b24 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Mac/AppsFlyerBundle.bundle/Contents/Info.plist b/Mac/AppsFlyerBundle.bundle/Contents/Info.plist new file mode 100644 index 00000000..3303ccd8 --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle/Contents/Info.plist @@ -0,0 +1,48 @@ + + + + + BuildMachineOSBuild + 20G417 + CFBundleDevelopmentRegion + en + CFBundleExecutable + AppsFlyerBundle + CFBundleIdentifier + com.appsflyer.support.two.AppsFlyerBundle + CFBundleInfoDictionaryVersion + 6.0 + CFBundleName + AppsFlyerBundle + CFBundlePackageType + BNDL + CFBundleShortVersionString + 1.0 + CFBundleSupportedPlatforms + + MacOSX + + CFBundleVersion + 1 + DTCompiler + com.apple.compilers.llvm.clang.1_0 + DTPlatformBuild + 13A1030d + DTPlatformName + macosx + DTPlatformVersion + 12.0 + DTSDKBuild + 21A344 + DTSDKName + macosx12.0 + DTXcode + 1310 + DTXcodeBuild + 13A1030d + LSMinimumSystemVersion + 11.6 + NSHumanReadableCopyright + + + diff --git a/Mac/AppsFlyerBundle.bundle/Contents/Info.plist.meta b/Mac/AppsFlyerBundle.bundle/Contents/Info.plist.meta new file mode 100644 index 00000000..dac263eb --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle/Contents/Info.plist.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 58a86b0b376564c06bf8ce29e1dbfb04 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Mac/AppsFlyerBundle.bundle/Contents/MacOS.meta b/Mac/AppsFlyerBundle.bundle/Contents/MacOS.meta new file mode 100644 index 00000000..b55a7574 --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle/Contents/MacOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 218a2e7ff5a4c461981bc41f7d7bfeba +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Mac/AppsFlyerBundle.bundle/Contents/MacOS/AppsFlyerBundle b/Mac/AppsFlyerBundle.bundle/Contents/MacOS/AppsFlyerBundle new file mode 100755 index 00000000..3376a474 Binary files /dev/null and b/Mac/AppsFlyerBundle.bundle/Contents/MacOS/AppsFlyerBundle differ diff --git a/Mac/AppsFlyerBundle.bundle/Contents/MacOS/AppsFlyerBundle.meta b/Mac/AppsFlyerBundle.bundle/Contents/MacOS/AppsFlyerBundle.meta new file mode 100644 index 00000000..a6e35c7c --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle/Contents/MacOS/AppsFlyerBundle.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 0889edee891d84a8eb0b7cc87071b91e +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature.meta b/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature.meta new file mode 100644 index 00000000..d3cac98c --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 16068f30788004029bd487756623799b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature/CodeResources b/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature/CodeResources new file mode 100644 index 00000000..d5d0fd74 --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature/CodeResources @@ -0,0 +1,115 @@ + + + + + files + + files2 + + rules + + ^Resources/ + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^version.plist$ + + + rules2 + + .*\.dSYM($|/) + + weight + 11 + + ^(.*/)?\.DS_Store$ + + omit + + weight + 2000 + + ^(Frameworks|SharedFrameworks|PlugIns|Plug-ins|XPCServices|Helpers|MacOS|Library/(Automator|Spotlight|LoginItems))/ + + nested + + weight + 10 + + ^.* + + ^Info\.plist$ + + omit + + weight + 20 + + ^PkgInfo$ + + omit + + weight + 20 + + ^Resources/ + + weight + 20 + + ^Resources/.*\.lproj/ + + optional + + weight + 1000 + + ^Resources/.*\.lproj/locversion.plist$ + + omit + + weight + 1100 + + ^Resources/Base\.lproj/ + + weight + 1010 + + ^[^/]+$ + + nested + + weight + 10 + + ^embedded\.provisionprofile$ + + weight + 20 + + ^version\.plist$ + + weight + 20 + + + + diff --git a/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature/CodeResources.meta b/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature/CodeResources.meta new file mode 100644 index 00000000..4cbf1969 --- /dev/null +++ b/Mac/AppsFlyerBundle.bundle/Contents/_CodeSignature/CodeResources.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 724b52b308e9a4a6d889d7bf3945a2ca +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins.meta b/Plugins.meta new file mode 100644 index 00000000..5394930a --- /dev/null +++ b/Plugins.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 66297743248ab4e47abdc371a59f1111 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/iOS.meta b/Plugins/iOS.meta new file mode 100644 index 00000000..286d70c3 --- /dev/null +++ b/Plugins/iOS.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d8325c12a80ff4323b82e2833a8fc287 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/iOS/AFUnityUtils.h b/Plugins/iOS/AFUnityUtils.h new file mode 100644 index 00000000..9047bcf6 --- /dev/null +++ b/Plugins/iOS/AFUnityUtils.h @@ -0,0 +1,23 @@ +// +// AFUnityUtils.h +// +// Created by Andrii H. and Dmitry O. on 16 Oct 2023 +// + +#if __has_include() +#import +#else +#import "AppsFlyerLib.h" +#endif + +static NSString* stringFromChar(const char *str); +static NSDictionary* dictionaryFromJson(const char *jsonString); +static const char* stringFromdictionary(NSDictionary* dictionary); +static NSArray *NSArrayFromCArray(int length, const char **arr); +static char* getCString(const char* string); +static AppsFlyerLinkGenerator* generatorFromDictionary(NSDictionary* dictionary, AppsFlyerLinkGenerator* generator); +static EmailCryptType emailCryptTypeFromInt(int emailCryptTypeInt); +static AppsFlyerAdRevenueMediationNetworkType mediationNetworkTypeFromInt(int mediationNetwork); +static NSString* stringFromDeepLinkResultStatus(AFSDKDeepLinkResultStatus deepLinkResult); +static NSString* stringFromDeepLinkResultError(AppsFlyerDeepLinkResult *result); + diff --git a/Plugins/iOS/AFUnityUtils.h.meta b/Plugins/iOS/AFUnityUtils.h.meta new file mode 100644 index 00000000..f6811a68 --- /dev/null +++ b/Plugins/iOS/AFUnityUtils.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 4b0609ff467554f2088aee1c52bf54a2 +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 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/iOS/AFUnityUtils.mm b/Plugins/iOS/AFUnityUtils.mm new file mode 100644 index 00000000..359c297a --- /dev/null +++ b/Plugins/iOS/AFUnityUtils.mm @@ -0,0 +1,199 @@ +// +// AFUnityUtils.mm +// Unity-iPhone +// +// Created by Jonathan Wesfield on 24/07/2019. +// + +#import "AFUnityUtils.h" + +static NSString* stringFromChar(const char *str) { + return str ? [NSString stringWithUTF8String:str] : nil; +} + +static NSDictionary* dictionaryFromJson(const char *jsonString) { + if(jsonString){ + NSData *jsonData = [[NSData alloc] initWithBytes:jsonString length:strlen(jsonString)]; + NSDictionary *dictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:nil]; + return dictionary; + } + + return nil; +} + +static const char* stringFromdictionary(NSDictionary* dictionary) { + if(dictionary){ + NSError * err; + NSData * jsonData = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:&err]; + NSString * myString = [[NSString alloc] initWithData:jsonData encoding:NSUTF8StringEncoding]; + return [myString UTF8String]; + } + + return nil; +} + +static NSDictionary* dictionaryFromNSError(NSError* error) { + if(error){ + NSInteger code = [error code]; + NSString *localizedDescription = [error localizedDescription]; + + NSDictionary *errorDictionary = @{ + @"code" : @(code) ?: @(-1), + @"localizedDescription" : localizedDescription, + }; + return errorDictionary; + } + + return nil; +} + + +static NSArray *NSArrayFromCArray(int length, const char **arr) { + NSMutableArray *res = [[NSMutableArray alloc] init]; + for(int i = 0; i < length; i++) { + if (arr[i]) { + [res addObject:[NSString stringWithUTF8String:arr[i]]]; + } + } + + return res; +} + +static char* getCString(const char* string){ + if (string == NULL){ + return NULL; + } + + char* res = (char*)malloc(strlen(string) + 1); + strcpy(res, string); + + return res; +} + +static AppsFlyerLinkGenerator* generatorFromDictionary(NSDictionary* dictionary, AppsFlyerLinkGenerator* generator) { + + NSArray* generatorKeys = @[@"channel", @"customerID", @"campaign", @"referrerName", @"referrerImageUrl", @"deeplinkPath", @"baseDeeplink", @"brandDomain"]; + + NSMutableDictionary* mutableDictionary = [dictionary mutableCopy]; + + [generator setChannel:[dictionary objectForKey: @"channel"]]; + [generator setReferrerCustomerId:[dictionary objectForKey: @"customerID"]]; + [generator setCampaign:[dictionary objectForKey: @"campaign"]]; + [generator setReferrerName:[dictionary objectForKey: @"referrerName"]]; + [generator setReferrerImageURL:[dictionary objectForKey: @"referrerImageUrl"]]; + [generator setDeeplinkPath:[dictionary objectForKey: @"deeplinkPath"]]; + [generator setBaseDeeplink:[dictionary objectForKey: @"baseDeeplink"]]; + [generator setBrandDomain:[dictionary objectForKey: @"brandDomain"]]; + + + [mutableDictionary removeObjectsForKeys:generatorKeys]; + + [generator addParameters:mutableDictionary]; + + return generator; +} + +static EmailCryptType emailCryptTypeFromInt(int emailCryptTypeInt){ + + EmailCryptType emailCryptType; + switch (emailCryptTypeInt){ + case 1: + emailCryptType = EmailCryptTypeSHA256; + break; + default: + emailCryptType = EmailCryptTypeNone; + break; + } + + return emailCryptType; +} + +static AppsFlyerAdRevenueMediationNetworkType mediationNetworkTypeFromInt(int mediationNetworkInt){ + + AppsFlyerAdRevenueMediationNetworkType mediationNetworkType; + switch (mediationNetworkInt){ + case 1: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeGoogleAdMob; + break; + case 2: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeIronSource; + break; + case 3: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeApplovinMax; + break; + case 4: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeFyber; + break; + case 5: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeAppodeal; + break; + case 6: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeAdmost; + break; + case 7: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeTopon; + break; + case 8: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeTradplus; + break; + case 9: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeYandex; + break; + case 10: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeChartBoost; + break; + case 11: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeUnity; + break; + case 12: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeToponPte; + break; + case 13: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeCustom; + break; + case 14: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeDirectMonetization; + break; + default: + mediationNetworkType = AppsFlyerAdRevenueMediationNetworkTypeCustom; + break; + } + + return mediationNetworkType; +} + +static NSString* stringFromDeepLinkResultStatus(AFSDKDeepLinkResultStatus deepLinkResult){ + NSString* result; + switch (deepLinkResult){ + case AFSDKDeepLinkResultStatusFound: + result = @"FOUND"; + break; + case AFSDKDeepLinkResultStatusFailure: + result = @"ERROR"; + break; + case AFSDKDeepLinkResultStatusNotFound: + result = @"NOT_FOUND"; + break; + default: + result = @"ERROR"; + break; + } + + return result; +} + +static NSString* stringFromDeepLinkResultError(AppsFlyerDeepLinkResult *result){ + NSString* res; + + if (result && result.error){ + if ([[result.error userInfo][NSUnderlyingErrorKey] code] == -1001) { + res = @"TIMEOUT"; + } else if ([[result.error userInfo][NSUnderlyingErrorKey] code] == -1009) { + res = @"NETWORK"; + } + } + + res = @"UNKNOWN"; + + return res; +} diff --git a/Plugins/iOS/AFUnityUtils.mm.meta b/Plugins/iOS/AFUnityUtils.mm.meta new file mode 100644 index 00000000..b4113757 --- /dev/null +++ b/Plugins/iOS/AFUnityUtils.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 18a03931864e84d86bedcc99c440e060 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + 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: diff --git a/Plugins/iOS/AppsFlyer+AppController.m b/Plugins/iOS/AppsFlyer+AppController.m new file mode 100644 index 00000000..f8775766 --- /dev/null +++ b/Plugins/iOS/AppsFlyer+AppController.m @@ -0,0 +1,164 @@ +// +// AppsFlyer+AppController.m +// Unity-iPhone +// +// Created by Jonathan Wesfield on 24/07/2019. +// + +#import +#import "UnityAppController.h" +#import "AppsFlyeriOSWrapper.h" +#if __has_include() +#import +#else +#import "AppsFlyerLib.h" +#endif + + +@implementation UnityAppController (AppsFlyerSwizzledAppController) + +static BOOL didEnteredBackGround __unused; +static IMP __original_applicationDidBecomeActive_Imp __unused; +static IMP __original_applicationDidEnterBackground_Imp __unused; +static IMP __original_didReceiveRemoteNotification_Imp __unused; +static IMP __original_continueUserActivity_Imp __unused; +static IMP __original_openUrl_Imp __unused; + + ++ (void)load { + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + +#if !AFSDK_SHOULD_SWIZZLE + + id swizzleFlag = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppsFlyerShouldSwizzle"]; + BOOL shouldSwizzle = swizzleFlag ? [swizzleFlag boolValue] : NO; + + if(shouldSwizzle){ + + Method method1 = class_getInstanceMethod([self class], @selector(applicationDidBecomeActive:)); + __original_applicationDidBecomeActive_Imp = method_setImplementation(method1, (IMP)__swizzled_applicationDidBecomeActive); + + Method method2 = class_getInstanceMethod([self class], @selector(applicationDidEnterBackground:)); + __original_applicationDidEnterBackground_Imp = method_setImplementation(method2, (IMP)__swizzled_applicationDidEnterBackground); + + + Method method3 = class_getInstanceMethod([self class], @selector(didReceiveRemoteNotification:)); + __original_didReceiveRemoteNotification_Imp = method_setImplementation(method3, (IMP)__swizzled_didReceiveRemoteNotification); + + + Method method4 = class_getInstanceMethod([self class], @selector(application:openURL:options:)); + __original_openUrl_Imp = method_setImplementation(method4, (IMP)__swizzled_openURL); + + if (_AppsFlyerdelegate == nil) { + _AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init]; + } + + [self swizzleContinueUserActivity:[self class]]; + } +#elif AFSDK_SHOULD_SWIZZLE + Method method1 = class_getInstanceMethod([self class], @selector(applicationDidBecomeActive:)); + __original_applicationDidBecomeActive_Imp = method_setImplementation(method1, (IMP)__swizzled_applicationDidBecomeActive); + + Method method2 = class_getInstanceMethod([self class], @selector(applicationDidEnterBackground:)); + __original_applicationDidEnterBackground_Imp = method_setImplementation(method2, (IMP)__swizzled_applicationDidEnterBackground); + + + Method method3 = class_getInstanceMethod([self class], @selector(didReceiveRemoteNotification:)); + __original_didReceiveRemoteNotification_Imp = method_setImplementation(method3, (IMP)__swizzled_didReceiveRemoteNotification); + + + Method method4 = class_getInstanceMethod([self class], @selector(application:openURL:options:)); + __original_openUrl_Imp = method_setImplementation(method4, (IMP)__swizzled_openURL); + + if (_AppsFlyerdelegate == nil) { + _AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init]; + } + + [self swizzleContinueUserActivity:[self class]]; + +#endif + + + }); +} + ++(void)swizzleContinueUserActivity:(Class)class { + + SEL originalSelector = @selector(application:continueUserActivity:restorationHandler:); + + Method defaultMethod = class_getInstanceMethod(class, originalSelector); + Method swizzledMethod = class_getInstanceMethod(class, @selector(__swizzled_continueUserActivity)); + + BOOL isMethodExists = !class_addMethod(class, originalSelector, method_getImplementation(swizzledMethod), method_getTypeEncoding(swizzledMethod)); + + if (isMethodExists) { + __original_continueUserActivity_Imp = method_setImplementation(defaultMethod, (IMP)__swizzled_continueUserActivity); + } else { + class_replaceMethod(class, originalSelector, (IMP)__swizzled_continueUserActivity, method_getTypeEncoding(swizzledMethod)); + } +} + +BOOL __swizzled_continueUserActivity(id self, SEL _cmd, UIApplication* application, NSUserActivity* userActivity, void (^restorationHandler)(NSArray*)) { + NSLog(@"swizzled continueUserActivity"); + [[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler]; + + if(__original_continueUserActivity_Imp){ + return ((BOOL(*)(id, SEL, UIApplication*, NSUserActivity*, void (^)(NSArray*)))__original_continueUserActivity_Imp)(self, _cmd, application, userActivity, NULL); + } + + return YES; +} + + + +void __swizzled_applicationDidBecomeActive(id self, SEL _cmd, UIApplication* launchOptions) { + NSLog(@"swizzled applicationDidBecomeActive"); + [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate]; + + if(didEnteredBackGround && AppsFlyeriOSWarpper.didCallStart == YES){ + [[AppsFlyerLib shared] start]; + } + + if(__original_applicationDidBecomeActive_Imp){ + ((void(*)(id,SEL, UIApplication*))__original_applicationDidBecomeActive_Imp)(self, _cmd, launchOptions); + } +} + + +void __swizzled_applicationDidEnterBackground(id self, SEL _cmd, UIApplication* application) { + NSLog(@"swizzled applicationDidEnterBackground"); + didEnteredBackGround = YES; + if(__original_applicationDidEnterBackground_Imp){ + ((void(*)(id,SEL, UIApplication*))__original_applicationDidEnterBackground_Imp)(self, _cmd, application); + } +} + + +BOOL __swizzled_didReceiveRemoteNotification(id self, SEL _cmd, UIApplication* application, NSDictionary* userInfo,void (^UIBackgroundFetchResult)(void) ) { + NSLog(@"swizzled didReceiveRemoteNotification"); + + [[AppsFlyerLib shared] handlePushNotification:userInfo]; + + if(__original_didReceiveRemoteNotification_Imp){ + return ((BOOL(*)(id, SEL, UIApplication*, NSDictionary*, int(UIBackgroundFetchResult)))__original_didReceiveRemoteNotification_Imp)(self, _cmd, application, userInfo, nil); + } + return YES; +} + + + +BOOL __swizzled_openURL(id self, SEL _cmd, UIApplication* application, NSURL* url, NSDictionary * options) { + NSLog(@"swizzled openURL"); + [[AppsFlyerAttribution shared] handleOpenUrl:url options:options]; + if(__original_openUrl_Imp){ + return ((BOOL(*)(id, SEL, UIApplication*, NSURL*, NSDictionary*))__original_openUrl_Imp)(self, _cmd, application, url, options); + } + return NO; +} + + +@end + + + diff --git a/Plugins/iOS/AppsFlyer+AppController.m.meta b/Plugins/iOS/AppsFlyer+AppController.m.meta new file mode 100644 index 00000000..24856fae --- /dev/null +++ b/Plugins/iOS/AppsFlyer+AppController.m.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 6ae9e1f7daef2427588fab2fbf8d35d5 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + 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: diff --git a/Plugins/iOS/AppsFlyerAppController.mm b/Plugins/iOS/AppsFlyerAppController.mm new file mode 100644 index 00000000..3e492c09 --- /dev/null +++ b/Plugins/iOS/AppsFlyerAppController.mm @@ -0,0 +1,131 @@ +// +// AppsFlyerAppController.mm +// Unity-iPhone +// +// Created by Jonathan Wesfield on 30/07/2019. +// + +#import +#import "UnityAppController.h" +#import "AppDelegateListener.h" +#import "AppsFlyeriOSWrapper.h" +#if __has_include() +#import +#else +#import "AppsFlyerLib.h" +#endif +#import + +/** + Note if you would like to use method swizzeling see AppsFlyer+AppController.m + If you are using swizzeling then comment out the method that is being swizzeled in AppsFlyerAppController.mm + Only use swizzeling if there are conflicts with other plugins that needs to be resolved. +*/ + + +@interface AppsFlyerAppController : UnityAppController +{ + BOOL didEnteredBackGround; +} +@end + +@implementation AppsFlyerAppController + +- (instancetype)init +{ + self = [super init]; + if (self) { + + id swizzleFlag = [[NSBundle mainBundle] objectForInfoDictionaryKey:@"AppsFlyerShouldSwizzle"]; + BOOL shouldSwizzle = swizzleFlag ? [swizzleFlag boolValue] : NO; + + if(!shouldSwizzle){ + UnityRegisterAppDelegateListener(self); + } + } + return self; +} + +- (void)didFinishLaunching:(NSNotification*)notification { + NSLog(@"got didFinishLaunching = %@",notification.userInfo); + + + if (_AppsFlyerdelegate == nil) { + _AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init]; + } + [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate]; + + if (notification.userInfo[@"url"]) { + [self onOpenURL:notification]; + } +} + +-(void)didBecomeActive:(NSNotification*)notification { + NSLog(@"got didBecomeActive(out) = %@", notification.userInfo); + if (didEnteredBackGround == YES && AppsFlyeriOSWarpper.didCallStart == YES) { + [[AppsFlyerLib shared] start]; + didEnteredBackGround = NO; + } +} + +- (void)didEnterBackground:(NSNotification*)notification { + NSLog(@"got didEnterBackground = %@", notification.userInfo); + didEnteredBackGround = YES; +} + +- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler { + [[AppsFlyerAttribution shared] continueUserActivity:userActivity restorationHandler:restorationHandler]; + return YES; +} + + +- (void)onOpenURL:(NSNotification*)notification { + NSLog(@"got onOpenURL = %@", notification.userInfo); + NSURL *url = notification.userInfo[@"url"]; + NSString *sourceApplication = notification.userInfo[@"sourceApplication"]; + + if (sourceApplication == nil) { + sourceApplication = @""; + } + + if (url != nil) { + [[AppsFlyerAttribution shared] handleOpenUrl:url sourceApplication:sourceApplication annotation:nil]; + } + +} + +- (void)didReceiveRemoteNotification:(NSNotification*)notification { + NSLog(@"got didReceiveRemoteNotification = %@", notification.userInfo); + [[AppsFlyerLib shared] handlePushNotification:notification.userInfo]; +} + +@end + +#if !(AFSDK_SHOULD_SWIZZLE) + +IMPL_APP_CONTROLLER_SUBCLASS(AppsFlyerAppController) + +#endif +/** +Note if you would not like to use IMPL_APP_CONTROLLER_SUBCLASS you can replace it with the code below. + + +(void)load + { + [AppsFlyerAppController plugin]; + } + + // Singleton accessor. + + (AppsFlyerAppController *)plugin + { + static AppsFlyerAppController *sharedInstance = nil; + static dispatch_once_t onceToken; + + dispatch_once(&onceToken, ^{ + + sharedInstance = [[AppsFlyerAppController alloc] init]; + }); + + return sharedInstance; + } + + **/ diff --git a/Plugins/iOS/AppsFlyerAppController.mm.meta b/Plugins/iOS/AppsFlyerAppController.mm.meta new file mode 100644 index 00000000..2e8e52cf --- /dev/null +++ b/Plugins/iOS/AppsFlyerAppController.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 2d1497a1493b24fecaa58bd3a7b707f9 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + 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: diff --git a/Plugins/iOS/AppsFlyerAttribution.h b/Plugins/iOS/AppsFlyerAttribution.h new file mode 100644 index 00000000..c79fec4d --- /dev/null +++ b/Plugins/iOS/AppsFlyerAttribution.h @@ -0,0 +1,34 @@ +// +// AppsFlyerAttribution.h +// UnityFramework +// +// Created by Margot Guetta on 11/04/2021. +// + +#ifndef AppsFlyerAttribution_h +#define AppsFlyerAttribution_h +#endif /* AppsFlyerAttribution_h */ +#if __has_include() +#import +#else +#import "AppsFlyerLib.h" +#endif + + +@interface AppsFlyerAttribution : NSObject +@property NSUserActivity*_Nullable userActivity; +@property (nonatomic, copy) void (^ _Nullable restorationHandler)(NSArray *_Nullable ); +@property NSURL * _Nullable url; +@property NSDictionary * _Nullable options; +@property NSString* _Nullable sourceApplication; +@property id _Nullable annotation; +@property BOOL isBridgeReady; + ++ (AppsFlyerAttribution *_Nullable)shared; +- (void) continueUserActivity: (NSUserActivity*_Nullable) userActivity restorationHandler: (void (^_Nullable)(NSArray * _Nullable))restorationHandler; +- (void) handleOpenUrl:(NSURL*_Nullable)url options:(NSDictionary*_Nullable) options; +- (void) handleOpenUrl: (NSURL *_Nonnull)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation; + +@end + +static NSString * _Nullable const AF_BRIDGE_SET = @"bridge is set"; diff --git a/Plugins/iOS/AppsFlyerAttribution.h.meta b/Plugins/iOS/AppsFlyerAttribution.h.meta new file mode 100644 index 00000000..5b77c9ba --- /dev/null +++ b/Plugins/iOS/AppsFlyerAttribution.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 8544dc3b3c7bb40d397b2de568df1058 +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 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/iOS/AppsFlyerAttribution.m b/Plugins/iOS/AppsFlyerAttribution.m new file mode 100644 index 00000000..c4e72782 --- /dev/null +++ b/Plugins/iOS/AppsFlyerAttribution.m @@ -0,0 +1,86 @@ +// +// NSObject+AppsFlyerAttribution.m +// UnityFramework +// +// Created by Margot Guetta on 11/04/2021. +// + +#import +#import "AppsFlyerAttribution.h" + +@implementation AppsFlyerAttribution + ++ (id)shared { + static AppsFlyerAttribution *shared = nil; + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + shared = [[self alloc] init]; + }); + return shared; +} + +- (id)init { + if (self = [super init]) { + self.options = nil; + self.restorationHandler = nil; + self.url = nil; + self.userActivity = nil; + self.annotation = nil; + self.sourceApplication = nil; + self.isBridgeReady = NO; + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(receiveBridgeReadyNotification:) + name:AF_BRIDGE_SET + object:nil]; + } + return self; +} + +- (void) continueUserActivity: (NSUserActivity*_Nullable) userActivity restorationHandler: (void (^_Nullable)(NSArray * _Nullable))restorationHandler{ + if(self.isBridgeReady == YES){ + [[AppsFlyerLib shared] continueUserActivity:userActivity restorationHandler:restorationHandler]; + }else{ + [AppsFlyerAttribution shared].userActivity = userActivity; + [AppsFlyerAttribution shared].restorationHandler = restorationHandler; + } +} + +- (void) handleOpenUrl:(NSURL *)url options:(NSDictionary *)options{ + if(self.isBridgeReady == YES){ + [[AppsFlyerLib shared] handleOpenUrl:url options:options]; + }else{ + [AppsFlyerAttribution shared].url = url; + [AppsFlyerAttribution shared].options = options; + } +} + +- (void) handleOpenUrl:(NSURL *)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation{ + if(self.isBridgeReady == YES){ + [[AppsFlyerLib shared] handleOpenURL:url sourceApplication:sourceApplication withAnnotation:annotation]; + }else{ + [AppsFlyerAttribution shared].url = url; + [AppsFlyerAttribution shared].sourceApplication = sourceApplication; + [AppsFlyerAttribution shared].annotation = annotation; + } + +} + +- (void) receiveBridgeReadyNotification:(NSNotification *) notification +{ + NSLog (@"AppsFlyer Debug: handle deep link"); + if(self.url && self.sourceApplication){ + [[AppsFlyerLib shared] handleOpenURL:self.url sourceApplication:self.sourceApplication withAnnotation:self.annotation]; + self.url = nil; + self.sourceApplication = nil; + self.annotation = nil; + }else if(self.options && self.url){ + [[AppsFlyerLib shared] handleOpenUrl:self.url options:self.options]; + self.options = nil; + self.url = nil; + }else if(self.userActivity){ + [[AppsFlyerLib shared] continueUserActivity:self.userActivity restorationHandler:nil]; + self.userActivity = nil; + self.restorationHandler = nil; + } +} +@end diff --git a/Plugins/iOS/AppsFlyerAttribution.m.meta b/Plugins/iOS/AppsFlyerAttribution.m.meta new file mode 100644 index 00000000..9f071e68 --- /dev/null +++ b/Plugins/iOS/AppsFlyerAttribution.m.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 1060e47d7b9e2453ba575f0b455b2bf8 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + 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: diff --git a/Plugins/iOS/AppsFlyeriOSWrapper.h b/Plugins/iOS/AppsFlyeriOSWrapper.h new file mode 100644 index 00000000..d4cd3c3d --- /dev/null +++ b/Plugins/iOS/AppsFlyeriOSWrapper.h @@ -0,0 +1,50 @@ +// +// AppsFlyeriOSWarpper.h +// Unity-iPhone +// +// Created by Jonathan Wesfield on 24/07/2019. +// + +#import "AFUnityUtils.mm" +#import "UnityAppController.h" +#import "AppsFlyerAttribution.h" +#if __has_include() +#import +#else +#import "AppsFlyerLib.h" +#endif + +@interface AppsFlyeriOSWarpper : NSObject ++ (BOOL) didCallStart; ++ (void) setDidCallStart:(BOOL)val; +@end + + +static AppsFlyeriOSWarpper *_AppsFlyerdelegate; +static const int kPushNotificationSize = 32; + +static NSString* ConversionDataCallbackObject = @"AppsFlyerObject"; + +static const char* VALIDATE_CALLBACK = "didFinishValidateReceipt"; +static const char* VALIDATE_ERROR_CALLBACK = "didFinishValidateReceiptWithError"; +static const char* GCD_CALLBACK = "onConversionDataSuccess"; +static const char* GCD_ERROR_CALLBACK = "onConversionDataFail"; +static const char* OAOA_CALLBACK = "onAppOpenAttribution"; +static const char* OAOA_ERROR_CALLBACK = "onAppOpenAttributionFailure"; +static const char* GENERATE_LINK_CALLBACK = "onInviteLinkGenerated"; +static const char* OPEN_STORE_LINK_CALLBACK = "onOpenStoreLinkGenerated"; +static const char* START_REQUEST_CALLBACK = "requestResponseReceived"; +static const char* IN_APP_RESPONSE_CALLBACK = "inAppResponseReceived"; +static const char* ON_DEEPLINKING = "onDeepLinking"; +static const char* VALIDATE_AND_LOG_V2_CALLBACK = "onValidateAndLogComplete"; +static const char* VALIDATE_AND_LOG_V2_ERROR_CALLBACK = "onValidateAndLogFailure"; + + +static NSString* validateObjectName = @""; +static NSString* openStoreObjectName = @""; +static NSString* generateInviteObjectName = @""; +static NSString* validateAndLogObjectName = @""; +static NSString* startRequestObjectName = @""; +static NSString* inAppRequestObjectName = @""; +static NSString* onDeeplinkingObjectName = @""; + diff --git a/Plugins/iOS/AppsFlyeriOSWrapper.h.meta b/Plugins/iOS/AppsFlyeriOSWrapper.h.meta new file mode 100644 index 00000000..52849897 --- /dev/null +++ b/Plugins/iOS/AppsFlyeriOSWrapper.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: 147104b04b5794eaa92b4195cc328e13 +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 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Plugins/iOS/AppsFlyeriOSWrapper.mm b/Plugins/iOS/AppsFlyeriOSWrapper.mm new file mode 100644 index 00000000..ba5ca7a1 --- /dev/null +++ b/Plugins/iOS/AppsFlyeriOSWrapper.mm @@ -0,0 +1,378 @@ +// +// AppsFlyeriOSWarpper.mm +// Unity-iPhone +// +// Created by Jonathan Wesfield on 24/07/2019. +// + +#import "AppsFlyeriOSWrapper.h" + + +static void unityCallBack(NSString* objectName, const char* method, const char* msg) { + if(objectName){ + UnitySendMessage([objectName UTF8String], method, msg); + } +} + +extern "C" { + + const void _startSDK(bool shouldCallback, const char* objectName) { + [[AppsFlyerLib shared] setPluginInfoWith: AFSDKPluginUnity + pluginVersion:@"6.15.2" + additionalParams:nil]; + startRequestObjectName = stringFromChar(objectName); + AppsFlyeriOSWarpper.didCallStart = YES; + [AppsFlyerAttribution shared].isBridgeReady = YES; + [[NSNotificationCenter defaultCenter] postNotificationName:AF_BRIDGE_SET object: [AppsFlyerAttribution shared]]; + [[AppsFlyerLib shared] startWithCompletionHandler:^(NSDictionary *dictionary, NSError *error) { + if(shouldCallback){ + if (error) { + NSDictionary *callbackDictionary = @{@"statusCode":[NSNumber numberWithLong:[error code]]}; + unityCallBack(startRequestObjectName, START_REQUEST_CALLBACK, stringFromdictionary(callbackDictionary)); + return; + } + if (dictionary) { + unityCallBack(startRequestObjectName, START_REQUEST_CALLBACK, stringFromdictionary(dictionary)); + return; + } + } + }]; + } + + const void _setCustomerUserID (const char* customerUserID) { + [[AppsFlyerLib shared] setCustomerUserID:stringFromChar(customerUserID)]; + } + + const void _setAdditionalData (const char* customData) { + [[AppsFlyerLib shared] setAdditionalData:dictionaryFromJson(customData)]; + } + + const void _setAppsFlyerDevKey (const char* appsFlyerDevKey) { + [AppsFlyerLib shared].appsFlyerDevKey = stringFromChar(appsFlyerDevKey); + } + + const void _setAppleAppID (const char* appleAppID) { + [AppsFlyerLib shared].appleAppID = stringFromChar(appleAppID); + } + + const void _setCurrencyCode (const char* currencyCode) { + [[AppsFlyerLib shared] setCurrencyCode:stringFromChar(currencyCode)]; + } + + const void _setDisableCollectAppleAdSupport (bool disableAdvertisingIdentifier) { + [AppsFlyerLib shared].disableAdvertisingIdentifier = disableAdvertisingIdentifier; + } + + const void _setIsDebug (bool isDebug) { + [AppsFlyerLib shared].isDebug = isDebug; + } + + const void _setShouldCollectDeviceName (bool shouldCollectDeviceName) { + [AppsFlyerLib shared].shouldCollectDeviceName = shouldCollectDeviceName; + } + + const void _setAppInviteOneLinkID (const char* appInviteOneLinkID) { + [[AppsFlyerLib shared] setAppInviteOneLink:stringFromChar(appInviteOneLinkID)]; + } + + const void _setDeepLinkTimeout (long deepLinkTimeout) { + [AppsFlyerLib shared].deepLinkTimeout = deepLinkTimeout; + } + + const void _anonymizeUser (bool anonymizeUser) { + [AppsFlyerLib shared].anonymizeUser = anonymizeUser; + } + + const void _enableTCFDataCollection (bool shouldCollectTcfData) { + [[AppsFlyerLib shared] enableTCFDataCollection:shouldCollectTcfData]; + } + + const void _setConsentData(bool isUserSubjectToGDPR, bool hasConsentForDataUsage, bool hasConsentForAdsPersonalization) { + AppsFlyerConsent *consentData = nil; + if (isUserSubjectToGDPR) { + consentData = [[AppsFlyerConsent alloc] initForGDPRUserWithHasConsentForDataUsage:hasConsentForDataUsage hasConsentForAdsPersonalization:hasConsentForAdsPersonalization]; + } else { + consentData = [[AppsFlyerConsent alloc] initNonGDPRUser]; + } + [[AppsFlyerLib shared] setConsentData:consentData]; + } + + const void _logAdRevenue(const char* monetizationNetwork, int mediationNetworkInt, const char* currencyIso4217Code, double eventRevenue, const char* additionalParameters) { + AppsFlyerAdRevenueMediationNetworkType mediationNetwork = mediationNetworkTypeFromInt(mediationNetworkInt); + NSString *formattedString = [NSString localizedStringWithFormat:@"%.2f", eventRevenue]; + NSNumber *revenue = [NSDecimalNumber decimalNumberWithString:formattedString]; + AFAdRevenueData *adRevenue = [[AFAdRevenueData alloc] initWithMonetizationNetwork:stringFromChar(monetizationNetwork) mediationNetwork:mediationNetwork currencyIso4217Code:stringFromChar(currencyIso4217Code) eventRevenue:revenue]; + [[AppsFlyerLib shared] logAdRevenue: adRevenue additionalParameters:dictionaryFromJson(additionalParameters)]; + } + + const void _setDisableCollectIAd (bool disableCollectASA) { + [AppsFlyerLib shared].disableCollectASA = disableCollectASA; + } + + const void _setUseReceiptValidationSandbox (bool useReceiptValidationSandbox) { + [AppsFlyerLib shared].useReceiptValidationSandbox = useReceiptValidationSandbox; + } + + const void _setUseUninstallSandbox (bool useUninstallSandbox) { + [AppsFlyerLib shared].useUninstallSandbox = useUninstallSandbox; + } + + const void _setResolveDeepLinkURLs (int length, const char **resolveDeepLinkURLs) { + if(length > 0 && resolveDeepLinkURLs) { + [[AppsFlyerLib shared] setResolveDeepLinkURLs:NSArrayFromCArray(length, resolveDeepLinkURLs)]; + } + } + + const void _setOneLinkCustomDomains (int length, const char **oneLinkCustomDomains) { + if(length > 0 && oneLinkCustomDomains) { + [[AppsFlyerLib shared] setOneLinkCustomDomains:NSArrayFromCArray(length, oneLinkCustomDomains)]; + } + } + + const void _afSendEvent (const char* eventName, const char* eventValues, bool shouldCallback, const char* objectName) { + inAppRequestObjectName = stringFromChar(objectName); + [[AppsFlyerLib shared] logEventWithEventName:stringFromChar(eventName) eventValues:dictionaryFromJson(eventValues) completionHandler:^(NSDictionary *dictionary, NSError *error) { + if(shouldCallback){ + if (error) { + NSDictionary *callbackDictionary = @{@"statusCode":[NSNumber numberWithLong:[error code]]}; + unityCallBack(inAppRequestObjectName, IN_APP_RESPONSE_CALLBACK, stringFromdictionary(callbackDictionary)); + return; + } + if (dictionary) { + unityCallBack(inAppRequestObjectName, IN_APP_RESPONSE_CALLBACK, stringFromdictionary(dictionary)); + return; + } + } + }]; + } + + const void _recordLocation (double longitude, double latitude) { + [[AppsFlyerLib shared] logLocation:longitude latitude:latitude]; + } + + const char* _getAppsFlyerId () { + return getCString([[[AppsFlyerLib shared] getAppsFlyerUID] UTF8String]); + } + + const void _registerUninstall (unsigned char* deviceToken) { + if(deviceToken){ + NSData* tokenData = [NSData dataWithBytes:(const void *)deviceToken length:sizeof(unsigned char)*kPushNotificationSize]; + [[AppsFlyerLib shared] registerUninstall:tokenData]; + } + } + + const void _handlePushNotification (const char* pushPayload) { + [[AppsFlyerLib shared] handlePushNotification:dictionaryFromJson(pushPayload)]; + } + + const char* _getSDKVersion () { + return getCString([[[AppsFlyerLib shared] getSDKVersion] UTF8String]); + } + + const void _setHost (const char* host, const char* hostPrefix) { + [[AppsFlyerLib shared] setHost:stringFromChar(host) withHostPrefix:stringFromChar(hostPrefix)]; + } + + const void _setMinTimeBetweenSessions (int minTimeBetweenSessions) { + [AppsFlyerLib shared].minTimeBetweenSessions = minTimeBetweenSessions; + } + + const void _stopSDK (bool isStopped) { + [AppsFlyerLib shared].isStopped = isStopped; + } + + const BOOL _isSDKStopped () { + return [AppsFlyerLib shared].isStopped; + } + + const void _handleOpenUrl(const char *url, const char *sourceApplication, const char *annotation) { + [[AppsFlyerLib shared] handleOpenURL:[NSURL URLWithString:stringFromChar(url)] sourceApplication:stringFromChar(sourceApplication) withAnnotation:stringFromChar(annotation)]; } + + const void _recordCrossPromoteImpression (const char* appID, const char* campaign, const char* parameters) { + [AppsFlyerCrossPromotionHelper logCrossPromoteImpression:stringFromChar(appID) campaign:stringFromChar(campaign) parameters:dictionaryFromJson(parameters)]; } + + const void _attributeAndOpenStore (const char* appID, const char* campaign, const char* parameters, const char* objectName) { + + openStoreObjectName = stringFromChar(objectName); + + [AppsFlyerCrossPromotionHelper + logAndOpenStore:stringFromChar(appID) + campaign:stringFromChar(campaign) + parameters:dictionaryFromJson(parameters) + openStore:^(NSURLSession * _Nonnull urlSession, NSURL * _Nonnull clickURL) { + unityCallBack(openStoreObjectName, OPEN_STORE_LINK_CALLBACK, [clickURL.absoluteString UTF8String]); + }]; + } + + const void _generateUserInviteLink (const char* parameters, const char* objectName) { + + generateInviteObjectName = stringFromChar(objectName); + + [AppsFlyerShareInviteHelper generateInviteUrlWithLinkGenerator:^AppsFlyerLinkGenerator * _Nonnull(AppsFlyerLinkGenerator * _Nonnull generator) { + return generatorFromDictionary(dictionaryFromJson(parameters), generator); + } completionHandler:^(NSURL * _Nullable url) { + unityCallBack(generateInviteObjectName, GENERATE_LINK_CALLBACK, [url.absoluteString UTF8String]); + }]; + } + + const void _recordInvite (const char* channel, const char* parameters) { + [AppsFlyerShareInviteHelper logInvite:stringFromChar(channel) parameters:dictionaryFromJson(parameters)]; + } + + const void _setUserEmails (int emailCryptTypeInt , int length, const char **userEmails) { + if(length > 0 && userEmails) { + [[AppsFlyerLib shared] setUserEmails:NSArrayFromCArray(length, userEmails) withCryptType:emailCryptTypeFromInt(emailCryptTypeInt)]; + } + } + + const void _setPhoneNumber (const char* phoneNumber) { + [[AppsFlyerLib shared] setPhoneNumber:stringFromChar(phoneNumber)]; + } + + const void _setSharingFilterForAllPartners () { + [[AppsFlyerLib shared] setSharingFilterForAllPartners]; + } + + const void _setSharingFilter (int length, const char **partners) { + if(length > 0 && partners) { + [[AppsFlyerLib shared] setSharingFilter:NSArrayFromCArray(length, partners)]; + } + } + + const void _setSharingFilterForPartners (int length, const char **partners) { + if(length > 0 && partners) { + [[AppsFlyerLib shared] setSharingFilterForPartners:NSArrayFromCArray(length, partners)]; + } else { + [[AppsFlyerLib shared] setSharingFilterForPartners:nil]; + } + } + + const void _validateAndSendInAppPurchase (const char* productIdentifier, const char* price, const char* currency, const char* transactionId, const char* additionalParameters, const char* objectName) { + + validateObjectName = stringFromChar(objectName); + + [[AppsFlyerLib shared] + validateAndLogInAppPurchase:stringFromChar(productIdentifier) + price:stringFromChar(price) + currency:stringFromChar(currency) + transactionId:stringFromChar(transactionId) + additionalParameters:dictionaryFromJson(additionalParameters) + success:^(NSDictionary *result){ + unityCallBack(validateObjectName, VALIDATE_CALLBACK, stringFromdictionary(result)); + } failure:^(NSError *error, id response) { + if(response && [response isKindOfClass:[NSDictionary class]]) { + NSDictionary* value = (NSDictionary*)response; + unityCallBack(validateObjectName, VALIDATE_ERROR_CALLBACK, stringFromdictionary(value)); + } else { + unityCallBack(validateObjectName, VALIDATE_ERROR_CALLBACK, error ? [[error localizedDescription] UTF8String] : "error"); + } + }]; + } + + const void _validateAndSendInAppPurchaseV2 (const char* product, const char* price, const char* currency, const char* transactionId, const char* extraEventValues, const char* objectName) { + + validateAndLogObjectName = stringFromChar(objectName); + AFSDKPurchaseDetails *details = [[AFSDKPurchaseDetails alloc] initWithProductId:stringFromChar(product) price:stringFromChar(price) currency:stringFromChar(currency) transactionId:stringFromChar(transactionId)]; + + [[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)); + } else { + unityCallBack(validateAndLogObjectName, VALIDATE_AND_LOG_V2_ERROR_CALLBACK, stringFromdictionary(dictionaryFromNSError(result.error))); + } + }]; + + } + + const void _getConversionData(const char* objectName) { + if (_AppsFlyerdelegate == nil) { + _AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init]; + } + ConversionDataCallbackObject = stringFromChar(objectName); + [[AppsFlyerLib shared] setDelegate:_AppsFlyerdelegate]; + } + + const void _waitForATTUserAuthorizationWithTimeoutInterval (int timeoutInterval) { + [[AppsFlyerLib shared] waitForATTUserAuthorizationWithTimeoutInterval:timeoutInterval]; + } + + const void _disableSKAdNetwork (bool isDisabled) { + [AppsFlyerLib shared].disableSKAdNetwork = isDisabled; + } + + const void _addPushNotificationDeepLinkPath (int length, const char **paths) { + if(length > 0 && paths) { + [[AppsFlyerLib shared] addPushNotificationDeepLinkPath:NSArrayFromCArray(length, paths)]; + } + } + + const void _subscribeForDeepLink (const char* objectName) { + + onDeeplinkingObjectName = stringFromChar(objectName); + + if (_AppsFlyerdelegate == nil) { + _AppsFlyerdelegate = [[AppsFlyeriOSWarpper alloc] init]; + } + [[AppsFlyerLib shared] setDeepLinkDelegate:_AppsFlyerdelegate]; + } + + const void _setCurrentDeviceLanguage(const char* language) { + [[AppsFlyerLib shared] setCurrentDeviceLanguage:stringFromChar(language)]; + } + + const void _setPartnerData(const char* partnerId, const char* partnerInfo) { + [[AppsFlyerLib shared] setPartnerDataWithPartnerId: stringFromChar(partnerId) partnerInfo:dictionaryFromJson(partnerInfo)]; + } + + const void _disableIDFVCollection(bool isDisabled) { + [AppsFlyerLib shared].disableIDFVCollection = isDisabled; + } + +} + +@implementation AppsFlyeriOSWarpper + +static BOOL didCallStart; ++ (BOOL) didCallStart +{ @synchronized(self) { return didCallStart; } } ++ (void) setDidCallStart:(BOOL)val +{ @synchronized(self) { didCallStart = val; } } + +- (void)onConversionDataSuccess:(NSDictionary *)installData { + unityCallBack(ConversionDataCallbackObject, GCD_CALLBACK, stringFromdictionary(installData)); +} + +- (void)onConversionDataFail:(NSError *)error { + unityCallBack(ConversionDataCallbackObject, GCD_ERROR_CALLBACK, [[error localizedDescription] UTF8String]); +} + +- (void)onAppOpenAttribution:(NSDictionary *)attributionData { + unityCallBack(ConversionDataCallbackObject, OAOA_CALLBACK, stringFromdictionary(attributionData)); +} + +- (void)onAppOpenAttributionFailure:(NSError *)error { + unityCallBack(ConversionDataCallbackObject, OAOA_ERROR_CALLBACK, [[error localizedDescription] UTF8String]); +} + +- (void)didResolveDeepLink:(AppsFlyerDeepLinkResult *)result{ + + NSMutableDictionary *dict = [[NSMutableDictionary alloc] init]; + + [dict setValue:stringFromDeepLinkResultError(result) forKey:@"error"]; + [dict setValue:stringFromDeepLinkResultStatus(result.status) forKey:@"status"]; + + if(result && result.deepLink){ + [dict setValue:result.deepLink.description forKey:@"deepLink"]; + [dict setValue:@(result.deepLink.isDeferred) forKey:@"is_deferred"]; + } + + unityCallBack(onDeeplinkingObjectName, ON_DEEPLINKING, stringFromdictionary(dict)); +} + +@end + diff --git a/Plugins/iOS/AppsFlyeriOSWrapper.mm.meta b/Plugins/iOS/AppsFlyeriOSWrapper.mm.meta new file mode 100644 index 00000000..3799161a --- /dev/null +++ b/Plugins/iOS/AppsFlyeriOSWrapper.mm.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: 2bff3788f3d8747fe9679bd3818e1d76 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + 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: diff --git a/Tests.meta b/Tests.meta new file mode 100644 index 00000000..8217a6a3 --- /dev/null +++ b/Tests.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1f19f272c71674582bed1d93925da003 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Castle.Core.dll b/Tests/Castle.Core.dll new file mode 100644 index 00000000..268e311c Binary files /dev/null and b/Tests/Castle.Core.dll differ diff --git a/Tests/Castle.Core.dll.meta b/Tests/Castle.Core.dll.meta new file mode 100644 index 00000000..14cc646e --- /dev/null +++ b/Tests/Castle.Core.dll.meta @@ -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: diff --git a/Tests/NSubstitute.dll b/Tests/NSubstitute.dll new file mode 100644 index 00000000..f32e4919 Binary files /dev/null and b/Tests/NSubstitute.dll differ diff --git a/Tests/NSubstitute.dll.meta b/Tests/NSubstitute.dll.meta new file mode 100644 index 00000000..b716f6a2 --- /dev/null +++ b/Tests/NSubstitute.dll.meta @@ -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: diff --git a/Tests/System.Runtime.CompilerServices.Unsafe.dll b/Tests/System.Runtime.CompilerServices.Unsafe.dll new file mode 100644 index 00000000..c5ba4e40 Binary files /dev/null and b/Tests/System.Runtime.CompilerServices.Unsafe.dll differ diff --git a/Tests/System.Runtime.CompilerServices.Unsafe.dll.meta b/Tests/System.Runtime.CompilerServices.Unsafe.dll.meta new file mode 100644 index 00000000..fca37704 --- /dev/null +++ b/Tests/System.Runtime.CompilerServices.Unsafe.dll.meta @@ -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: diff --git a/Tests/System.Threading.Tasks.Extensions.dll b/Tests/System.Threading.Tasks.Extensions.dll new file mode 100644 index 00000000..dfc4cdf6 Binary files /dev/null and b/Tests/System.Threading.Tasks.Extensions.dll differ diff --git a/Tests/System.Threading.Tasks.Extensions.dll.meta b/Tests/System.Threading.Tasks.Extensions.dll.meta new file mode 100644 index 00000000..cb661cab --- /dev/null +++ b/Tests/System.Threading.Tasks.Extensions.dll.meta @@ -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: diff --git a/Tests/Tests.asmdef b/Tests/Tests.asmdef new file mode 100644 index 00000000..4d103636 --- /dev/null +++ b/Tests/Tests.asmdef @@ -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 +} \ No newline at end of file diff --git a/Tests/Tests.asmdef.meta b/Tests/Tests.asmdef.meta new file mode 100644 index 00000000..27780081 --- /dev/null +++ b/Tests/Tests.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 1f155a0e4c9ab48eeb4b54b2dc0aeba7 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Tests/Tests_Suite.cs b/Tests/Tests_Suite.cs new file mode 100644 index 00000000..95231315 --- /dev/null +++ b/Tests/Tests_Suite.cs @@ -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(); + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.startSDK(); + AppsFlyerMOCKInterface.Received().startSDK(Arg.Any(), Arg.Any()); + + } + + [Test] + public void test_sendEvent_withValues() + { + var AppsFlyerMOCKInterface = Substitute.For(); + AppsFlyer.instance = AppsFlyerMOCKInterface; + var eventParams = new Dictionary(); + 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(); + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.sendEvent("testevent", null); + AppsFlyerMOCKInterface.Received().sendEvent("testevent", null,false, null); + } + + + [Test] + public void test_isSDKStopped_true() + { + var AppsFlyerMOCKInterface = Substitute.For(); + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.stopSDK(true); + + AppsFlyerMOCKInterface.Received().stopSDK(true); + + } + + [Test] + public void test_isSDKStopped_false() + { + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + + AppsFlyer.stopSDK(false); + + AppsFlyerMOCKInterface.Received().stopSDK(false); + + } + + [Test] + public void test_isSDKStopped_called() + { + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + + var isSDKStopped = AppsFlyer.isSDKStopped(); + + AppsFlyerMOCKInterface.Received().isSDKStopped(); + + } + + [Test] + public void test_isSDKStopped_receveivedFalse() + { + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + + var isSDKStopped = AppsFlyer.isSDKStopped(); + + Assert.AreEqual(AppsFlyerMOCKInterface.Received().isSDKStopped(), false); + + + } + + + [Test] + public void test_getSdkVersion_called() + { + var AppsFlyerMOCKInterface = Substitute.For(); + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.getSdkVersion(); + AppsFlyerMOCKInterface.Received().getSdkVersion(); + } + + [Test] + public void test_setCustomerUserId_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setCustomerUserId("test"); + AppsFlyerMOCKInterface.Received().setCustomerUserId("test"); + + } + + [Test] + public void Test_setAppInviteOneLinkID_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setAppInviteOneLinkID("2f36"); + AppsFlyerMOCKInterface.Received().setAppInviteOneLinkID("2f36"); + + } + + [Test] + public void Test_setAdditionalData_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + var customData = new Dictionary(); + customData.Add("test", "test"); + AppsFlyer.setAdditionalData(customData); + AppsFlyerMOCKInterface.Received().setAdditionalData(customData); + } + + [Test] + public void Test_setResolveDeepLinkURLs_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setResolveDeepLinkURLs("url1", "url2"); + AppsFlyerMOCKInterface.Received().setResolveDeepLinkURLs("url1", "url2"); + + } + + [Test] + public void Test_setOneLinkCustomDomain_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setOneLinkCustomDomain("url1", "url2"); + AppsFlyerMOCKInterface.Received().setOneLinkCustomDomain("url1", "url2"); + + } + + [Test] + public void Test_setCurrencyCode_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setCurrencyCode("usd"); + AppsFlyerMOCKInterface.Received().setCurrencyCode("usd"); + + } + + [Test] + public void Test_recordLocation_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + 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(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.anonymizeUser(true); + AppsFlyerMOCKInterface.Received().anonymizeUser(true); + + } + + [Test] + public void Test_anonymizeUser_false() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.anonymizeUser(false); + AppsFlyerMOCKInterface.Received().anonymizeUser(false); + + } + + [Test] + public void Test_getAppsFlyerId_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.getAppsFlyerId(); + AppsFlyerMOCKInterface.Received().getAppsFlyerId(); + + } + + [Test] + public void Test_setMinTimeBetweenSessions_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setMinTimeBetweenSessions(3); + AppsFlyerMOCKInterface.Received().setMinTimeBetweenSessions(3); + + } + + [Test] + public void Test_setHost_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setHost("prefix", "name"); + AppsFlyerMOCKInterface.Received().setHost("prefix", "name"); + + } + + [Test] + public void Test_setPhoneNumber_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setPhoneNumber("002"); + AppsFlyerMOCKInterface.Received().setPhoneNumber("002"); + + } + + + [Test] + [System.Obsolete] + public void Test_setSharingFilterForAllPartners_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setSharingFilterForAllPartners(); + AppsFlyerMOCKInterface.Received().setSharingFilterForAllPartners(); + + } + + [Test] + [System.Obsolete] + public void Test_setSharingFilter_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + + + AppsFlyer.setSharingFilter("filter1", "filter2"); + AppsFlyerMOCKInterface.Received().setSharingFilter("filter1", "filter2"); + + } + + [Test] + public void Test_getConversionData_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + + AppsFlyer.getConversionData("ObjectName"); + AppsFlyerMOCKInterface.Received().getConversionData("ObjectName"); + + } + + [Test] + public void Test_attributeAndOpenStore_called_withParams() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + Dictionary parameters = new Dictionary(); + 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()); + + } + + [Test] + public void Test_attributeAndOpenStore_called_nullParams() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + + AppsFlyer.attributeAndOpenStore("appid", "campaign", null, new MonoBehaviour()); + AppsFlyerMOCKInterface.Received().attributeAndOpenStore("appid", "campaign", null, Arg.Any()); + + } + + [Test] + public void Test_recordCrossPromoteImpression_calledWithParameters() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + Dictionary parameters = new Dictionary(); + 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(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.recordCrossPromoteImpression("appid", "campaign", null); + AppsFlyerMOCKInterface.Received().recordCrossPromoteImpression("appid", "campaign", null); + + } + + [Test] + public void Test_generateUserInviteLink_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + + AppsFlyer.generateUserInviteLink(new Dictionary(), new MonoBehaviour()); + AppsFlyerMOCKInterface.Received().generateUserInviteLink(Arg.Any>(), Arg.Any()); + + } + + + [Test] + public void Test_addPushNotificationDeepLinkPath_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.addPushNotificationDeepLinkPath("path1", "path2"); + AppsFlyerMOCKInterface.Received().addPushNotificationDeepLinkPath("path1", "path2"); + + } + +#if UNITY_ANDROID + [Test] + public void updateServerUninstallToken_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.updateServerUninstallToken("tokenTest"); + AppsFlyerMOCKInterface.Received().updateServerUninstallToken("tokenTest"); + + } + + [Test] + public void setImeiData_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setImeiData("imei"); + AppsFlyerMOCKInterface.Received().setImeiData("imei"); + + } + + [Test] + public void setAndroidIdData_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setAndroidIdData("androidId"); + AppsFlyerMOCKInterface.Received().setAndroidIdData("androidId"); + + } + + [Test] + public void waitForCustomerUserId_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.waitForCustomerUserId(true); + AppsFlyerMOCKInterface.Received().waitForCustomerUserId(true); + + } + + [Test] + public void setCustomerIdAndStartSDK_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setCustomerIdAndStartSDK("01234"); + AppsFlyerMOCKInterface.Received().setCustomerIdAndStartSDK("01234"); + + } + + + [Test] + public void getOutOfStore_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.getOutOfStore(); + AppsFlyerMOCKInterface.Received().getOutOfStore(); + + } + + [Test] + public void setOutOfStore_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setOutOfStore("test"); + AppsFlyerMOCKInterface.Received().setOutOfStore("test"); + + } + + [Test] + public void setCollectAndroidID_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setCollectAndroidID(true); + AppsFlyerMOCKInterface.Received().setCollectAndroidID(true); + + } + + [Test] + public void setCollectIMEI_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setCollectIMEI(true); + AppsFlyerMOCKInterface.Received().setCollectIMEI(true); + + } + + [Test] + public void setIsUpdate_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setIsUpdate(true); + AppsFlyerMOCKInterface.Received().setIsUpdate(true); + + } + + [Test] + public void setPreinstallAttribution_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setPreinstallAttribution("mediaSourceTestt", "campaign", "sideId"); + AppsFlyerMOCKInterface.Received().setPreinstallAttribution("mediaSourceTestt", "campaign", "sideId"); + + } + + [Test] + public void isPreInstalledApp_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.isPreInstalledApp(); + AppsFlyerMOCKInterface.Received().isPreInstalledApp(); + + } + + [Test] + public void getAttributionId_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.getAttributionId(); + AppsFlyerMOCKInterface.Received().getAttributionId(); + + } + + [Test] + public void handlePushNotifications_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.handlePushNotifications(); + AppsFlyerMOCKInterface.Received().handlePushNotifications(); + + } + + [Test] + public void validateAndSendInAppPurchase_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + 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(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setCollectOaid(true); + AppsFlyerMOCKInterface.Received().setCollectOaid(true); + + } + + [Test] + public void setDisableAdvertisingIdentifiers_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setDisableAdvertisingIdentifiers(true); + AppsFlyerMOCKInterface.Received().setDisableAdvertisingIdentifiers(true); + + } + + [Test] + public void setDisableNetworkData_called() { + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setDisableNetworkData(true); + AppsFlyerMOCKInterface.Received().setDisableNetworkData(true); + } +#elif UNITY_IOS + + [Test] + public void setDisableCollectAppleAdSupport_called_true() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setDisableCollectAppleAdSupport(true); + AppsFlyerMOCKInterface.Received().setDisableCollectAppleAdSupport(true); + + } + + [Test] + public void setDisableCollectAppleAdSupport_called_false() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setDisableCollectAppleAdSupport(false); + AppsFlyerMOCKInterface.Received().setDisableCollectAppleAdSupport(false); + + } + + [Test] + [System.Obsolete] + public void setShouldCollectDeviceName_called_true() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setShouldCollectDeviceName(true); + AppsFlyerMOCKInterface.Received().setShouldCollectDeviceName(true); + + } + + [Test] + [System.Obsolete] + public void setShouldCollectDeviceName_called_false() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setShouldCollectDeviceName(false); + AppsFlyerMOCKInterface.Received().setShouldCollectDeviceName(false); + + } + + [Test] + public void setDisableCollectIAd_called_true() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setDisableCollectIAd(true); + AppsFlyerMOCKInterface.Received().setDisableCollectIAd(true); + + } + + [Test] + public void setDisableCollectIAd_called_false() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setDisableCollectIAd(false); + AppsFlyerMOCKInterface.Received().setDisableCollectIAd(false); + + } + + [Test] + public void setUseReceiptValidationSandbox_called_true() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setUseReceiptValidationSandbox(true); + AppsFlyerMOCKInterface.Received().setUseReceiptValidationSandbox(true); + + } + + [Test] + public void setUseReceiptValidationSandbox_called_false() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setUseReceiptValidationSandbox(false); + AppsFlyerMOCKInterface.Received().setUseReceiptValidationSandbox(false); + + } + + [Test] + public void ssetUseUninstallSandbox_called_true() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setUseUninstallSandbox(true); + AppsFlyerMOCKInterface.Received().setUseUninstallSandbox(true); + + } + + [Test] + public void setUseUninstallSandbox_called_false() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setUseUninstallSandbox(false); + AppsFlyerMOCKInterface.Received().setUseUninstallSandbox(false); + + } + + [Test] + public void validateAndSendInAppPurchase_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + 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(); + + 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(); + + 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(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.waitForATTUserAuthorizationWithTimeoutInterval(30); + AppsFlyerMOCKInterface.Received().waitForATTUserAuthorizationWithTimeoutInterval(30); + + } + + [Test] + public void setCurrentDeviceLanguage_called() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.setCurrentDeviceLanguage("en"); + AppsFlyerMOCKInterface.Received().setCurrentDeviceLanguage("en"); + + } + + [Test] + public void disableSKAdNetwork_called_true() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.disableSKAdNetwork(true); + AppsFlyerMOCKInterface.Received().disableSKAdNetwork(true); + + } + + [Test] + public void disableSKAdNetwork_called_false() + { + + var AppsFlyerMOCKInterface = Substitute.For(); + + AppsFlyer.instance = AppsFlyerMOCKInterface; + AppsFlyer.disableSKAdNetwork(false); + AppsFlyerMOCKInterface.Received().disableSKAdNetwork(false); + + } + +#endif + } +} diff --git a/Tests/Tests_Suite.cs.meta b/Tests/Tests_Suite.cs.meta new file mode 100644 index 00000000..c20a62c7 --- /dev/null +++ b/Tests/Tests_Suite.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1b1a24aa01166451d804d7c03c14a3db +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Windows.meta b/Windows.meta new file mode 100644 index 00000000..859b3f26 --- /dev/null +++ b/Windows.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1fbfcb6aeaa7f40e69a0daff450a2450 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Windows/AppsFlyerLib.pdb b/Windows/AppsFlyerLib.pdb new file mode 100644 index 00000000..1bea160d Binary files /dev/null and b/Windows/AppsFlyerLib.pdb differ diff --git a/Windows/AppsFlyerLib.pdb.meta b/Windows/AppsFlyerLib.pdb.meta new file mode 100644 index 00000000..fd461dc7 --- /dev/null +++ b/Windows/AppsFlyerLib.pdb.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: d0748deab2f031f42b801afab0837a59 +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Windows/AppsFlyerLib.pri b/Windows/AppsFlyerLib.pri new file mode 100644 index 00000000..f3993bee Binary files /dev/null and b/Windows/AppsFlyerLib.pri differ diff --git a/Windows/AppsFlyerLib.pri.meta b/Windows/AppsFlyerLib.pri.meta new file mode 100644 index 00000000..ed4fbf84 --- /dev/null +++ b/Windows/AppsFlyerLib.pri.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c621896ec81267f478e98555031271ef +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Windows/AppsFlyerLib.winmd b/Windows/AppsFlyerLib.winmd new file mode 100644 index 00000000..381ce320 Binary files /dev/null and b/Windows/AppsFlyerLib.winmd differ diff --git a/Windows/AppsFlyerLib.winmd.meta b/Windows/AppsFlyerLib.winmd.meta new file mode 100644 index 00000000..728454ca --- /dev/null +++ b/Windows/AppsFlyerLib.winmd.meta @@ -0,0 +1,38 @@ +fileFormatVersion: 2 +guid: 5186898c6f4665f438e46763d4cff3ae +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + - first: + XboxOne: XboxOne + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Windows/AppsFlyerWindows.cs b/Windows/AppsFlyerWindows.cs new file mode 100644 index 00000000..8fd696f8 --- /dev/null +++ b/Windows/AppsFlyerWindows.cs @@ -0,0 +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 eventValues) + { +#if ENABLE_WINMD_SUPPORT + if (eventValues == null) + { + eventValues = new Dictionary(); + } + IDictionary result = new Dictionary(); + foreach (KeyValuePair 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 diff --git a/Windows/AppsFlyerWindows.cs.meta b/Windows/AppsFlyerWindows.cs.meta new file mode 100644 index 00000000..66f10a13 --- /dev/null +++ b/Windows/AppsFlyerWindows.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 034d11e52b599954181d7f08c0d89ca8 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/package.json b/package.json new file mode 100644 index 00000000..b1292ede --- /dev/null +++ b/package.json @@ -0,0 +1,8 @@ +{ + "name": "appsflyer-unity-plugin", + "displayName": "AppsFlyer", + "description": "AppsFlyer Unity plugin", + "version": "6.15.2", + "unity": "2019.4", + "license": "MIT" + } diff --git a/package.json.meta b/package.json.meta new file mode 100644 index 00000000..e9b3d879 --- /dev/null +++ b/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a2b3ab5da7dda473b8791503604647b4 +TextScriptImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: