diff --git a/AFInAppEvents.cs b/AFInAppEvents.cs new file mode 100644 index 0000000..1f6d1fe --- /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 0000000..f21eba3 --- /dev/null +++ b/AFInAppEvents.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 4bda50a55ee3549dcb21fc684c4776c2 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AFMiniJSON.cs b/AFMiniJSON.cs new file mode 100644 index 0000000..d02bf2f --- /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 0000000..55bc8fa --- /dev/null +++ b/AFMiniJSON.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 54bb2b2c240304b7eaa463b9ff2b1b20 +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 0000000..381ee00 --- /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 0000000..de17426 --- /dev/null +++ b/AppsFlyer.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: c3b2ad556d41d1441bfade97a3c348cd +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyer.cs b/AppsFlyer.cs new file mode 100644 index 0000000..af9df81 --- /dev/null +++ b/AppsFlyer.cs @@ -0,0 +1,508 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace AppsFlyerSDK +{ + public class AppsFlyer : MonoBehaviour + { + + public static readonly string kAppsFlyerPluginVersion = "5.4.2"; + + + /// + /// 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 UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setAppsFlyerDevKey(devKey); + AppsFlyeriOS.setAppleAppID(appID); + if(gameObject != null) + { + AppsFlyeriOS.getConversionData(gameObject.name); + } +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.initSDK(devKey, gameObject); +#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_IOS && !UNITY_EDITOR + AppsFlyeriOS.startSDK(); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.startSDK(); +#else + +#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_IOS && !UNITY_EDITOR + AppsFlyeriOS.sendEvent(eventName, eventValues); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.sendEvent(eventName, eventValues); +#else + +#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 UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.stopSDK(isSDKStopped); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.stopSDK(isSDKStopped); +#else + +#endif + } + + // + /// Was the stopSDK(boolean) API set to true. + /// + /// boolean isSDKStopped. + public static bool isSDKStopped() + { +#if UNITY_IOS && !UNITY_EDITOR + return AppsFlyeriOS.isSDKStopped(); +#elif UNITY_ANDROID && !UNITY_EDITOR + return AppsFlyerAndroid.isSDKStopped(); +#else + return false; +#endif + } + + /// + /// Get the AppsFlyer SDK version used in app. + /// + /// The current SDK version. + public static string getSdkVersion() + { +#if UNITY_IOS && !UNITY_EDITOR + return AppsFlyeriOS.getSDKVersion(); +#elif UNITY_ANDROID && !UNITY_EDITOR + return AppsFlyerAndroid.getSdkVersion(); +#else + return ""; +#endif + + } + + /// + /// 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 UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setIsDebug(shouldEnable); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.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_IOS && !UNITY_EDITOR + AppsFlyeriOS.setCustomerUserID(id); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setCustomerUserId(id); +#else + +#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 UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setAppInviteOneLinkID(oneLinkId); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setAppInviteOneLinkID(oneLinkId); +#else + +#endif + } + + /// + /// Set additional data to be sent to AppsFlyer. + /// + /// additional data Dictionary. + public static void setAdditionalData(Dictionary customData) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setAdditionalData(customData); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setAdditionalData(customData); +#else + +#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 static void setResolveDeepLinkURLs(params string[] urls) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setResolveDeepLinkURLs(urls); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setResolveDeepLinkURLs(urls); +#else + +#endif + } + + + /// + /// Advertisers can use this method to set vanity onelink domains. + /// + /// Array of domains. + public static void setOneLinkCustomDomain(params string[] domains) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setOneLinkCustomDomains(domains); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setOneLinkCustomDomain(domains); +#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 UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setCurrencyCode(currencyCode); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setCurrencyCode(currencyCode); +#else + +#endif + } + + /// + /// Manually record the location of the user. + /// + /// latitude as double. + /// longitude as double. + public static void recordLocation(double latitude, double longitude) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.recordLocation(latitude, longitude); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.recordLocation(latitude, longitude); +#else + +#endif + } + + /// + /// 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 UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.anonymizeUser(shouldAnonymizeUser); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.anonymizeUser(shouldAnonymizeUser); +#else + +#endif + } + + /// + /// 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_IOS && !UNITY_EDITOR + return AppsFlyeriOS.getAppsFlyerId(); +#elif UNITY_ANDROID && !UNITY_EDITOR + return AppsFlyerAndroid.getAppsFlyerId(); +#else + return ""; +#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 static void setMinTimeBetweenSessions(int seconds) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setMinTimeBetweenSessions(seconds); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setMinTimeBetweenSessions(seconds); +#else + +#endif + } + + /// + /// Set a custom host. + /// + /// Host prefix. + /// Host name. + public static void setHost(string hostPrefixName, string hostName) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setHost(hostName, hostPrefixName); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.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 cryptMethod, params string[] emails) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setUserEmails(cryptMethod, emails.Length, emails); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setUserEmails(cryptMethod, emails); +#else + +#endif + } + + /// + /// Set the user phone number. + /// + /// phoneNumber string + public static void setPhoneNumber(string phoneNumber) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setPhoneNumber(phoneNumber); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setPhoneNumber(phoneNumber); +#else + +#endif + } + + /// + /// Used by advertisers to exclude all networks/integrated partners from getting data. + /// + public static void setSharingFilterForAllPartners() + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setSharingFilterForAllPartners(); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setSharingFilterForAllPartners(); +#else + +#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 static void setSharingFilter(params string[] partners) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.setSharingFilter(partners); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.setSharingFilter(partners); +#else + +#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. + /// + /// + /// + /// AppsFlyer.getConversionData(this.name); + /// + /// + public static void getConversionData(string objectName) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.getConversionData(objectName); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.getConversionData(objectName); +#else + +#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 + /// + /// + /// 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 UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.attributeAndOpenStore(appID, campaign, userParams, gameObject); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.attributeAndOpenStore(appID, campaign, userParams); +#else + +#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 static void recordCrossPromoteImpression(string appID, string campaign, Dictionary parameters) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.recordCrossPromoteImpression(appID, campaign, parameters); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.recordCrossPromoteImpression(appID, campaign, parameters); +#else + +#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 static void generateUserInviteLink(Dictionary parameters, MonoBehaviour gameObject) + { +#if UNITY_IOS && !UNITY_EDITOR + AppsFlyeriOS.generateUserInviteLink(parameters, gameObject); +#elif UNITY_ANDROID && !UNITY_EDITOR + AppsFlyerAndroid.generateUserInviteLink(parameters, gameObject); +#else + +#endif + } + + /// + /// 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 0000000..a7e4587 --- /dev/null +++ b/AppsFlyer.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3ee67b96679174324b71b44080a6741c +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 0000000..2ce7d61 --- /dev/null +++ b/AppsFlyerAndroid.cs @@ -0,0 +1,657 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace AppsFlyerSDK +{ + +#if UNITY_ANDROID + public class AppsFlyerAndroid + { + + private static AndroidJavaClass appsFlyerAndroid = new AndroidJavaClass("com.appsflyer.unity.AppsFlyerAndroidWrapper"); + + + /// + /// 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 static 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 static void startSDK() + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("startTracking"); +#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 static void stopSDK(bool isSDKStopped) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("stopTracking", isSDKStopped); +#endif + } + + /// + /// Get the AppsFlyer SDK version used in app. + /// + /// AppsFlyer SDK version. + public static 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 static 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 static 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 static 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 static 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 static 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 static 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 static void setCustomerIdAndStartSDK(string id) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setCustomerIdAndTrack", id); +#endif + } + + /// + /// Get the current AF_STORE value. + /// + /// AF_Store value. + public static string getOutOfStore() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("getOutOfStore"); +#else + return ""; +#endif + } + + /// + /// Manually set the AF_STORE value. + /// + /// value to be set. + public static 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 static void setAppInviteOneLinkID(string oneLinkId) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setAppInviteOneLinkID", oneLinkId); +#endif + } + + /// + /// Set additional data to be sent to AppsFlyer. + /// + /// additional data Dictionary. + public static void setAdditionalData(Dictionary customData) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setAdditionalData", convertDictionaryToJavaMap(customData)); +#endif + } + + /// + /// Set the user emails. + /// + /// User emails. + public static void setUserEmails(params string[] emails) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setUserEmails", (object)emails); +#endif + } + + + /// + /// Set the user phone number. + /// + /// User phoneNumber. + public static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static void sendEvent(string eventName, Dictionary eventValues) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("trackEvent", eventName, convertDictionaryToJavaMap(eventValues)); +#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 static void anonymizeUser(bool isDisabled) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setDeviceTrackingDisabled", isDisabled); +#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 static void enableFacebookDeferredApplinks(bool isEnabled) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("enableFacebookDeferredApplinks", isEnabled); +#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 static 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 static 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 static 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 static 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 static 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 static 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 + } + + /// + /// Was the stopSDK(boolean) API set to true. + /// + /// boolean isSDKStopped. + public static 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 static void setMinTimeBetweenSessions(int seconds) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setMinTimeBetweenSessions", seconds); +#endif + } + + /// + /// Set a custom host. + /// + /// Host prefix. + /// Host name. + public static 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 static string getHostName() + { +#if !UNITY_EDITOR + return appsFlyerAndroid.CallStatic("getHostName"); +#else + return ""; +#endif + } + + /// + /// Get the custom host prefix. + /// + /// Host prefix. + public static 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 static 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 static void setSharingFilter(params string[] partners) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("setSharingFilter", (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 static void getConversionData(string objectName) + { +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("getConversionData", objectName); +#endif + } + + /// + /// Register a validation listener for the validateAndSendInAppPurchase API. + /// + public static 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 static 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 static void attributeAndOpenStore(string promoted_app_id, string campaign, Dictionary userParams) + { +#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 static 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 static 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 static void handlePushNotifications(){ +#if !UNITY_EDITOR + appsFlyerAndroid.CallStatic("handlePushNotifications"); +#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 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;"); + if (dictionary != null) + { + foreach (var entry in dictionary) + { + AndroidJNI.CallObjectMethod(map.GetRawObject(), putMethod, AndroidJNIHelper.CreateJNIArgArray(new object[] { entry.Key, entry.Value })); + } + } + + return map; + } + } + +#endif + + + +} \ No newline at end of file diff --git a/AppsFlyerAndroid.cs.meta b/AppsFlyerAndroid.cs.meta new file mode 100644 index 0000000..ca999f3 --- /dev/null +++ b/AppsFlyerAndroid.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 1acf06d8f799e4050b792abc42365ab8 +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 0000000..6c9e085 --- /dev/null +++ b/AppsFlyerObject.prefab @@ -0,0 +1,57 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 0} + m_RootGameObject: {fileID: 1562408896289314} + m_IsPrefabAsset: 1 +--- !u!1 &1562408896289314 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 6 + m_Component: + - component: {fileID: 4294345628247858} + - component: {fileID: 114092076686766906} + m_Layer: 0 + m_Name: AppsFlyerObject + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4294345628247858 +Transform: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1562408896289314} + 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 &114092076686766906 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1562408896289314} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 2caf6a738ac024a48bd358f4cc91662a, 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 0000000..ddaed06 --- /dev/null +++ b/AppsFlyerObject.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 4a0acc9a317ee4b6191c57e81b0ddfb7 +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/AppsFlyerObjectScript.cs b/AppsFlyerObjectScript.cs new file mode 100644 index 0000000..49b7b48 --- /dev/null +++ b/AppsFlyerObjectScript.cs @@ -0,0 +1,59 @@ +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 bool isDebug; + public bool getConversionData; + //******************************// + + void Start() + { + // These fields are set from the editor so do not modify! + //******************************// + AppsFlyer.setIsDebug(isDebug); + AppsFlyer.initSDK(devKey, appID, getConversionData ? this : null); + //******************************// + + 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 0000000..25ee3d5 --- /dev/null +++ b/AppsFlyerObjectScript.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 2caf6a738ac024a48bd358f4cc91662a +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 0000000..7992153 --- /dev/null +++ b/AppsFlyeriOS.cs @@ -0,0 +1,586 @@ +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; + +namespace AppsFlyerSDK +{ +#if UNITY_IOS + + public class AppsFlyeriOS + { + + /// + /// Start Session. + /// This will record a session and then record all background forground sessions during the lifecycle of the app. + /// + public static void startSDK() + { +#if !UNITY_EDITOR + _startSDK(); +#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 static void sendEvent(string eventName, Dictionary eventValues) + { +#if !UNITY_EDITOR + _afSendEvent(eventName, AFMiniJSON.Json.Serialize(eventValues)); +#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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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. + public static 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 static void setAppInviteOneLinkID(string appInviteOneLinkID) + { +#if !UNITY_EDITOR + _setAppInviteOneLinkID(appInviteOneLinkID); +#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 static void anonymizeUser(bool shouldAnonymizeUser) + { +#if !UNITY_EDITOR + _anonymizeUser(shouldAnonymizeUser); +#endif + } + + /// + /// Opt-out for Apple Search Ads attributions. + /// + /// boolean disableCollectIAd. + public static 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 static 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 static 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 static void setResolveDeepLinkURLs(params string[] resolveDeepLinkURLs) + { +#if !UNITY_EDITOR + _setResolveDeepLinkURLs(resolveDeepLinkURLs.Length,resolveDeepLinkURLs); +#endif + } + + /// + /// For advertisers who use vanity OneLinks. + /// + /// Array of domains. + public static void setOneLinkCustomDomains(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 static void setUserEmails(EmailCryptType cryptType, int length, params string[] userEmails) + { +#if !UNITY_EDITOR + _setUserEmails(cryptType, length, userEmails); +#endif + } + + /// + /// Set the user phone number. + /// + /// User phoneNumber. + public static 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. + /// + /// 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 static void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string tranactionId, Dictionary additionalParameters, MonoBehaviour gameObject) + { +#if !UNITY_EDITOR + _validateAndSendInAppPurchase(productIdentifier, price, currency, tranactionId, AFMiniJSON.Json.Serialize(additionalParameters), gameObject ? gameObject.name : null); +#endif + } + + /// + /// To record location for geo-fencing. Does the same as code below. + /// + /// The location longitude. + /// The location latitude. + public static 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 static 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 static 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 static void handlePushNotification(Dictionary pushPayload) + { +#if !UNITY_EDITOR + _handlePushNotification(AFMiniJSON.Json.Serialize(pushPayload)); +#endif + } + + /// + /// Get SDK version. + /// + public static 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 static void setHost(string host, string hostPrefix) + { +#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 static 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 static void stopSDK(bool isSDKStopped) + { +#if !UNITY_EDITOR + _stopSDK(isSDKStopped); +#endif + } + + // + /// Was the stopSDK(boolean) API set to true. + /// + /// boolean isSDKStopped. + public static 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 static 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 static 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 static void setSharingFilter(params string[] partners) + { +#if !UNITY_EDITOR + _setSharingFilter(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 static 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 static 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 static 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 static void recordInvite(string channel, Dictionary parameters) + { +#if !UNITY_EDITOR + _recordInvite(channel, AFMiniJSON.Json.Serialize(parameters)); +#endif + } + + + /* + * AppsFlyer ios method mapping + */ + + [DllImport("__Internal")] + private static extern void _startSDK(); + + [DllImport("__Internal")] + private static extern void _getConversionData(string objectName); + + [DllImport("__Internal")] + private static extern void _setCustomerUserID(string customerUserID); + + [DllImport("__Internal")] + private static extern void _setAdditionalData(string customData); + + [DllImport("__Internal")] + private static extern void _setAppsFlyerDevKey(string appsFlyerDevKey); + + [DllImport("__Internal")] + private static extern void _setAppleAppID(string appleAppID); + + [DllImport("__Internal")] + private static extern void _setCurrencyCode(string currencyCode); + + [DllImport("__Internal")] + private static extern void _setDisableCollectAppleAdSupport(bool disableCollectAppleAdSupport); + + [DllImport("__Internal")] + private static extern void _setIsDebug(bool isDebug); + + [DllImport("__Internal")] + private static extern void _setShouldCollectDeviceName(bool shouldCollectDeviceName); + + [DllImport("__Internal")] + private static extern void _setAppInviteOneLinkID(string appInviteOneLinkID); + + [DllImport("__Internal")] + private static extern void _anonymizeUser(bool shouldAnonymizeUser); + + [DllImport("__Internal")] + private static extern void _setDisableCollectIAd(bool disableCollectIAd); + + [DllImport("__Internal")] + private static extern void _setUseReceiptValidationSandbox(bool useReceiptValidationSandbox); + + [DllImport("__Internal")] + private static extern void _setUseUninstallSandbox(bool useUninstallSandbox); + + [DllImport("__Internal")] + private static extern void _setResolveDeepLinkURLs(int length, params string[] resolveDeepLinkURLs); + + [DllImport("__Internal")] + private static extern void _setOneLinkCustomDomains(int length, params string[] oneLinkCustomDomains); + + [DllImport("__Internal")] + private static extern void _setUserEmails(EmailCryptType cryptType, int length, params string[] userEmails); + + [DllImport("__Internal")] + private static extern void _setPhoneNumber(string phoneNumber); + + [DllImport("__Internal")] + private static extern void _afSendEvent(string eventName, string eventValues); + + [DllImport("__Internal")] + private static extern void _validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string tranactionId, string additionalParameters, string objectName); + + [DllImport("__Internal")] + private static extern void _recordLocation(double longitude, double latitude); + + [DllImport("__Internal")] + private static extern string _getAppsFlyerId(); + + [DllImport("__Internal")] + private static extern void _registerUninstall(byte[] deviceToken); + + [DllImport("__Internal")] + private static extern void _handlePushNotification(string pushPayload); + + [DllImport("__Internal")] + private static extern string _getSDKVersion(); + + [DllImport("__Internal")] + private static extern void _setHost(string host, string hostPrefix); + + [DllImport("__Internal")] + private static extern void _setMinTimeBetweenSessions(int minTimeBetweenSessions); + + [DllImport("__Internal")] + private static extern void _stopSDK(bool isStopSDK); + + [DllImport("__Internal")] + private static extern bool _isSDKStopped(); + + [DllImport("__Internal")] + private static extern void _handleOpenUrl(string url, string sourceApplication, string annotation); + + [DllImport("__Internal")] + private static extern void _setSharingFilterForAllPartners(); + + [DllImport("__Internal")] + private static extern void _setSharingFilter(int length, params string[] partners); + + [DllImport("__Internal")] + private static extern void _recordCrossPromoteImpression(string appID, string campaign, string parameters); + + [DllImport("__Internal")] + private static extern void _attributeAndOpenStore(string appID, string campaign, string parameters, string gameObject); + + [DllImport("__Internal")] + private static extern void _generateUserInviteLink(string parameters, string gameObject); + + [DllImport("__Internal")] + private static extern void _recordInvite(string channel, string parameters); + + } + +#endif + + +} \ No newline at end of file diff --git a/AppsFlyeriOS.cs.meta b/AppsFlyeriOS.cs.meta new file mode 100644 index 0000000..c876520 --- /dev/null +++ b/AppsFlyeriOS.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 120dceef0eff140d7b70376e9f0a1202 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/AppsFlyer.Editor.asmdef b/Editor/AppsFlyer.Editor.asmdef new file mode 100644 index 0000000..34dbf83 --- /dev/null +++ b/Editor/AppsFlyer.Editor.asmdef @@ -0,0 +1,17 @@ +{ + "name": "AppsFlyer.Editor", + "references": [ + "GUID:c3b2ad556d41d1441bfade97a3c348cd" + ], + "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 0000000..6f0477e --- /dev/null +++ b/Editor/AppsFlyer.Editor.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: e6960e31ade34ba46811fcd20d1d566d +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/Unity.AppsFlyer.Editor.asmdef b/Editor/Unity.AppsFlyer.Editor.asmdef deleted file mode 100644 index 34dbf83..0000000 --- a/Editor/Unity.AppsFlyer.Editor.asmdef +++ /dev/null @@ -1,17 +0,0 @@ -{ - "name": "AppsFlyer.Editor", - "references": [ - "GUID:c3b2ad556d41d1441bfade97a3c348cd" - ], - "includePlatforms": [ - "Editor" - ], - "excludePlatforms": [], - "allowUnsafeCode": false, - "overrideReferences": false, - "precompiledReferences": [], - "autoReferenced": true, - "defineConstraints": [], - "versionDefines": [], - "noEngineReferences": false -} \ No newline at end of file diff --git a/Editor/Unity.AppsFlyer.Editor.asmdef.meta b/Editor/Unity.AppsFlyer.Editor.asmdef.meta deleted file mode 100644 index 6f0477e..0000000 --- a/Editor/Unity.AppsFlyer.Editor.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: e6960e31ade34ba46811fcd20d1d566d -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/IAppsFlyerConversionData.cs b/IAppsFlyerConversionData.cs new file mode 100644 index 0000000..454eaa6 --- /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 0000000..3e25bce --- /dev/null +++ b/IAppsFlyerConversionData.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c2148c64eaa7b4a44a76b14de953ffcf +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 0000000..aac109e --- /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 0000000..e6b08dc --- /dev/null +++ b/IAppsFlyerUserInvite.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 3add604d2b2ac47269f4e3c24a5ef62a +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 0000000..90490e2 --- /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 0000000..e44c3bb --- /dev/null +++ b/IAppsFlyerValidateReceipt.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7ccadc8fd86194a66b791b2509477fb4 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Runtime.meta b/Runtime.meta deleted file mode 100644 index f1af900..0000000 --- a/Runtime.meta +++ /dev/null @@ -1,8 +0,0 @@ -fileFormatVersion: 2 -guid: 131e67461dec612468ec544abeac63e8 -folderAsset: yes -DefaultImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/AFInAppEvents.cs b/Runtime/AFInAppEvents.cs deleted file mode 100644 index 1f6d1fe..0000000 --- a/Runtime/AFInAppEvents.cs +++ /dev/null @@ -1,72 +0,0 @@ -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/Runtime/AFInAppEvents.cs.meta b/Runtime/AFInAppEvents.cs.meta deleted file mode 100644 index f21eba3..0000000 --- a/Runtime/AFInAppEvents.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 4bda50a55ee3549dcb21fc684c4776c2 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/AFMiniJSON.cs b/Runtime/AFMiniJSON.cs deleted file mode 100644 index d02bf2f..0000000 --- a/Runtime/AFMiniJSON.cs +++ /dev/null @@ -1,547 +0,0 @@ -/* - * 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/Runtime/AFMiniJSON.cs.meta b/Runtime/AFMiniJSON.cs.meta deleted file mode 100644 index 55bc8fa..0000000 --- a/Runtime/AFMiniJSON.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 54bb2b2c240304b7eaa463b9ff2b1b20 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/AppsFlyer.cs b/Runtime/AppsFlyer.cs deleted file mode 100644 index af9df81..0000000 --- a/Runtime/AppsFlyer.cs +++ /dev/null @@ -1,508 +0,0 @@ -using System.Collections.Generic; -using UnityEngine; - -namespace AppsFlyerSDK -{ - public class AppsFlyer : MonoBehaviour - { - - public static readonly string kAppsFlyerPluginVersion = "5.4.2"; - - - /// - /// 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 UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setAppsFlyerDevKey(devKey); - AppsFlyeriOS.setAppleAppID(appID); - if(gameObject != null) - { - AppsFlyeriOS.getConversionData(gameObject.name); - } -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.initSDK(devKey, gameObject); -#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_IOS && !UNITY_EDITOR - AppsFlyeriOS.startSDK(); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.startSDK(); -#else - -#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_IOS && !UNITY_EDITOR - AppsFlyeriOS.sendEvent(eventName, eventValues); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.sendEvent(eventName, eventValues); -#else - -#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 UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.stopSDK(isSDKStopped); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.stopSDK(isSDKStopped); -#else - -#endif - } - - // - /// Was the stopSDK(boolean) API set to true. - /// - /// boolean isSDKStopped. - public static bool isSDKStopped() - { -#if UNITY_IOS && !UNITY_EDITOR - return AppsFlyeriOS.isSDKStopped(); -#elif UNITY_ANDROID && !UNITY_EDITOR - return AppsFlyerAndroid.isSDKStopped(); -#else - return false; -#endif - } - - /// - /// Get the AppsFlyer SDK version used in app. - /// - /// The current SDK version. - public static string getSdkVersion() - { -#if UNITY_IOS && !UNITY_EDITOR - return AppsFlyeriOS.getSDKVersion(); -#elif UNITY_ANDROID && !UNITY_EDITOR - return AppsFlyerAndroid.getSdkVersion(); -#else - return ""; -#endif - - } - - /// - /// 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 UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setIsDebug(shouldEnable); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.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_IOS && !UNITY_EDITOR - AppsFlyeriOS.setCustomerUserID(id); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setCustomerUserId(id); -#else - -#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 UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setAppInviteOneLinkID(oneLinkId); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setAppInviteOneLinkID(oneLinkId); -#else - -#endif - } - - /// - /// Set additional data to be sent to AppsFlyer. - /// - /// additional data Dictionary. - public static void setAdditionalData(Dictionary customData) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setAdditionalData(customData); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setAdditionalData(customData); -#else - -#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 static void setResolveDeepLinkURLs(params string[] urls) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setResolveDeepLinkURLs(urls); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setResolveDeepLinkURLs(urls); -#else - -#endif - } - - - /// - /// Advertisers can use this method to set vanity onelink domains. - /// - /// Array of domains. - public static void setOneLinkCustomDomain(params string[] domains) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setOneLinkCustomDomains(domains); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setOneLinkCustomDomain(domains); -#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 UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setCurrencyCode(currencyCode); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setCurrencyCode(currencyCode); -#else - -#endif - } - - /// - /// Manually record the location of the user. - /// - /// latitude as double. - /// longitude as double. - public static void recordLocation(double latitude, double longitude) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.recordLocation(latitude, longitude); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.recordLocation(latitude, longitude); -#else - -#endif - } - - /// - /// 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 UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.anonymizeUser(shouldAnonymizeUser); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.anonymizeUser(shouldAnonymizeUser); -#else - -#endif - } - - /// - /// 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_IOS && !UNITY_EDITOR - return AppsFlyeriOS.getAppsFlyerId(); -#elif UNITY_ANDROID && !UNITY_EDITOR - return AppsFlyerAndroid.getAppsFlyerId(); -#else - return ""; -#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 static void setMinTimeBetweenSessions(int seconds) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setMinTimeBetweenSessions(seconds); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setMinTimeBetweenSessions(seconds); -#else - -#endif - } - - /// - /// Set a custom host. - /// - /// Host prefix. - /// Host name. - public static void setHost(string hostPrefixName, string hostName) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setHost(hostName, hostPrefixName); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.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 cryptMethod, params string[] emails) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setUserEmails(cryptMethod, emails.Length, emails); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setUserEmails(cryptMethod, emails); -#else - -#endif - } - - /// - /// Set the user phone number. - /// - /// phoneNumber string - public static void setPhoneNumber(string phoneNumber) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setPhoneNumber(phoneNumber); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setPhoneNumber(phoneNumber); -#else - -#endif - } - - /// - /// Used by advertisers to exclude all networks/integrated partners from getting data. - /// - public static void setSharingFilterForAllPartners() - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setSharingFilterForAllPartners(); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setSharingFilterForAllPartners(); -#else - -#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 static void setSharingFilter(params string[] partners) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.setSharingFilter(partners); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.setSharingFilter(partners); -#else - -#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. - /// - /// - /// - /// AppsFlyer.getConversionData(this.name); - /// - /// - public static void getConversionData(string objectName) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.getConversionData(objectName); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.getConversionData(objectName); -#else - -#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 - /// - /// - /// 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 UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.attributeAndOpenStore(appID, campaign, userParams, gameObject); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.attributeAndOpenStore(appID, campaign, userParams); -#else - -#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 static void recordCrossPromoteImpression(string appID, string campaign, Dictionary parameters) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.recordCrossPromoteImpression(appID, campaign, parameters); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.recordCrossPromoteImpression(appID, campaign, parameters); -#else - -#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 static void generateUserInviteLink(Dictionary parameters, MonoBehaviour gameObject) - { -#if UNITY_IOS && !UNITY_EDITOR - AppsFlyeriOS.generateUserInviteLink(parameters, gameObject); -#elif UNITY_ANDROID && !UNITY_EDITOR - AppsFlyerAndroid.generateUserInviteLink(parameters, gameObject); -#else - -#endif - } - - /// - /// 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/Runtime/AppsFlyer.cs.meta b/Runtime/AppsFlyer.cs.meta deleted file mode 100644 index a7e4587..0000000 --- a/Runtime/AppsFlyer.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3ee67b96679174324b71b44080a6741c -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/AppsFlyerAndroid.cs b/Runtime/AppsFlyerAndroid.cs deleted file mode 100644 index 2ce7d61..0000000 --- a/Runtime/AppsFlyerAndroid.cs +++ /dev/null @@ -1,657 +0,0 @@ -using System; -using System.Collections.Generic; -using UnityEngine; - -namespace AppsFlyerSDK -{ - -#if UNITY_ANDROID - public class AppsFlyerAndroid - { - - private static AndroidJavaClass appsFlyerAndroid = new AndroidJavaClass("com.appsflyer.unity.AppsFlyerAndroidWrapper"); - - - /// - /// 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 static 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 static void startSDK() - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("startTracking"); -#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 static void stopSDK(bool isSDKStopped) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("stopTracking", isSDKStopped); -#endif - } - - /// - /// Get the AppsFlyer SDK version used in app. - /// - /// AppsFlyer SDK version. - public static 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 static 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 static 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 static 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 static 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 static 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 static 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 static void setCustomerIdAndStartSDK(string id) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("setCustomerIdAndTrack", id); -#endif - } - - /// - /// Get the current AF_STORE value. - /// - /// AF_Store value. - public static string getOutOfStore() - { -#if !UNITY_EDITOR - return appsFlyerAndroid.CallStatic("getOutOfStore"); -#else - return ""; -#endif - } - - /// - /// Manually set the AF_STORE value. - /// - /// value to be set. - public static 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 static void setAppInviteOneLinkID(string oneLinkId) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("setAppInviteOneLinkID", oneLinkId); -#endif - } - - /// - /// Set additional data to be sent to AppsFlyer. - /// - /// additional data Dictionary. - public static void setAdditionalData(Dictionary customData) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("setAdditionalData", convertDictionaryToJavaMap(customData)); -#endif - } - - /// - /// Set the user emails. - /// - /// User emails. - public static void setUserEmails(params string[] emails) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("setUserEmails", (object)emails); -#endif - } - - - /// - /// Set the user phone number. - /// - /// User phoneNumber. - public static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static void sendEvent(string eventName, Dictionary eventValues) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("trackEvent", eventName, convertDictionaryToJavaMap(eventValues)); -#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 static void anonymizeUser(bool isDisabled) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("setDeviceTrackingDisabled", isDisabled); -#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 static void enableFacebookDeferredApplinks(bool isEnabled) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("enableFacebookDeferredApplinks", isEnabled); -#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 static 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 static 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 static 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 static 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 static 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 static 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 - } - - /// - /// Was the stopSDK(boolean) API set to true. - /// - /// boolean isSDKStopped. - public static 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 static void setMinTimeBetweenSessions(int seconds) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("setMinTimeBetweenSessions", seconds); -#endif - } - - /// - /// Set a custom host. - /// - /// Host prefix. - /// Host name. - public static 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 static string getHostName() - { -#if !UNITY_EDITOR - return appsFlyerAndroid.CallStatic("getHostName"); -#else - return ""; -#endif - } - - /// - /// Get the custom host prefix. - /// - /// Host prefix. - public static 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 static 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 static void setSharingFilter(params string[] partners) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("setSharingFilter", (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 static void getConversionData(string objectName) - { -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("getConversionData", objectName); -#endif - } - - /// - /// Register a validation listener for the validateAndSendInAppPurchase API. - /// - public static 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 static 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 static void attributeAndOpenStore(string promoted_app_id, string campaign, Dictionary userParams) - { -#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 static 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 static 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 static void handlePushNotifications(){ -#if !UNITY_EDITOR - appsFlyerAndroid.CallStatic("handlePushNotifications"); -#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 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;"); - if (dictionary != null) - { - foreach (var entry in dictionary) - { - AndroidJNI.CallObjectMethod(map.GetRawObject(), putMethod, AndroidJNIHelper.CreateJNIArgArray(new object[] { entry.Key, entry.Value })); - } - } - - return map; - } - } - -#endif - - - -} \ No newline at end of file diff --git a/Runtime/AppsFlyerAndroid.cs.meta b/Runtime/AppsFlyerAndroid.cs.meta deleted file mode 100644 index ca999f3..0000000 --- a/Runtime/AppsFlyerAndroid.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 1acf06d8f799e4050b792abc42365ab8 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/AppsFlyerObject.prefab b/Runtime/AppsFlyerObject.prefab deleted file mode 100644 index 6c9e085..0000000 --- a/Runtime/AppsFlyerObject.prefab +++ /dev/null @@ -1,57 +0,0 @@ -%YAML 1.1 -%TAG !u! tag:unity3d.com,2011: ---- !u!1001 &100100000 -Prefab: - m_ObjectHideFlags: 1 - serializedVersion: 2 - m_Modification: - m_TransformParent: {fileID: 0} - m_Modifications: [] - m_RemovedComponents: [] - m_SourcePrefab: {fileID: 0} - m_RootGameObject: {fileID: 1562408896289314} - m_IsPrefabAsset: 1 ---- !u!1 &1562408896289314 -GameObject: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - serializedVersion: 6 - m_Component: - - component: {fileID: 4294345628247858} - - component: {fileID: 114092076686766906} - m_Layer: 0 - m_Name: AppsFlyerObject - m_TagString: Untagged - m_Icon: {fileID: 0} - m_NavMeshLayer: 0 - m_StaticEditorFlags: 0 - m_IsActive: 1 ---- !u!4 &4294345628247858 -Transform: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1562408896289314} - 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 &114092076686766906 -MonoBehaviour: - m_ObjectHideFlags: 1 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInternal: {fileID: 100100000} - m_GameObject: {fileID: 1562408896289314} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 2caf6a738ac024a48bd358f4cc91662a, type: 3} - m_Name: - m_EditorClassIdentifier: - devKey: - appID: - isDebug: 0 - getConversionData: 0 diff --git a/Runtime/AppsFlyerObject.prefab.meta b/Runtime/AppsFlyerObject.prefab.meta deleted file mode 100644 index ddaed06..0000000 --- a/Runtime/AppsFlyerObject.prefab.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: 4a0acc9a317ee4b6191c57e81b0ddfb7 -PrefabImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/AppsFlyerObjectScript.cs b/Runtime/AppsFlyerObjectScript.cs deleted file mode 100644 index 49b7b48..0000000 --- a/Runtime/AppsFlyerObjectScript.cs +++ /dev/null @@ -1,59 +0,0 @@ -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 bool isDebug; - public bool getConversionData; - //******************************// - - void Start() - { - // These fields are set from the editor so do not modify! - //******************************// - AppsFlyer.setIsDebug(isDebug); - AppsFlyer.initSDK(devKey, appID, getConversionData ? this : null); - //******************************// - - 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/Runtime/AppsFlyerObjectScript.cs.meta b/Runtime/AppsFlyerObjectScript.cs.meta deleted file mode 100644 index 25ee3d5..0000000 --- a/Runtime/AppsFlyerObjectScript.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 2caf6a738ac024a48bd358f4cc91662a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/AppsFlyeriOS.cs b/Runtime/AppsFlyeriOS.cs deleted file mode 100644 index 7992153..0000000 --- a/Runtime/AppsFlyeriOS.cs +++ /dev/null @@ -1,586 +0,0 @@ -using System.Collections.Generic; -using System.Runtime.InteropServices; -using UnityEngine; - -namespace AppsFlyerSDK -{ -#if UNITY_IOS - - public class AppsFlyeriOS - { - - /// - /// Start Session. - /// This will record a session and then record all background forground sessions during the lifecycle of the app. - /// - public static void startSDK() - { -#if !UNITY_EDITOR - _startSDK(); -#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 static void sendEvent(string eventName, Dictionary eventValues) - { -#if !UNITY_EDITOR - _afSendEvent(eventName, AFMiniJSON.Json.Serialize(eventValues)); -#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 static 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 static 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 static 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 static 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 static 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 static 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 static 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 static 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. - public static 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 static void setAppInviteOneLinkID(string appInviteOneLinkID) - { -#if !UNITY_EDITOR - _setAppInviteOneLinkID(appInviteOneLinkID); -#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 static void anonymizeUser(bool shouldAnonymizeUser) - { -#if !UNITY_EDITOR - _anonymizeUser(shouldAnonymizeUser); -#endif - } - - /// - /// Opt-out for Apple Search Ads attributions. - /// - /// boolean disableCollectIAd. - public static 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 static 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 static 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 static void setResolveDeepLinkURLs(params string[] resolveDeepLinkURLs) - { -#if !UNITY_EDITOR - _setResolveDeepLinkURLs(resolveDeepLinkURLs.Length,resolveDeepLinkURLs); -#endif - } - - /// - /// For advertisers who use vanity OneLinks. - /// - /// Array of domains. - public static void setOneLinkCustomDomains(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 static void setUserEmails(EmailCryptType cryptType, int length, params string[] userEmails) - { -#if !UNITY_EDITOR - _setUserEmails(cryptType, length, userEmails); -#endif - } - - /// - /// Set the user phone number. - /// - /// User phoneNumber. - public static 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. - /// - /// 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 static void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string tranactionId, Dictionary additionalParameters, MonoBehaviour gameObject) - { -#if !UNITY_EDITOR - _validateAndSendInAppPurchase(productIdentifier, price, currency, tranactionId, AFMiniJSON.Json.Serialize(additionalParameters), gameObject ? gameObject.name : null); -#endif - } - - /// - /// To record location for geo-fencing. Does the same as code below. - /// - /// The location longitude. - /// The location latitude. - public static 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 static 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 static 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 static void handlePushNotification(Dictionary pushPayload) - { -#if !UNITY_EDITOR - _handlePushNotification(AFMiniJSON.Json.Serialize(pushPayload)); -#endif - } - - /// - /// Get SDK version. - /// - public static 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 static void setHost(string host, string hostPrefix) - { -#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 static 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 static void stopSDK(bool isSDKStopped) - { -#if !UNITY_EDITOR - _stopSDK(isSDKStopped); -#endif - } - - // - /// Was the stopSDK(boolean) API set to true. - /// - /// boolean isSDKStopped. - public static 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 static 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 static 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 static void setSharingFilter(params string[] partners) - { -#if !UNITY_EDITOR - _setSharingFilter(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 static 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 static 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 static 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 static void recordInvite(string channel, Dictionary parameters) - { -#if !UNITY_EDITOR - _recordInvite(channel, AFMiniJSON.Json.Serialize(parameters)); -#endif - } - - - /* - * AppsFlyer ios method mapping - */ - - [DllImport("__Internal")] - private static extern void _startSDK(); - - [DllImport("__Internal")] - private static extern void _getConversionData(string objectName); - - [DllImport("__Internal")] - private static extern void _setCustomerUserID(string customerUserID); - - [DllImport("__Internal")] - private static extern void _setAdditionalData(string customData); - - [DllImport("__Internal")] - private static extern void _setAppsFlyerDevKey(string appsFlyerDevKey); - - [DllImport("__Internal")] - private static extern void _setAppleAppID(string appleAppID); - - [DllImport("__Internal")] - private static extern void _setCurrencyCode(string currencyCode); - - [DllImport("__Internal")] - private static extern void _setDisableCollectAppleAdSupport(bool disableCollectAppleAdSupport); - - [DllImport("__Internal")] - private static extern void _setIsDebug(bool isDebug); - - [DllImport("__Internal")] - private static extern void _setShouldCollectDeviceName(bool shouldCollectDeviceName); - - [DllImport("__Internal")] - private static extern void _setAppInviteOneLinkID(string appInviteOneLinkID); - - [DllImport("__Internal")] - private static extern void _anonymizeUser(bool shouldAnonymizeUser); - - [DllImport("__Internal")] - private static extern void _setDisableCollectIAd(bool disableCollectIAd); - - [DllImport("__Internal")] - private static extern void _setUseReceiptValidationSandbox(bool useReceiptValidationSandbox); - - [DllImport("__Internal")] - private static extern void _setUseUninstallSandbox(bool useUninstallSandbox); - - [DllImport("__Internal")] - private static extern void _setResolveDeepLinkURLs(int length, params string[] resolveDeepLinkURLs); - - [DllImport("__Internal")] - private static extern void _setOneLinkCustomDomains(int length, params string[] oneLinkCustomDomains); - - [DllImport("__Internal")] - private static extern void _setUserEmails(EmailCryptType cryptType, int length, params string[] userEmails); - - [DllImport("__Internal")] - private static extern void _setPhoneNumber(string phoneNumber); - - [DllImport("__Internal")] - private static extern void _afSendEvent(string eventName, string eventValues); - - [DllImport("__Internal")] - private static extern void _validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string tranactionId, string additionalParameters, string objectName); - - [DllImport("__Internal")] - private static extern void _recordLocation(double longitude, double latitude); - - [DllImport("__Internal")] - private static extern string _getAppsFlyerId(); - - [DllImport("__Internal")] - private static extern void _registerUninstall(byte[] deviceToken); - - [DllImport("__Internal")] - private static extern void _handlePushNotification(string pushPayload); - - [DllImport("__Internal")] - private static extern string _getSDKVersion(); - - [DllImport("__Internal")] - private static extern void _setHost(string host, string hostPrefix); - - [DllImport("__Internal")] - private static extern void _setMinTimeBetweenSessions(int minTimeBetweenSessions); - - [DllImport("__Internal")] - private static extern void _stopSDK(bool isStopSDK); - - [DllImport("__Internal")] - private static extern bool _isSDKStopped(); - - [DllImport("__Internal")] - private static extern void _handleOpenUrl(string url, string sourceApplication, string annotation); - - [DllImport("__Internal")] - private static extern void _setSharingFilterForAllPartners(); - - [DllImport("__Internal")] - private static extern void _setSharingFilter(int length, params string[] partners); - - [DllImport("__Internal")] - private static extern void _recordCrossPromoteImpression(string appID, string campaign, string parameters); - - [DllImport("__Internal")] - private static extern void _attributeAndOpenStore(string appID, string campaign, string parameters, string gameObject); - - [DllImport("__Internal")] - private static extern void _generateUserInviteLink(string parameters, string gameObject); - - [DllImport("__Internal")] - private static extern void _recordInvite(string channel, string parameters); - - } - -#endif - - -} \ No newline at end of file diff --git a/Runtime/AppsFlyeriOS.cs.meta b/Runtime/AppsFlyeriOS.cs.meta deleted file mode 100644 index c876520..0000000 --- a/Runtime/AppsFlyeriOS.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 120dceef0eff140d7b70376e9f0a1202 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/IAppsFlyerConversionData.cs b/Runtime/IAppsFlyerConversionData.cs deleted file mode 100644 index 454eaa6..0000000 --- a/Runtime/IAppsFlyerConversionData.cs +++ /dev/null @@ -1,31 +0,0 @@ -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/Runtime/IAppsFlyerConversionData.cs.meta b/Runtime/IAppsFlyerConversionData.cs.meta deleted file mode 100644 index 3e25bce..0000000 --- a/Runtime/IAppsFlyerConversionData.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: c2148c64eaa7b4a44a76b14de953ffcf -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/IAppsFlyerUserInvite.cs b/Runtime/IAppsFlyerUserInvite.cs deleted file mode 100644 index aac109e..0000000 --- a/Runtime/IAppsFlyerUserInvite.cs +++ /dev/null @@ -1,26 +0,0 @@ -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/Runtime/IAppsFlyerUserInvite.cs.meta b/Runtime/IAppsFlyerUserInvite.cs.meta deleted file mode 100644 index e6b08dc..0000000 --- a/Runtime/IAppsFlyerUserInvite.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 3add604d2b2ac47269f4e3c24a5ef62a -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/IAppsFlyerValidateReceipt.cs b/Runtime/IAppsFlyerValidateReceipt.cs deleted file mode 100644 index 90490e2..0000000 --- a/Runtime/IAppsFlyerValidateReceipt.cs +++ /dev/null @@ -1,19 +0,0 @@ -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/Runtime/IAppsFlyerValidateReceipt.cs.meta b/Runtime/IAppsFlyerValidateReceipt.cs.meta deleted file mode 100644 index e44c3bb..0000000 --- a/Runtime/IAppsFlyerValidateReceipt.cs.meta +++ /dev/null @@ -1,11 +0,0 @@ -fileFormatVersion: 2 -guid: 7ccadc8fd86194a66b791b2509477fb4 -MonoImporter: - externalObjects: {} - serializedVersion: 2 - defaultReferences: [] - executionOrder: 0 - icon: {instanceID: 0} - userData: - assetBundleName: - assetBundleVariant: diff --git a/Runtime/Unity.AppsFlyer.asmdef b/Runtime/Unity.AppsFlyer.asmdef deleted file mode 100644 index a02176e..0000000 --- a/Runtime/Unity.AppsFlyer.asmdef +++ /dev/null @@ -1,3 +0,0 @@ -{ - "name": "AppsFlyer" -} diff --git a/Runtime/Unity.AppsFlyer.asmdef.meta b/Runtime/Unity.AppsFlyer.asmdef.meta deleted file mode 100644 index de17426..0000000 --- a/Runtime/Unity.AppsFlyer.asmdef.meta +++ /dev/null @@ -1,7 +0,0 @@ -fileFormatVersion: 2 -guid: c3b2ad556d41d1441bfade97a3c348cd -AssemblyDefinitionImporter: - externalObjects: {} - userData: - assetBundleName: - assetBundleVariant: diff --git a/package.json b/package.json index 318d4ec..5a880e2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "com.powerplaystudio.appsflyer", - "version": "0.0.2", + "name": "studio.powerplay.appsflyer", + "version": "0.0.3", "displayName": "AppsFlyer", "description": "Package wrapper for AppsFlyer Unity SDK", "unity": "2019.3",