commit 7d3907665fc0664a32d43ff38831d2cea6f08117 Author: HuYufei Date: Tue Dec 26 11:52:53 2023 +0800 init commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e6c2593 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +# Mac auto-generated system files +*.DS_Store* diff --git a/Adjust.meta b/Adjust.meta new file mode 100644 index 0000000..8d98d65 --- /dev/null +++ b/Adjust.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: f6eb314a40e64090be99b81e9bbdd00d +timeCreated: 1701911403 \ No newline at end of file diff --git a/Adjust/3rd Party.meta b/Adjust/3rd Party.meta new file mode 100644 index 0000000..832fff0 --- /dev/null +++ b/Adjust/3rd Party.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 48d72eaa514ffd0449362a759c8e9a86 +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/3rd Party/SimpleJSON.cs b/Adjust/3rd Party/SimpleJSON.cs new file mode 100644 index 0000000..0d85e5d --- /dev/null +++ b/Adjust/3rd Party/SimpleJSON.cs @@ -0,0 +1,1038 @@ +//#define USE_SharpZipLib +#if !UNITY_WEBPLAYER +#define USE_FileIO +#endif + +/* * * * * + * A simple JSON Parser / builder + * ------------------------------ + * + * It mainly has been written as a simple JSON parser. It can build a JSON string + * from the node-tree, or generate a node tree from any valid JSON string. + * + * If you want to use compression when saving to file / stream / B64 you have to include + * SharpZipLib ( http://www.icsharpcode.net/opensource/sharpziplib/ ) in your project and + * define "USE_SharpZipLib" at the top of the file + * + * Written by Bunny83 + * 2012-06-09 + * + * Features / attributes: + * - provides strongly typed node classes and lists / dictionaries + * - provides easy access to class members / array items / data values + * - the parser ignores data types. Each value is a string. + * - only double quotes (") are used for quoting strings. + * - values and names are not restricted to quoted strings. They simply add up and are trimmed. + * - There are only 3 types: arrays(JSONArray), objects(JSONClass) and values(JSONData) + * - provides "casting" properties to easily convert to / from those types: + * int / float / double / bool + * - provides a common interface for each node so no explicit casting is required. + * - the parser try to avoid errors, but if malformed JSON is parsed the result is undefined + * + * + * 2012-12-17 Update: + * - Added internal JSONLazyCreator class which simplifies the construction of a JSON tree + * Now you can simple reference any item that doesn't exist yet and it will return a JSONLazyCreator + * The class determines the required type by it's further use, creates the type and removes itself. + * - Added binary serialization / deserialization. + * - Added support for BZip2 zipped binary format. Requires the SharpZipLib ( http://www.icsharpcode.net/opensource/sharpziplib/ ) + * The usage of the SharpZipLib library can be disabled by removing or commenting out the USE_SharpZipLib define at the top + * - The serializer uses different types when it comes to store the values. Since my data values + * are all of type string, the serializer will "try" which format fits best. The order is: int, float, double, bool, string. + * It's not the most efficient way but for a moderate amount of data it should work on all platforms. + * + * * * * */ +using System; +using System.Collections; +using System.Collections.Generic; +using System.Linq; + + +namespace com.adjust.sdk +{ + public enum JSONBinaryTag + { + Array = 1, + Class = 2, + Value = 3, + IntValue = 4, + DoubleValue = 5, + BoolValue = 6, + FloatValue = 7, + } + + public class JSONNode + { + #region common interface + public virtual void Add(string aKey, JSONNode aItem){ } + public virtual JSONNode this[int aIndex] { get { return null; } set { } } + public virtual JSONNode this[string aKey] { get { return null; } set { } } + public virtual string Value { get { return ""; } set { } } + public virtual int Count { get { return 0; } } + + public virtual void Add(JSONNode aItem) + { + Add("", aItem); + } + + public virtual JSONNode Remove(string aKey) { return null; } + public virtual JSONNode Remove(int aIndex) { return null; } + public virtual JSONNode Remove(JSONNode aNode) { return aNode; } + + public virtual IEnumerable Childs { get { yield break;} } + public IEnumerable DeepChilds + { + get + { + foreach (var C in Childs) + foreach (var D in C.DeepChilds) + yield return D; + } + } + + public override string ToString() + { + return "JSONNode"; + } + public virtual string ToString(string aPrefix) + { + return "JSONNode"; + } + + #endregion common interface + + #region typecasting properties + public virtual int AsInt + { + get + { + int v = 0; + if (int.TryParse(Value,out v)) + return v; + return 0; + } + set + { + Value = value.ToString(); + } + } + public virtual float AsFloat + { + get + { + float v = 0.0f; + if (float.TryParse(Value,out v)) + return v; + return 0.0f; + } + set + { + Value = value.ToString(); + } + } + public virtual double AsDouble + { + get + { + double v = 0.0; + if (double.TryParse(Value,out v)) + return v; + return 0.0; + } + set + { + Value = value.ToString(); + } + } + public virtual bool AsBool + { + get + { + bool v = false; + if (bool.TryParse(Value,out v)) + return v; + return !string.IsNullOrEmpty(Value); + } + set + { + Value = (value)?"true":"false"; + } + } + public virtual JSONArray AsArray + { + get + { + return this as JSONArray; + } + } + public virtual JSONClass AsObject + { + get + { + return this as JSONClass; + } + } + + + #endregion typecasting properties + + #region operators + public static implicit operator JSONNode(string s) + { + return new JSONData(s); + } + public static implicit operator string(JSONNode d) + { + return (d == null)?null:d.Value; + } + public static bool operator ==(JSONNode a, object b) + { + if (b == null && a is JSONLazyCreator) + return true; + return System.Object.ReferenceEquals(a,b); + } + + public static bool operator !=(JSONNode a, object b) + { + return !(a == b); + } + public override bool Equals (object obj) + { + return System.Object.ReferenceEquals(this, obj); + } + public override int GetHashCode () + { + return base.GetHashCode(); + } + + + #endregion operators + + internal static string Escape(string aText) + { + string result = ""; + foreach(char c in aText) + { + switch(c) + { + case '\\' : result += "\\\\"; break; + case '\"' : result += "\\\""; break; + case '\n' : result += "\\n" ; break; + case '\r' : result += "\\r" ; break; + case '\t' : result += "\\t" ; break; + case '\b' : result += "\\b" ; break; + case '\f' : result += "\\f" ; break; + default : result += c ; break; + } + } + return result; + } + + public static JSONNode Parse(string aJSON) + { + Stack stack = new Stack(); + JSONNode ctx = null; + int i = 0; + string Token = ""; + string TokenName = ""; + bool QuoteMode = false; + while (i < aJSON.Length) + { + switch (aJSON[i]) + { + case '{': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + stack.Push(new JSONClass()); + if (ctx != null) + { + TokenName = TokenName.Trim(); + if (ctx is JSONArray) + ctx.Add(stack.Peek()); + else if (TokenName != "") + ctx.Add(TokenName,stack.Peek()); + } + TokenName = ""; + Token = ""; + ctx = stack.Peek(); + break; + + case '[': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + + stack.Push(new JSONArray()); + if (ctx != null) + { + TokenName = TokenName.Trim(); + if (ctx is JSONArray) + ctx.Add(stack.Peek()); + else if (TokenName != "") + ctx.Add(TokenName,stack.Peek()); + } + TokenName = ""; + Token = ""; + ctx = stack.Peek(); + break; + + case '}': + case ']': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + if (stack.Count == 0) + throw new Exception("JSON Parse: Too many closing brackets"); + + stack.Pop(); + if (Token != "") + { + TokenName = TokenName.Trim(); + if (ctx is JSONArray) + ctx.Add(Token); + else if (TokenName != "") + ctx.Add(TokenName,Token); + } + TokenName = ""; + Token = ""; + if (stack.Count>0) + ctx = stack.Peek(); + break; + + case ':': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + TokenName = Token; + Token = ""; + break; + + case '"': + QuoteMode ^= true; + break; + + case ',': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + if (Token != "") + { + if (ctx is JSONArray) + ctx.Add(Token); + else if (TokenName != "") + ctx.Add(TokenName, Token); + } + TokenName = ""; + Token = ""; + break; + + case '\r': + case '\n': + break; + + case ' ': + case '\t': + if (QuoteMode) + Token += aJSON[i]; + break; + + case '\\': + ++i; + if (QuoteMode) + { + char C = aJSON[i]; + switch (C) + { + case 't' : Token += '\t'; break; + case 'r' : Token += '\r'; break; + case 'n' : Token += '\n'; break; + case 'b' : Token += '\b'; break; + case 'f' : Token += '\f'; break; + case 'u': + { + string s = aJSON.Substring(i+1,4); + Token += (char)int.Parse(s, System.Globalization.NumberStyles.AllowHexSpecifier); + i += 4; + break; + } + default : Token += C; break; + } + } + break; + + default: + Token += aJSON[i]; + break; + } + ++i; + } + if (QuoteMode) + { + throw new Exception("JSON Parse: Quotation marks seems to be messed up."); + } + return ctx; + } + + public virtual void Serialize(System.IO.BinaryWriter aWriter) {} + + public void SaveToStream(System.IO.Stream aData) + { + var W = new System.IO.BinaryWriter(aData); + Serialize(W); + } + + #if USE_SharpZipLib + public void SaveToCompressedStream(System.IO.Stream aData) + { + using (var gzipOut = new ICSharpCode.SharpZipLib.BZip2.BZip2OutputStream(aData)) + { + gzipOut.IsStreamOwner = false; + SaveToStream(gzipOut); + gzipOut.Close(); + } + } + + public void SaveToCompressedFile(string aFileName) + { + #if USE_FileIO + System.IO.Directory.CreateDirectory((new System.IO.FileInfo(aFileName)).Directory.FullName); + using(var F = System.IO.File.OpenWrite(aFileName)) + { + SaveToCompressedStream(F); + } + #else + throw new Exception("Can't use File IO stuff in webplayer"); + #endif + } + public string SaveToCompressedBase64() + { + using (var stream = new System.IO.MemoryStream()) + { + SaveToCompressedStream(stream); + stream.Position = 0; + return System.Convert.ToBase64String(stream.ToArray()); + } + } + + #else + public void SaveToCompressedStream(System.IO.Stream aData) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + public void SaveToCompressedFile(string aFileName) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + public string SaveToCompressedBase64() + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + #endif + + public static JSONNode Deserialize(System.IO.BinaryReader aReader) + { + JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte(); + switch(type) + { + case JSONBinaryTag.Array: + { + int count = aReader.ReadInt32(); + JSONArray tmp = new JSONArray(); + for(int i = 0; i < count; i++) + tmp.Add(Deserialize(aReader)); + return tmp; + } + case JSONBinaryTag.Class: + { + int count = aReader.ReadInt32(); + JSONClass tmp = new JSONClass(); + for(int i = 0; i < count; i++) + { + string key = aReader.ReadString(); + var val = Deserialize(aReader); + tmp.Add(key, val); + } + return tmp; + } + case JSONBinaryTag.Value: + { + return new JSONData(aReader.ReadString()); + } + case JSONBinaryTag.IntValue: + { + return new JSONData(aReader.ReadInt32()); + } + case JSONBinaryTag.DoubleValue: + { + return new JSONData(aReader.ReadDouble()); + } + case JSONBinaryTag.BoolValue: + { + return new JSONData(aReader.ReadBoolean()); + } + case JSONBinaryTag.FloatValue: + { + return new JSONData(aReader.ReadSingle()); + } + + default: + { + throw new Exception("Error deserializing JSON. Unknown tag: " + type); + } + } + } + + #if USE_SharpZipLib + public static JSONNode LoadFromCompressedStream(System.IO.Stream aData) + { + var zin = new ICSharpCode.SharpZipLib.BZip2.BZip2InputStream(aData); + return LoadFromStream(zin); + } + public static JSONNode LoadFromCompressedFile(string aFileName) + { + #if USE_FileIO + using(var F = System.IO.File.OpenRead(aFileName)) + { + return LoadFromCompressedStream(F); + } + #else + throw new Exception("Can't use File IO stuff in webplayer"); + #endif + } + public static JSONNode LoadFromCompressedBase64(string aBase64) + { + var tmp = System.Convert.FromBase64String(aBase64); + var stream = new System.IO.MemoryStream(tmp); + stream.Position = 0; + return LoadFromCompressedStream(stream); + } + #else + public static JSONNode LoadFromCompressedFile(string aFileName) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + public static JSONNode LoadFromCompressedStream(System.IO.Stream aData) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + public static JSONNode LoadFromCompressedBase64(string aBase64) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + #endif + + public static JSONNode LoadFromStream(System.IO.Stream aData) + { + using(var R = new System.IO.BinaryReader(aData)) + { + return Deserialize(R); + } + } + public static JSONNode LoadFromBase64(string aBase64) + { + var tmp = System.Convert.FromBase64String(aBase64); + var stream = new System.IO.MemoryStream(tmp); + stream.Position = 0; + return LoadFromStream(stream); + } + } // End of JSONNode + + public class JSONArray : JSONNode, IEnumerable + { + private List m_List = new List(); + public override JSONNode this[int aIndex] + { + get + { + if (aIndex<0 || aIndex >= m_List.Count) + return new JSONLazyCreator(this); + return m_List[aIndex]; + } + set + { + if (aIndex<0 || aIndex >= m_List.Count) + m_List.Add(value); + else + m_List[aIndex] = value; + } + } + public override JSONNode this[string aKey] + { + get{ return new JSONLazyCreator(this);} + set{ m_List.Add(value); } + } + public override int Count + { + get { return m_List.Count; } + } + public override void Add(string aKey, JSONNode aItem) + { + m_List.Add(aItem); + } + public override JSONNode Remove(int aIndex) + { + if (aIndex < 0 || aIndex >= m_List.Count) + return null; + JSONNode tmp = m_List[aIndex]; + m_List.RemoveAt(aIndex); + return tmp; + } + public override JSONNode Remove(JSONNode aNode) + { + m_List.Remove(aNode); + return aNode; + } + public override IEnumerable Childs + { + get + { + foreach(JSONNode N in m_List) + yield return N; + } + } + public IEnumerator GetEnumerator() + { + foreach(JSONNode N in m_List) + yield return N; + } + public override string ToString() + { + string result = "[ "; + foreach (JSONNode N in m_List) + { + if (result.Length > 2) + result += ", "; + result += N.ToString(); + } + result += " ]"; + return result; + } + public override string ToString(string aPrefix) + { + string result = "[ "; + foreach (JSONNode N in m_List) + { + if (result.Length > 3) + result += ", "; + result += "\n" + aPrefix + " "; + result += N.ToString(aPrefix+" "); + } + result += "\n" + aPrefix + "]"; + return result; + } + public override void Serialize (System.IO.BinaryWriter aWriter) + { + aWriter.Write((byte)JSONBinaryTag.Array); + aWriter.Write(m_List.Count); + for(int i = 0; i < m_List.Count; i++) + { + m_List[i].Serialize(aWriter); + } + } + } // End of JSONArray + + public class JSONClass : JSONNode, IEnumerable + { + private Dictionary m_Dict = new Dictionary(); + public override JSONNode this[string aKey] + { + get + { + if (m_Dict.ContainsKey(aKey)) + return m_Dict[aKey]; + else + return new JSONLazyCreator(this, aKey); + } + set + { + if (m_Dict.ContainsKey(aKey)) + m_Dict[aKey] = value; + else + m_Dict.Add(aKey,value); + } + } + public override JSONNode this[int aIndex] + { + get + { + if (aIndex < 0 || aIndex >= m_Dict.Count) + return null; + return m_Dict.ElementAt(aIndex).Value; + } + set + { + if (aIndex < 0 || aIndex >= m_Dict.Count) + return; + string key = m_Dict.ElementAt(aIndex).Key; + m_Dict[key] = value; + } + } + public override int Count + { + get { return m_Dict.Count; } + } + + + public override void Add(string aKey, JSONNode aItem) + { + if (!string.IsNullOrEmpty(aKey)) + { + if (m_Dict.ContainsKey(aKey)) + m_Dict[aKey] = aItem; + else + m_Dict.Add(aKey, aItem); + } + else + m_Dict.Add(Guid.NewGuid().ToString(), aItem); + } + + public override JSONNode Remove(string aKey) + { + if (!m_Dict.ContainsKey(aKey)) + return null; + JSONNode tmp = m_Dict[aKey]; + m_Dict.Remove(aKey); + return tmp; + } + public override JSONNode Remove(int aIndex) + { + if (aIndex < 0 || aIndex >= m_Dict.Count) + return null; + var item = m_Dict.ElementAt(aIndex); + m_Dict.Remove(item.Key); + return item.Value; + } + public override JSONNode Remove(JSONNode aNode) + { + try + { + var item = m_Dict.Where(k => k.Value == aNode).First(); + m_Dict.Remove(item.Key); + return aNode; + } + catch + { + return null; + } + } + + public override IEnumerable Childs + { + get + { + foreach(KeyValuePair N in m_Dict) + yield return N.Value; + } + } + + public IEnumerator GetEnumerator() + { + foreach(KeyValuePair N in m_Dict) + yield return N; + } + public override string ToString() + { + string result = "{"; + foreach (KeyValuePair N in m_Dict) + { + if (result.Length > 2) + result += ", "; + result += "\"" + Escape(N.Key) + "\":" + N.Value.ToString(); + } + result += "}"; + return result; + } + public override string ToString(string aPrefix) + { + string result = "{ "; + foreach (KeyValuePair N in m_Dict) + { + if (result.Length > 3) + result += ", "; + result += "\n" + aPrefix + " "; + result += "\"" + Escape(N.Key) + "\" : " + N.Value.ToString(aPrefix+" "); + } + result += "\n" + aPrefix + "}"; + return result; + } + public override void Serialize (System.IO.BinaryWriter aWriter) + { + aWriter.Write((byte)JSONBinaryTag.Class); + aWriter.Write(m_Dict.Count); + foreach(string K in m_Dict.Keys) + { + aWriter.Write(K); + m_Dict[K].Serialize(aWriter); + } + } + } // End of JSONClass + + public class JSONData : JSONNode + { + private string m_Data; + public override string Value + { + get { return m_Data; } + set { m_Data = value; } + } + public JSONData(string aData) + { + m_Data = aData; + } + public JSONData(float aData) + { + AsFloat = aData; + } + public JSONData(double aData) + { + AsDouble = aData; + } + public JSONData(bool aData) + { + AsBool = aData; + } + public JSONData(int aData) + { + AsInt = aData; + } + + public override string ToString() + { + return "\"" + Escape(m_Data) + "\""; + } + public override string ToString(string aPrefix) + { + return "\"" + Escape(m_Data) + "\""; + } + public override void Serialize (System.IO.BinaryWriter aWriter) + { + var tmp = new JSONData(""); + + tmp.AsInt = AsInt; + if (tmp.m_Data == this.m_Data) + { + aWriter.Write((byte)JSONBinaryTag.IntValue); + aWriter.Write(AsInt); + return; + } + tmp.AsFloat = AsFloat; + if (tmp.m_Data == this.m_Data) + { + aWriter.Write((byte)JSONBinaryTag.FloatValue); + aWriter.Write(AsFloat); + return; + } + tmp.AsDouble = AsDouble; + if (tmp.m_Data == this.m_Data) + { + aWriter.Write((byte)JSONBinaryTag.DoubleValue); + aWriter.Write(AsDouble); + return; + } + + tmp.AsBool = AsBool; + if (tmp.m_Data == this.m_Data) + { + aWriter.Write((byte)JSONBinaryTag.BoolValue); + aWriter.Write(AsBool); + return; + } + aWriter.Write((byte)JSONBinaryTag.Value); + aWriter.Write(m_Data); + } + } // End of JSONData + + internal class JSONLazyCreator : JSONNode + { + private JSONNode m_Node = null; + private string m_Key = null; + + public JSONLazyCreator(JSONNode aNode) + { + m_Node = aNode; + m_Key = null; + } + public JSONLazyCreator(JSONNode aNode, string aKey) + { + m_Node = aNode; + m_Key = aKey; + } + + private void Set(JSONNode aVal) + { + if (m_Key == null) + { + m_Node.Add(aVal); + } + else + { + m_Node.Add(m_Key, aVal); + } + m_Node = null; // Be GC friendly. + } + + public override JSONNode this[int aIndex] + { + get + { + return new JSONLazyCreator(this); + } + set + { + var tmp = new JSONArray(); + tmp.Add(value); + Set(tmp); + } + } + + public override JSONNode this[string aKey] + { + get + { + return new JSONLazyCreator(this, aKey); + } + set + { + var tmp = new JSONClass(); + tmp.Add(aKey, value); + Set(tmp); + } + } + public override void Add (JSONNode aItem) + { + var tmp = new JSONArray(); + tmp.Add(aItem); + Set(tmp); + } + public override void Add (string aKey, JSONNode aItem) + { + var tmp = new JSONClass(); + tmp.Add(aKey, aItem); + Set(tmp); + } + public static bool operator ==(JSONLazyCreator a, object b) + { + if (b == null) + return true; + return System.Object.ReferenceEquals(a,b); + } + + public static bool operator !=(JSONLazyCreator a, object b) + { + return !(a == b); + } + public override bool Equals (object obj) + { + if (obj == null) + return true; + return System.Object.ReferenceEquals(this, obj); + } + public override int GetHashCode () + { + return base.GetHashCode(); + } + + public override string ToString() + { + return ""; + } + public override string ToString(string aPrefix) + { + return ""; + } + + public override int AsInt + { + get + { + JSONData tmp = new JSONData(0); + Set(tmp); + return 0; + } + set + { + JSONData tmp = new JSONData(value); + Set(tmp); + } + } + public override float AsFloat + { + get + { + JSONData tmp = new JSONData(0.0f); + Set(tmp); + return 0.0f; + } + set + { + JSONData tmp = new JSONData(value); + Set(tmp); + } + } + public override double AsDouble + { + get + { + JSONData tmp = new JSONData(0.0); + Set(tmp); + return 0.0; + } + set + { + JSONData tmp = new JSONData(value); + Set(tmp); + } + } + public override bool AsBool + { + get + { + JSONData tmp = new JSONData(false); + Set(tmp); + return false; + } + set + { + JSONData tmp = new JSONData(value); + Set(tmp); + } + } + public override JSONArray AsArray + { + get + { + JSONArray tmp = new JSONArray(); + Set(tmp); + return tmp; + } + } + public override JSONClass AsObject + { + get + { + JSONClass tmp = new JSONClass(); + Set(tmp); + return tmp; + } + } + } // End of JSONLazyCreator + + public static class JSON + { + public static JSONNode Parse(string aJSON) + { + return JSONNode.Parse(aJSON); + } + } +} \ No newline at end of file diff --git a/Adjust/3rd Party/SimpleJSON.cs.meta b/Adjust/3rd Party/SimpleJSON.cs.meta new file mode 100644 index 0000000..a28238d --- /dev/null +++ b/Adjust/3rd Party/SimpleJSON.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 9c780c17852614618be5ffd9cc43a75f +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Adjust.asmdef b/Adjust/Adjust.asmdef new file mode 100644 index 0000000..6dea7a6 --- /dev/null +++ b/Adjust/Adjust.asmdef @@ -0,0 +1,3 @@ +{ + "name": "Adjust" +} diff --git a/Adjust/Adjust.asmdef.meta b/Adjust/Adjust.asmdef.meta new file mode 100644 index 0000000..6a438a3 --- /dev/null +++ b/Adjust/Adjust.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 052c31a56689f4aeea54d292c3e95e89 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Android.meta b/Adjust/Android.meta new file mode 100644 index 0000000..1700eda --- /dev/null +++ b/Adjust/Android.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 64b3fa260fe5b3c4e9215ec9b42c90da +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Android/AdjustAndroid.cs b/Adjust/Android/AdjustAndroid.cs new file mode 100644 index 0000000..fdaa33b --- /dev/null +++ b/Adjust/Android/AdjustAndroid.cs @@ -0,0 +1,1038 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; + +namespace com.adjust.sdk +{ +#if UNITY_ANDROID + public class AdjustAndroid + { + private const string sdkPrefix = "unity4.36.0"; + private static bool launchDeferredDeeplink = true; + private static AndroidJavaClass ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); + private static AndroidJavaObject ajoCurrentActivity = new AndroidJavaClass("com.unity3d.player.UnityPlayer").GetStatic("currentActivity"); + private static DeferredDeeplinkListener onDeferredDeeplinkListener; + private static AttributionChangeListener onAttributionChangedListener; + private static EventTrackingFailedListener onEventTrackingFailedListener; + private static EventTrackingSucceededListener onEventTrackingSucceededListener; + private static SessionTrackingFailedListener onSessionTrackingFailedListener; + private static SessionTrackingSucceededListener onSessionTrackingSucceededListener; + private static VerificationInfoListener onVerificationInfoListener; + + public static void Start(AdjustConfig adjustConfig) + { + // Thank you, Unity 2019.2.0, for breaking this. + // AndroidJavaObject ajoEnvironment = adjustConfig.environment == AdjustEnvironment.Sandbox ? + // new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("ENVIRONMENT_SANDBOX") : + // new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("ENVIRONMENT_PRODUCTION"); + + // Get environment variable. + string ajoEnvironment = adjustConfig.environment == AdjustEnvironment.Production ? "production" : "sandbox"; + + // Create adjust config object. + AndroidJavaObject ajoAdjustConfig; + + // Check if suppress log leve is supported. + if (adjustConfig.allowSuppressLogLevel != null) + { + ajoAdjustConfig = new AndroidJavaObject("com.adjust.sdk.AdjustConfig", ajoCurrentActivity, adjustConfig.appToken, ajoEnvironment, adjustConfig.allowSuppressLogLevel); + } + else + { + ajoAdjustConfig = new AndroidJavaObject("com.adjust.sdk.AdjustConfig", ajoCurrentActivity, adjustConfig.appToken, ajoEnvironment); + } + + // Check if deferred deeplink should be launched by SDK. + launchDeferredDeeplink = adjustConfig.launchDeferredDeeplink; + + // Check log level. + if (adjustConfig.logLevel != null) + { + AndroidJavaObject ajoLogLevel; + if (adjustConfig.logLevel.Value.ToUppercaseString().Equals("SUPPRESS")) + { + ajoLogLevel = new AndroidJavaClass("com.adjust.sdk.LogLevel").GetStatic("SUPRESS"); + } + else + { + ajoLogLevel = new AndroidJavaClass("com.adjust.sdk.LogLevel").GetStatic(adjustConfig.logLevel.Value.ToUppercaseString()); + } + + if (ajoLogLevel != null) + { + ajoAdjustConfig.Call("setLogLevel", ajoLogLevel); + } + } + + // Set unity SDK prefix. + ajoAdjustConfig.Call("setSdkPrefix", sdkPrefix); + + // Check if user has configured the delayed start option. + if (adjustConfig.delayStart != null) + { + ajoAdjustConfig.Call("setDelayStart", adjustConfig.delayStart); + } + + // Check event buffering setting. + if (adjustConfig.eventBufferingEnabled != null) + { + AndroidJavaObject ajoIsEnabled = new AndroidJavaObject("java.lang.Boolean", adjustConfig.eventBufferingEnabled.Value); + ajoAdjustConfig.Call("setEventBufferingEnabled", ajoIsEnabled); + } + + // Check COPPA setting. + if (adjustConfig.coppaCompliantEnabled != null) + { + ajoAdjustConfig.Call("setCoppaCompliantEnabled", adjustConfig.coppaCompliantEnabled.Value); + } + + // Check final Android attribution setting. + if (adjustConfig.finalAndroidAttributionEnabled != null) + { + ajoAdjustConfig.Call("setFinalAttributionEnabled", adjustConfig.finalAndroidAttributionEnabled.Value); + } + + // Check read Android IDs only once. + if (adjustConfig.readDeviceInfoOnceEnabled != null) + { + ajoAdjustConfig.Call("setReadDeviceInfoOnceEnabled", adjustConfig.readDeviceInfoOnceEnabled.Value); + } + + // Check Play Store Kids Apps setting. + if (adjustConfig.playStoreKidsAppEnabled != null) + { + ajoAdjustConfig.Call("setPlayStoreKidsAppEnabled", adjustConfig.playStoreKidsAppEnabled.Value); + } + + // Check if user enabled tracking in the background. + if (adjustConfig.sendInBackground != null) + { + ajoAdjustConfig.Call("setSendInBackground", adjustConfig.sendInBackground.Value); + } + + // Check if user wants to get cost data in attribution callback. + if (adjustConfig.needsCost != null) + { + ajoAdjustConfig.Call("setNeedsCost", adjustConfig.needsCost.Value); + } + + // Check if user wants to run preinstall campaigns. + if (adjustConfig.preinstallTrackingEnabled != null) + { + ajoAdjustConfig.Call("setPreinstallTrackingEnabled", adjustConfig.preinstallTrackingEnabled.Value); + } + + // Check if user has set custom preinstall file path. + if (adjustConfig.preinstallFilePath != null) + { + ajoAdjustConfig.Call("setPreinstallFilePath", adjustConfig.preinstallFilePath); + } + + // Check if FB app ID has been set. + if (adjustConfig.fbAppId != null) + { + ajoAdjustConfig.Call("setFbAppId", adjustConfig.fbAppId); + } + + // Check if user has set user agent value. + if (adjustConfig.userAgent != null) + { + ajoAdjustConfig.Call("setUserAgent", adjustConfig.userAgent); + } + + // Check if user has set default process name. + if (!String.IsNullOrEmpty(adjustConfig.processName)) + { + ajoAdjustConfig.Call("setProcessName", adjustConfig.processName); + } + + // Check if user has set default tracker token. + if (adjustConfig.defaultTracker != null) + { + ajoAdjustConfig.Call("setDefaultTracker", adjustConfig.defaultTracker); + } + + // Check if user has set external device identifier. + if (adjustConfig.externalDeviceId != null) + { + ajoAdjustConfig.Call("setExternalDeviceId", adjustConfig.externalDeviceId); + } + + // Check if user has set custom URL strategy. + if (adjustConfig.urlStrategy != null) + { + if (adjustConfig.urlStrategy == AdjustConfig.AdjustUrlStrategyChina) + { + AndroidJavaObject ajoUrlStrategyChina = new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("URL_STRATEGY_CHINA"); + ajoAdjustConfig.Call("setUrlStrategy", ajoUrlStrategyChina); + } + else if (adjustConfig.urlStrategy == AdjustConfig.AdjustUrlStrategyIndia) + { + AndroidJavaObject ajoUrlStrategyIndia = new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("URL_STRATEGY_INDIA"); + ajoAdjustConfig.Call("setUrlStrategy", ajoUrlStrategyIndia); + } + else if (adjustConfig.urlStrategy == AdjustConfig.AdjustUrlStrategyCn) + { + AndroidJavaObject ajoUrlStrategyCn = new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("URL_STRATEGY_CN"); + ajoAdjustConfig.Call("setUrlStrategy", ajoUrlStrategyCn); + } + else if (adjustConfig.urlStrategy == AdjustConfig.AdjustUrlStrategyCnOnly) + { + AndroidJavaObject ajoUrlStrategyCnOnly = new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("URL_STRATEGY_CN_ONLY"); + ajoAdjustConfig.Call("setUrlStrategy", ajoUrlStrategyCnOnly); + } + else if (adjustConfig.urlStrategy == AdjustConfig.AdjustDataResidencyEU) + { + AndroidJavaObject ajoDataResidencyEU = new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("DATA_RESIDENCY_EU"); + ajoAdjustConfig.Call("setUrlStrategy", ajoDataResidencyEU); + } + else if (adjustConfig.urlStrategy == AdjustConfig.AdjustDataResidencyTR) + { + AndroidJavaObject ajoDataResidencyTR = new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("DATA_RESIDENCY_TR"); + ajoAdjustConfig.Call("setUrlStrategy", ajoDataResidencyTR); + } + else if (adjustConfig.urlStrategy == AdjustConfig.AdjustDataResidencyUS) + { + AndroidJavaObject ajoDataResidencyUS = new AndroidJavaClass("com.adjust.sdk.AdjustConfig").GetStatic("DATA_RESIDENCY_US"); + ajoAdjustConfig.Call("setUrlStrategy", ajoDataResidencyUS); + } + } + + // Check if user has set app secret. + if (IsAppSecretSet(adjustConfig)) + { + ajoAdjustConfig.Call("setAppSecret", + adjustConfig.secretId.Value, + adjustConfig.info1.Value, + adjustConfig.info2.Value, + adjustConfig.info3.Value, + adjustConfig.info4.Value); + } + + // Check if user has set device as known. + if (adjustConfig.isDeviceKnown.HasValue) + { + ajoAdjustConfig.Call("setDeviceKnown", adjustConfig.isDeviceKnown.Value); + } + + // Check if user has enabled reading of IMEI and MEID. + // Obsolete method. + if (adjustConfig.readImei.HasValue) + { + // ajoAdjustConfig.Call("setReadMobileEquipmentIdentity", adjustConfig.readImei.Value); + } + + // Check attribution changed delagate setting. + if (adjustConfig.attributionChangedDelegate != null) + { + onAttributionChangedListener = new AttributionChangeListener(adjustConfig.attributionChangedDelegate); + ajoAdjustConfig.Call("setOnAttributionChangedListener", onAttributionChangedListener); + } + + // Check event success delegate setting. + if (adjustConfig.eventSuccessDelegate != null) + { + onEventTrackingSucceededListener = new EventTrackingSucceededListener(adjustConfig.eventSuccessDelegate); + ajoAdjustConfig.Call("setOnEventTrackingSucceededListener", onEventTrackingSucceededListener); + } + + // Check event failure delagate setting. + if (adjustConfig.eventFailureDelegate != null) + { + onEventTrackingFailedListener = new EventTrackingFailedListener(adjustConfig.eventFailureDelegate); + ajoAdjustConfig.Call("setOnEventTrackingFailedListener", onEventTrackingFailedListener); + } + + // Check session success delegate setting. + if (adjustConfig.sessionSuccessDelegate != null) + { + onSessionTrackingSucceededListener = new SessionTrackingSucceededListener(adjustConfig.sessionSuccessDelegate); + ajoAdjustConfig.Call("setOnSessionTrackingSucceededListener", onSessionTrackingSucceededListener); + } + + // Check session failure delegate setting. + if (adjustConfig.sessionFailureDelegate != null) + { + onSessionTrackingFailedListener = new SessionTrackingFailedListener(adjustConfig.sessionFailureDelegate); + ajoAdjustConfig.Call("setOnSessionTrackingFailedListener", onSessionTrackingFailedListener); + } + + // Check deferred deeplink delegate setting. + if (adjustConfig.deferredDeeplinkDelegate != null) + { + onDeferredDeeplinkListener = new DeferredDeeplinkListener(adjustConfig.deferredDeeplinkDelegate); + ajoAdjustConfig.Call("setOnDeeplinkResponseListener", onDeferredDeeplinkListener); + } + + // Initialise and start the SDK. + ajcAdjust.CallStatic("onCreate", ajoAdjustConfig); + ajcAdjust.CallStatic("onResume"); + } + + public static void TrackEvent(AdjustEvent adjustEvent) + { + AndroidJavaObject ajoAdjustEvent = new AndroidJavaObject("com.adjust.sdk.AdjustEvent", adjustEvent.eventToken); + + // Check if user has set revenue for the event. + if (adjustEvent.revenue != null) + { + ajoAdjustEvent.Call("setRevenue", (double)adjustEvent.revenue, adjustEvent.currency); + } + + // Check if user has added any callback parameters to the event. + if (adjustEvent.callbackList != null) + { + for (int i = 0; i < adjustEvent.callbackList.Count; i += 2) + { + string key = adjustEvent.callbackList[i]; + string value = adjustEvent.callbackList[i + 1]; + ajoAdjustEvent.Call("addCallbackParameter", key, value); + } + } + + // Check if user has added any partner parameters to the event. + if (adjustEvent.partnerList != null) + { + for (int i = 0; i < adjustEvent.partnerList.Count; i += 2) + { + string key = adjustEvent.partnerList[i]; + string value = adjustEvent.partnerList[i + 1]; + ajoAdjustEvent.Call("addPartnerParameter", key, value); + } + } + + // Check if user has added transaction ID to the event. + if (adjustEvent.transactionId != null) + { + ajoAdjustEvent.Call("setOrderId", adjustEvent.transactionId); + } + + // Check if user has added callback ID to the event. + if (adjustEvent.callbackId != null) + { + ajoAdjustEvent.Call("setCallbackId", adjustEvent.callbackId); + } + + // Check if user has added product ID to the event. + if (adjustEvent.productId != null) + { + ajoAdjustEvent.Call("setProductId", adjustEvent.productId); + } + + // Check if user has added purchase token to the event. + if (adjustEvent.purchaseToken != null) + { + ajoAdjustEvent.Call("setPurchaseToken", adjustEvent.purchaseToken); + } + + // Track the event. + ajcAdjust.CallStatic("trackEvent", ajoAdjustEvent); + } + + public static bool IsEnabled() + { + return ajcAdjust.CallStatic("isEnabled"); + } + + public static void SetEnabled(bool enabled) + { + ajcAdjust.CallStatic("setEnabled", enabled); + } + + public static void SetOfflineMode(bool enabled) + { + ajcAdjust.CallStatic("setOfflineMode", enabled); + } + + public static void SendFirstPackages() + { + ajcAdjust.CallStatic("sendFirstPackages"); + } + + public static void SetDeviceToken(string deviceToken) + { + ajcAdjust.CallStatic("setPushToken", deviceToken, ajoCurrentActivity); + } + + public static string GetAdid() + { + return ajcAdjust.CallStatic("getAdid"); + } + + public static void GdprForgetMe() + { + ajcAdjust.CallStatic("gdprForgetMe", ajoCurrentActivity); + } + + public static void DisableThirdPartySharing() + { + ajcAdjust.CallStatic("disableThirdPartySharing", ajoCurrentActivity); + } + + public static AdjustAttribution GetAttribution() + { + try + { + AndroidJavaObject ajoAttribution = ajcAdjust.CallStatic("getAttribution"); + if (null == ajoAttribution) + { + return null; + } + + AdjustAttribution adjustAttribution = new AdjustAttribution(); + adjustAttribution.trackerName = ajoAttribution.Get(AdjustUtils.KeyTrackerName) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyTrackerName); + adjustAttribution.trackerToken = ajoAttribution.Get(AdjustUtils.KeyTrackerToken) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyTrackerToken); + adjustAttribution.network = ajoAttribution.Get(AdjustUtils.KeyNetwork) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyNetwork); + adjustAttribution.campaign = ajoAttribution.Get(AdjustUtils.KeyCampaign) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyCampaign); + adjustAttribution.adgroup = ajoAttribution.Get(AdjustUtils.KeyAdgroup) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyAdgroup); + adjustAttribution.creative = ajoAttribution.Get(AdjustUtils.KeyCreative) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyCreative); + adjustAttribution.clickLabel = ajoAttribution.Get(AdjustUtils.KeyClickLabel) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyClickLabel); + adjustAttribution.adid = ajoAttribution.Get(AdjustUtils.KeyAdid) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyAdid); + adjustAttribution.costType = ajoAttribution.Get(AdjustUtils.KeyCostType) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyCostType); + AndroidJavaObject ajoCostAmount = ajoAttribution.Get(AdjustUtils.KeyCostAmount) == null ? + null : ajoAttribution.Get(AdjustUtils.KeyCostAmount); + if (ajoCostAmount == null) + { + adjustAttribution.costAmount = null; + } + else + { + double costAmount = ajoCostAmount.Call("doubleValue"); + adjustAttribution.costAmount = costAmount; + } + adjustAttribution.costCurrency = ajoAttribution.Get(AdjustUtils.KeyCostCurrency) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyCostCurrency); + adjustAttribution.fbInstallReferrer = ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer) == "" ? + null : ajoAttribution.Get(AdjustUtils.KeyFbInstallReferrer); + return adjustAttribution; + } + catch (Exception) {} + + return null; + } + + public static void AddSessionPartnerParameter(string key, string value) + { + if (ajcAdjust == null) + { + ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); + } + ajcAdjust.CallStatic("addSessionPartnerParameter", key, value); + } + + public static void AddSessionCallbackParameter(string key, string value) + { + if (ajcAdjust == null) + { + ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); + } + ajcAdjust.CallStatic("addSessionCallbackParameter", key, value); + } + + public static void RemoveSessionPartnerParameter(string key) + { + if (ajcAdjust == null) + { + ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); + } + ajcAdjust.CallStatic("removeSessionPartnerParameter", key); + } + + public static void RemoveSessionCallbackParameter(string key) + { + if (ajcAdjust == null) + { + ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); + } + ajcAdjust.CallStatic("removeSessionCallbackParameter", key); + } + + public static void ResetSessionPartnerParameters() + { + if (ajcAdjust == null) + { + ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); + } + ajcAdjust.CallStatic("resetSessionPartnerParameters"); + } + + public static void ResetSessionCallbackParameters() + { + if (ajcAdjust == null) + { + ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); + } + ajcAdjust.CallStatic("resetSessionCallbackParameters"); + } + + public static void AppWillOpenUrl(string url) + { + AndroidJavaClass ajcUri = new AndroidJavaClass("android.net.Uri"); + AndroidJavaObject ajoUri = ajcUri.CallStatic("parse", url); + ajcAdjust.CallStatic("appWillOpenUrl", ajoUri, ajoCurrentActivity); + } + + public static void TrackAdRevenue(string source, string payload) + { + if (ajcAdjust == null) + { + ajcAdjust = new AndroidJavaClass("com.adjust.sdk.Adjust"); + } + AndroidJavaObject jsonPayload = new AndroidJavaObject("org.json.JSONObject", payload); + ajcAdjust.CallStatic("trackAdRevenue", source, jsonPayload); + } + + public static void TrackAdRevenue(AdjustAdRevenue adRevenue) + { + AndroidJavaObject ajoAdjustAdRevenue = new AndroidJavaObject("com.adjust.sdk.AdjustAdRevenue", adRevenue.source); + + // Check if user has set revenue. + if (adRevenue.revenue != null) + { + AndroidJavaObject ajoRevenue = new AndroidJavaObject("java.lang.Double", adRevenue.revenue); + ajoAdjustAdRevenue.Call("setRevenue", ajoRevenue, adRevenue.currency); + } + + // Check if user has set ad impressions count. + if (adRevenue.adImpressionsCount != null) + { + AndroidJavaObject ajoAdImpressionsCount = new AndroidJavaObject("java.lang.Integer", adRevenue.adImpressionsCount); + ajoAdjustAdRevenue.Call("setAdImpressionsCount", ajoAdImpressionsCount); + } + + // Check if user has set ad revenue network. + if (adRevenue.adRevenueNetwork != null) + { + ajoAdjustAdRevenue.Call("setAdRevenueNetwork", adRevenue.adRevenueNetwork); + } + + // Check if user has set ad revenue unit. + if (adRevenue.adRevenueUnit != null) + { + ajoAdjustAdRevenue.Call("setAdRevenueUnit", adRevenue.adRevenueUnit); + } + + // Check if user has set ad revenue placement. + if (adRevenue.adRevenuePlacement != null) + { + ajoAdjustAdRevenue.Call("setAdRevenuePlacement", adRevenue.adRevenuePlacement); + } + + // Check if user has added any callback parameters. + if (adRevenue.callbackList != null) + { + for (int i = 0; i < adRevenue.callbackList.Count; i += 2) + { + string key = adRevenue.callbackList[i]; + string value = adRevenue.callbackList[i + 1]; + ajoAdjustAdRevenue.Call("addCallbackParameter", key, value); + } + } + + // Check if user has added any partner parameters. + if (adRevenue.partnerList != null) + { + for (int i = 0; i < adRevenue.partnerList.Count; i += 2) + { + string key = adRevenue.partnerList[i]; + string value = adRevenue.partnerList[i + 1]; + ajoAdjustAdRevenue.Call("addPartnerParameter", key, value); + } + } + + // Track ad revenue. + ajcAdjust.CallStatic("trackAdRevenue", ajoAdjustAdRevenue); + } + + public static void TrackPlayStoreSubscription(AdjustPlayStoreSubscription subscription) + { + AndroidJavaObject ajoSubscription = new AndroidJavaObject("com.adjust.sdk.AdjustPlayStoreSubscription", + Convert.ToInt64(subscription.price), + subscription.currency, + subscription.sku, + subscription.orderId, + subscription.signature, + subscription.purchaseToken); + + // Check if user has set purchase time for subscription. + if (subscription.purchaseTime != null) + { + ajoSubscription.Call("setPurchaseTime", Convert.ToInt64(subscription.purchaseTime)); + } + + // Check if user has added any callback parameters to the subscription. + if (subscription.callbackList != null) + { + for (int i = 0; i < subscription.callbackList.Count; i += 2) + { + string key = subscription.callbackList[i]; + string value = subscription.callbackList[i + 1]; + ajoSubscription.Call("addCallbackParameter", key, value); + } + } + + // Check if user has added any partner parameters to the subscription. + if (subscription.partnerList != null) + { + for (int i = 0; i < subscription.partnerList.Count; i += 2) + { + string key = subscription.partnerList[i]; + string value = subscription.partnerList[i + 1]; + ajoSubscription.Call("addPartnerParameter", key, value); + } + } + + // Track the subscription. + ajcAdjust.CallStatic("trackPlayStoreSubscription", ajoSubscription); + } + + public static void TrackThirdPartySharing(AdjustThirdPartySharing thirdPartySharing) + { + AndroidJavaObject ajoIsEnabled; + AndroidJavaObject ajoAdjustThirdPartySharing; + if (thirdPartySharing.isEnabled != null) + { + ajoIsEnabled = new AndroidJavaObject("java.lang.Boolean", thirdPartySharing.isEnabled.Value); + ajoAdjustThirdPartySharing = new AndroidJavaObject("com.adjust.sdk.AdjustThirdPartySharing", ajoIsEnabled); + } + else + { + string[] parameters = null; + ajoAdjustThirdPartySharing = new AndroidJavaObject("com.adjust.sdk.AdjustThirdPartySharing", parameters); + } + + if (thirdPartySharing.granularOptions != null) + { + foreach (KeyValuePair> entry in thirdPartySharing.granularOptions) + { + for (int i = 0; i < entry.Value.Count;) + { + ajoAdjustThirdPartySharing.Call("addGranularOption", entry.Key, entry.Value[i++], entry.Value[i++]); + } + } + } + + if (thirdPartySharing.partnerSharingSettings != null) + { + foreach (KeyValuePair> entry in thirdPartySharing.partnerSharingSettings) + { + for (int i = 0; i < entry.Value.Count;) + { + ajoAdjustThirdPartySharing.Call("addPartnerSharingSetting", entry.Key, entry.Value[i++], bool.Parse(entry.Value[i++])); + } + } + } + + ajcAdjust.CallStatic("trackThirdPartySharing", ajoAdjustThirdPartySharing); + } + + public static void TrackMeasurementConsent(bool measurementConsent) + { + ajcAdjust.CallStatic("trackMeasurementConsent", measurementConsent); + } + + // Android specific methods. + public static void OnPause() + { + ajcAdjust.CallStatic("onPause"); + } + + public static void OnResume() + { + ajcAdjust.CallStatic("onResume"); + } + + public static void SetReferrer(string referrer) + { + ajcAdjust.CallStatic("setReferrer", referrer, ajoCurrentActivity); + } + + public static void GetGoogleAdId(Action onDeviceIdsRead) + { + DeviceIdsReadListener onDeviceIdsReadProxy = new DeviceIdsReadListener(onDeviceIdsRead); + ajcAdjust.CallStatic("getGoogleAdId", ajoCurrentActivity, onDeviceIdsReadProxy); + } + + public static string GetAmazonAdId() + { + return ajcAdjust.CallStatic("getAmazonAdId", ajoCurrentActivity); + } + + public static string GetSdkVersion() + { + string nativeSdkVersion = ajcAdjust.CallStatic("getSdkVersion"); + return sdkPrefix + "@" + nativeSdkVersion; + } + + public static void VerifyPlayStorePurchase(AdjustPlayStorePurchase purchase, Action verificationInfoCallback) + { + AndroidJavaObject ajoPurchase = new AndroidJavaObject("com.adjust.sdk.AdjustPurchase", + purchase.productId, + purchase.purchaseToken); + onVerificationInfoListener = new VerificationInfoListener(verificationInfoCallback); + + ajcAdjust.CallStatic("verifyPurchase", ajoPurchase, onVerificationInfoListener); + } + + // Used for testing only. + public static void SetTestOptions(Dictionary testOptions) + { + AndroidJavaObject ajoTestOptions = AdjustUtils.TestOptionsMap2AndroidJavaObject(testOptions, ajoCurrentActivity); + ajcAdjust.CallStatic("setTestOptions", ajoTestOptions); + } + + // Private & helper classes. + private class AttributionChangeListener : AndroidJavaProxy + { + private Action callback; + + public AttributionChangeListener(Action pCallback) : base("com.adjust.sdk.OnAttributionChangedListener") + { + this.callback = pCallback; + } + + // Method must be lowercase to match Android method signature. + public void onAttributionChanged(AndroidJavaObject attribution) + { + if (callback == null) + { + return; + } + + AdjustAttribution adjustAttribution = new AdjustAttribution(); + adjustAttribution.trackerName = attribution.Get(AdjustUtils.KeyTrackerName) == "" ? + null : attribution.Get(AdjustUtils.KeyTrackerName); + adjustAttribution.trackerToken = attribution.Get(AdjustUtils.KeyTrackerToken) == "" ? + null : attribution.Get(AdjustUtils.KeyTrackerToken); + adjustAttribution.network = attribution.Get(AdjustUtils.KeyNetwork) == "" ? + null : attribution.Get(AdjustUtils.KeyNetwork); + adjustAttribution.campaign = attribution.Get(AdjustUtils.KeyCampaign) == "" ? + null : attribution.Get(AdjustUtils.KeyCampaign); + adjustAttribution.adgroup = attribution.Get(AdjustUtils.KeyAdgroup) == "" ? + null : attribution.Get(AdjustUtils.KeyAdgroup); + adjustAttribution.creative = attribution.Get(AdjustUtils.KeyCreative) == "" ? + null : attribution.Get(AdjustUtils.KeyCreative); + adjustAttribution.clickLabel = attribution.Get(AdjustUtils.KeyClickLabel) == "" ? + null : attribution.Get(AdjustUtils.KeyClickLabel); + adjustAttribution.adid = attribution.Get(AdjustUtils.KeyAdid) == "" ? + null : attribution.Get(AdjustUtils.KeyAdid); + adjustAttribution.costType = attribution.Get(AdjustUtils.KeyCostType) == "" ? + null : attribution.Get(AdjustUtils.KeyCostType); + AndroidJavaObject ajoCostAmount = attribution.Get(AdjustUtils.KeyCostAmount) == null ? + null : attribution.Get(AdjustUtils.KeyCostAmount); + if (ajoCostAmount == null) + { + adjustAttribution.costAmount = null; + } + else + { + double costAmount = ajoCostAmount.Call("doubleValue"); + adjustAttribution.costAmount = costAmount; + } + adjustAttribution.costCurrency = attribution.Get(AdjustUtils.KeyCostCurrency) == "" ? + null : attribution.Get(AdjustUtils.KeyCostCurrency); + adjustAttribution.fbInstallReferrer = attribution.Get(AdjustUtils.KeyFbInstallReferrer) == "" ? + null : attribution.Get(AdjustUtils.KeyFbInstallReferrer); + callback(adjustAttribution); + } + } + + private class DeferredDeeplinkListener : AndroidJavaProxy + { + private Action callback; + + public DeferredDeeplinkListener(Action pCallback) : base("com.adjust.sdk.OnDeeplinkResponseListener") + { + this.callback = pCallback; + } + + // Method must be lowercase to match Android method signature. + public bool launchReceivedDeeplink(AndroidJavaObject deeplink) + { + if (callback == null) + { + return launchDeferredDeeplink; + } + + string deeplinkURL = deeplink.Call("toString"); + callback(deeplinkURL); + return launchDeferredDeeplink; + } + } + + private class EventTrackingSucceededListener : AndroidJavaProxy + { + private Action callback; + + public EventTrackingSucceededListener(Action pCallback) : base("com.adjust.sdk.OnEventTrackingSucceededListener") + { + this.callback = pCallback; + } + + // Method must be lowercase to match Android method signature. + public void onFinishedEventTrackingSucceeded(AndroidJavaObject eventSuccessData) + { + if (callback == null) + { + return; + } + if (eventSuccessData == null) + { + return; + } + + AdjustEventSuccess adjustEventSuccess = new AdjustEventSuccess(); + adjustEventSuccess.Adid = eventSuccessData.Get(AdjustUtils.KeyAdid) == "" ? + null : eventSuccessData.Get(AdjustUtils.KeyAdid); + adjustEventSuccess.Message = eventSuccessData.Get(AdjustUtils.KeyMessage) == "" ? + null : eventSuccessData.Get(AdjustUtils.KeyMessage); + adjustEventSuccess.Timestamp = eventSuccessData.Get(AdjustUtils.KeyTimestamp) == "" ? + null : eventSuccessData.Get(AdjustUtils.KeyTimestamp); + adjustEventSuccess.EventToken = eventSuccessData.Get(AdjustUtils.KeyEventToken) == "" ? + null : eventSuccessData.Get(AdjustUtils.KeyEventToken); + adjustEventSuccess.CallbackId = eventSuccessData.Get(AdjustUtils.KeyCallbackId) == "" ? + null : eventSuccessData.Get(AdjustUtils.KeyCallbackId); + + try + { + AndroidJavaObject ajoJsonResponse = eventSuccessData.Get(AdjustUtils.KeyJsonResponse); + string jsonResponseString = ajoJsonResponse.Call("toString"); + adjustEventSuccess.BuildJsonResponseFromString(jsonResponseString); + } + catch (Exception) + { + // JSON response reading failed. + // Native Android SDK should send empty JSON object if none available as of v4.12.5. + // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. + } + + callback(adjustEventSuccess); + } + } + + private class EventTrackingFailedListener : AndroidJavaProxy + { + private Action callback; + + public EventTrackingFailedListener(Action pCallback) : base("com.adjust.sdk.OnEventTrackingFailedListener") + { + this.callback = pCallback; + } + + // Method must be lowercase to match Android method signature. + public void onFinishedEventTrackingFailed(AndroidJavaObject eventFailureData) + { + if (callback == null) + { + return; + } + if (eventFailureData == null) + { + return; + } + + AdjustEventFailure adjustEventFailure = new AdjustEventFailure(); + adjustEventFailure.Adid = eventFailureData.Get(AdjustUtils.KeyAdid) == "" ? + null : eventFailureData.Get(AdjustUtils.KeyAdid); + adjustEventFailure.Message = eventFailureData.Get(AdjustUtils.KeyMessage) == "" ? + null : eventFailureData.Get(AdjustUtils.KeyMessage); + adjustEventFailure.WillRetry = eventFailureData.Get(AdjustUtils.KeyWillRetry); + adjustEventFailure.Timestamp = eventFailureData.Get(AdjustUtils.KeyTimestamp) == "" ? + null : eventFailureData.Get(AdjustUtils.KeyTimestamp); + adjustEventFailure.EventToken = eventFailureData.Get(AdjustUtils.KeyEventToken) == "" ? + null : eventFailureData.Get(AdjustUtils.KeyEventToken); + adjustEventFailure.CallbackId = eventFailureData.Get(AdjustUtils.KeyCallbackId) == "" ? + null : eventFailureData.Get(AdjustUtils.KeyCallbackId); + + try + { + AndroidJavaObject ajoJsonResponse = eventFailureData.Get(AdjustUtils.KeyJsonResponse); + string jsonResponseString = ajoJsonResponse.Call("toString"); + adjustEventFailure.BuildJsonResponseFromString(jsonResponseString); + } + catch (Exception) + { + // JSON response reading failed. + // Native Android SDK should send empty JSON object if none available as of v4.12.5. + // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. + } + + callback(adjustEventFailure); + } + } + + private class SessionTrackingSucceededListener : AndroidJavaProxy + { + private Action callback; + + public SessionTrackingSucceededListener(Action pCallback) : base("com.adjust.sdk.OnSessionTrackingSucceededListener") + { + this.callback = pCallback; + } + + // Method must be lowercase to match Android method signature. + public void onFinishedSessionTrackingSucceeded(AndroidJavaObject sessionSuccessData) + { + if (callback == null) + { + return; + } + if (sessionSuccessData == null) + { + return; + } + + AdjustSessionSuccess adjustSessionSuccess = new AdjustSessionSuccess(); + adjustSessionSuccess.Adid = sessionSuccessData.Get(AdjustUtils.KeyAdid) == "" ? + null : sessionSuccessData.Get(AdjustUtils.KeyAdid); + adjustSessionSuccess.Message = sessionSuccessData.Get(AdjustUtils.KeyMessage) == "" ? + null : sessionSuccessData.Get(AdjustUtils.KeyMessage); + adjustSessionSuccess.Timestamp = sessionSuccessData.Get(AdjustUtils.KeyTimestamp) == "" ? + null : sessionSuccessData.Get(AdjustUtils.KeyTimestamp); + + try + { + AndroidJavaObject ajoJsonResponse = sessionSuccessData.Get(AdjustUtils.KeyJsonResponse); + string jsonResponseString = ajoJsonResponse.Call("toString"); + adjustSessionSuccess.BuildJsonResponseFromString(jsonResponseString); + } + catch (Exception) + { + // JSON response reading failed. + // Native Android SDK should send empty JSON object if none available as of v4.12.5. + // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. + } + + callback(adjustSessionSuccess); + } + } + + private class SessionTrackingFailedListener : AndroidJavaProxy + { + private Action callback; + + public SessionTrackingFailedListener(Action pCallback) : base("com.adjust.sdk.OnSessionTrackingFailedListener") + { + this.callback = pCallback; + } + + // Method must be lowercase to match Android method signature. + public void onFinishedSessionTrackingFailed(AndroidJavaObject sessionFailureData) + { + if (callback == null) + { + return; + } + if (sessionFailureData == null) + { + return; + } + + AdjustSessionFailure adjustSessionFailure = new AdjustSessionFailure(); + adjustSessionFailure.Adid = sessionFailureData.Get(AdjustUtils.KeyAdid) == "" ? + null : sessionFailureData.Get(AdjustUtils.KeyAdid); + adjustSessionFailure.Message = sessionFailureData.Get(AdjustUtils.KeyMessage) == "" ? + null : sessionFailureData.Get(AdjustUtils.KeyMessage); + adjustSessionFailure.WillRetry = sessionFailureData.Get(AdjustUtils.KeyWillRetry); + adjustSessionFailure.Timestamp = sessionFailureData.Get(AdjustUtils.KeyTimestamp) == "" ? + null : sessionFailureData.Get(AdjustUtils.KeyTimestamp); + + try + { + AndroidJavaObject ajoJsonResponse = sessionFailureData.Get(AdjustUtils.KeyJsonResponse); + string jsonResponseString = ajoJsonResponse.Call("toString"); + adjustSessionFailure.BuildJsonResponseFromString(jsonResponseString); + } + catch (Exception) + { + // JSON response reading failed. + // Native Android SDK should send empty JSON object if none available as of v4.12.5. + // Native Android SDK added special logic to send Unity friendly values as of v4.15.0. + } + + callback(adjustSessionFailure); + } + } + + private class DeviceIdsReadListener : AndroidJavaProxy + { + private Action onPlayAdIdReadCallback; + + public DeviceIdsReadListener(Action pCallback) : base("com.adjust.sdk.OnDeviceIdsRead") + { + this.onPlayAdIdReadCallback = pCallback; + } + + // Method must be lowercase to match Android method signature. + public void onGoogleAdIdRead(string playAdId) + { + if (onPlayAdIdReadCallback == null) + { + return; + } + + this.onPlayAdIdReadCallback(playAdId); + } + + // Handling of null object. + public void onGoogleAdIdRead(AndroidJavaObject ajoAdId) + { + if (ajoAdId == null) + { + string adId = null; + this.onGoogleAdIdRead(adId); + return; + } + + this.onGoogleAdIdRead(ajoAdId.Call("toString")); + } + } + + private class VerificationInfoListener : AndroidJavaProxy + { + private Action callback; + + public VerificationInfoListener(Action pCallback) : base("com.adjust.sdk.OnPurchaseVerificationFinishedListener") + { + this.callback = pCallback; + } + + public void onVerificationFinished(AndroidJavaObject verificationInfo) + { + AdjustPurchaseVerificationInfo purchaseVerificationInfo = new AdjustPurchaseVerificationInfo(); + // verification status + purchaseVerificationInfo.verificationStatus = verificationInfo.Get(AdjustUtils.KeyVerificationStatus); + // status code + purchaseVerificationInfo.code = verificationInfo.Get(AdjustUtils.KeyCode); + // message + purchaseVerificationInfo.message = verificationInfo.Get(AdjustUtils.KeyMessage); + + if (callback != null) + { + callback(purchaseVerificationInfo); + } + } + } + + // Private & helper methods. + private static bool IsAppSecretSet(AdjustConfig adjustConfig) + { + return adjustConfig.secretId.HasValue + && adjustConfig.info1.HasValue + && adjustConfig.info2.HasValue + && adjustConfig.info3.HasValue + && adjustConfig.info4.HasValue; + } + } +#endif +} diff --git a/Adjust/Android/AdjustAndroid.cs.meta b/Adjust/Android/AdjustAndroid.cs.meta new file mode 100644 index 0000000..f977efd --- /dev/null +++ b/Adjust/Android/AdjustAndroid.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 1b21499aaf10a42e8b6377af71a35ba5 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Android/AdjustAndroidManifest.xml b/Adjust/Android/AdjustAndroidManifest.xml new file mode 100644 index 0000000..d0471ae --- /dev/null +++ b/Adjust/Android/AdjustAndroidManifest.xml @@ -0,0 +1,56 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Adjust/Android/AdjustAndroidManifest.xml.meta b/Adjust/Android/AdjustAndroidManifest.xml.meta new file mode 100644 index 0000000..58af3b4 --- /dev/null +++ b/Adjust/Android/AdjustAndroidManifest.xml.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: a13ef442648c346a79f9ff24875c037a +TextScriptImporter: + userData: diff --git a/Adjust/Android/adjust-android.jar b/Adjust/Android/adjust-android.jar new file mode 100644 index 0000000..c07b4bf Binary files /dev/null and b/Adjust/Android/adjust-android.jar differ diff --git a/Adjust/Android/adjust-android.jar.meta b/Adjust/Android/adjust-android.jar.meta new file mode 100644 index 0000000..62add18 --- /dev/null +++ b/Adjust/Android/adjust-android.jar.meta @@ -0,0 +1,33 @@ +fileFormatVersion: 2 +guid: de7cd4cf0359345f487233fc82a1d892 +timeCreated: 1526341612 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': data + second: + enabled: 0 + settings: {} + data: + first: + Android: Android + second: + enabled: 1 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Editor.meta b/Adjust/Editor.meta new file mode 100644 index 0000000..9a97713 --- /dev/null +++ b/Adjust/Editor.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: af6a4d5087d014e96817909f48d7faac +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Editor/Adjust.Editor.asmdef b/Adjust/Editor/Adjust.Editor.asmdef new file mode 100644 index 0000000..84f122d --- /dev/null +++ b/Adjust/Editor/Adjust.Editor.asmdef @@ -0,0 +1,18 @@ +{ + "name": "Adjust.Editor", + "rootNamespace": "com.adjust.sdk", + "references": [ + "Adjust" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Adjust/Editor/Adjust.Editor.asmdef.meta b/Adjust/Editor/Adjust.Editor.asmdef.meta new file mode 100644 index 0000000..8cf2af2 --- /dev/null +++ b/Adjust/Editor/Adjust.Editor.asmdef.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e539acf4e82c476e9c5c849a7e699085 +timeCreated: 1701844361 \ No newline at end of file diff --git a/Adjust/Editor/AdjustCustomEditor.cs b/Adjust/Editor/AdjustCustomEditor.cs new file mode 100644 index 0000000..0162152 --- /dev/null +++ b/Adjust/Editor/AdjustCustomEditor.cs @@ -0,0 +1,84 @@ +using System; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor.SceneManagement; +using UnityEditor; + +namespace com.adjust.sdk +{ + [CustomEditor(typeof(Adjust))] + public class AdjustCustomEditor : Editor + { + private Editor settingsEditor; + + public override void OnInspectorGUI() + { + base.OnInspectorGUI(); + + var adjust = target as Adjust; + GUIStyle darkerCyanTextFieldStyles = new GUIStyle(EditorStyles.boldLabel); + darkerCyanTextFieldStyles.normal.textColor = new Color(0f/255f, 190f/255f, 190f/255f); + + // Not gonna ask: http://answers.unity.com/answers/1244650/view.html + EditorGUILayout.Space(); + var origFontStyle = EditorStyles.label.fontStyle; + EditorStyles.label.fontStyle = FontStyle.Bold; + adjust.startManually = EditorGUILayout.Toggle("START SDK MANUALLY", adjust.startManually, EditorStyles.toggle); + EditorStyles.label.fontStyle = origFontStyle; + + using (new EditorGUI.DisabledScope(adjust.startManually)) + { + EditorGUILayout.Space(); + EditorGUILayout.LabelField("MULTIPLATFORM SETTINGS:", darkerCyanTextFieldStyles); + EditorGUI.indentLevel += 1; + adjust.appToken = EditorGUILayout.TextField("App Token", adjust.appToken); + adjust.environment = (AdjustEnvironment)EditorGUILayout.EnumPopup("Environment", adjust.environment); + adjust.logLevel = (AdjustLogLevel)EditorGUILayout.EnumPopup("Log Level", adjust.logLevel); + adjust.urlStrategy = (AdjustUrlStrategy)EditorGUILayout.EnumPopup("URL Strategy", adjust.urlStrategy); + adjust.eventBuffering = EditorGUILayout.Toggle("Event Buffering", adjust.eventBuffering); + adjust.sendInBackground = EditorGUILayout.Toggle("Send In Background", adjust.sendInBackground); + adjust.launchDeferredDeeplink = EditorGUILayout.Toggle("Launch Deferred Deep Link", adjust.launchDeferredDeeplink); + adjust.needsCost = EditorGUILayout.Toggle("Cost Data In Attribution Callback", adjust.needsCost); + adjust.coppaCompliant = EditorGUILayout.Toggle("COPPA Compliant", adjust.coppaCompliant); + adjust.linkMe = EditorGUILayout.Toggle("LinkMe", adjust.linkMe); + adjust.defaultTracker = EditorGUILayout.TextField("Default Tracker", adjust.defaultTracker); + adjust.startDelay = EditorGUILayout.DoubleField("Start Delay", adjust.startDelay); + EditorGUILayout.LabelField("App Secret:", EditorStyles.label); + EditorGUI.indentLevel += 1; + adjust.secretId = EditorGUILayout.LongField("Secret ID", adjust.secretId); + adjust.info1 = EditorGUILayout.LongField("Info 1", adjust.info1); + adjust.info2 = EditorGUILayout.LongField("Info 2", adjust.info2); + adjust.info3 = EditorGUILayout.LongField("Info 3", adjust.info3); + adjust.info4 = EditorGUILayout.LongField("Info 4", adjust.info4); + EditorGUI.indentLevel -= 2; + EditorGUILayout.Space(); + EditorGUILayout.LabelField("ANDROID SETTINGS:", darkerCyanTextFieldStyles); + EditorGUI.indentLevel += 1; + adjust.preinstallTracking = EditorGUILayout.Toggle("Preinstall Tracking", adjust.preinstallTracking); + adjust.preinstallFilePath = EditorGUILayout.TextField("Preinstall File Path", adjust.preinstallFilePath); + adjust.playStoreKidsApp = EditorGUILayout.Toggle("Play Store Kids App", adjust.playStoreKidsApp); + EditorGUI.indentLevel -= 1; + EditorGUILayout.Space(); + EditorGUILayout.LabelField("IOS SETTINGS:", darkerCyanTextFieldStyles); + EditorGUI.indentLevel += 1; + adjust.adServicesInfoReading = EditorGUILayout.Toggle("AdServices Info Reading", adjust.adServicesInfoReading); + adjust.idfaInfoReading = EditorGUILayout.Toggle("IDFA Info Reading", adjust.idfaInfoReading); + adjust.skAdNetworkHandling = EditorGUILayout.Toggle("SKAdNetwork Handling", adjust.skAdNetworkHandling); + EditorGUI.indentLevel -= 1; + } + + if (settingsEditor == null) + { + settingsEditor = CreateEditor(AdjustSettings.Instance); + } + + settingsEditor.OnInspectorGUI(); + + if (GUI.changed) + { + EditorUtility.SetDirty(adjust); + EditorSceneManager.MarkSceneDirty(adjust.gameObject.scene); + } + } + } +} diff --git a/Adjust/Editor/AdjustCustomEditor.cs.meta b/Adjust/Editor/AdjustCustomEditor.cs.meta new file mode 100644 index 0000000..8039909 --- /dev/null +++ b/Adjust/Editor/AdjustCustomEditor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 1772b9461c24c4df0ad55f51f81c7345 +timeCreated: 1617868100 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Editor/AdjustEditor.cs b/Adjust/Editor/AdjustEditor.cs new file mode 100644 index 0000000..b81dadc --- /dev/null +++ b/Adjust/Editor/AdjustEditor.cs @@ -0,0 +1,342 @@ +using System; +using System.IO; +using System.Linq; +using System.Xml; +using System.Collections.Generic; +using System.Text.RegularExpressions; +using UnityEngine; +using UnityEditor; +using UnityEditor.Callbacks; +#if UNITY_IOS +using UnityEditor.iOS.Xcode; +#endif + +public class AdjustEditor : AssetPostprocessor +{ + [MenuItem("Assets/Adjust/Export Unity Package")] + public static void ExportAdjustUnityPackage() + { + string exportedFileName = "Adjust.unitypackage"; + string assetsPath = "Assets/Adjust"; + List assetsToExport = new List(); + + // Adjust Assets. + assetsToExport.Add(assetsPath + "/3rd Party/SimpleJSON.cs"); + + assetsToExport.Add(assetsPath + "/Android/adjust-android.jar"); + assetsToExport.Add(assetsPath + "/Android/AdjustAndroid.cs"); + assetsToExport.Add(assetsPath + "/Android/AdjustAndroidManifest.xml"); + + assetsToExport.Add(assetsPath + "/Editor/AdjustEditor.cs"); + assetsToExport.Add(assetsPath + "/Editor/AdjustSettings.cs"); + assetsToExport.Add(assetsPath + "/Editor/AdjustSettingsEditor.cs"); + assetsToExport.Add(assetsPath + "/Editor/AdjustCustomEditor.cs"); + assetsToExport.Add(assetsPath + "/Editor/AdjustEditorPreprocessor.cs"); + + assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.cs"); + assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.prefab"); + assetsToExport.Add(assetsPath + "/ExampleGUI/ExampleGUI.unity"); + + assetsToExport.Add(assetsPath + "/iOS/ADJAttribution.h"); + assetsToExport.Add(assetsPath + "/iOS/ADJConfig.h"); + assetsToExport.Add(assetsPath + "/iOS/ADJEvent.h"); + assetsToExport.Add(assetsPath + "/iOS/ADJEventFailure.h"); + assetsToExport.Add(assetsPath + "/iOS/ADJEventSuccess.h"); + assetsToExport.Add(assetsPath + "/iOS/ADJLogger.h"); + assetsToExport.Add(assetsPath + "/iOS/ADJSessionFailure.h"); + assetsToExport.Add(assetsPath + "/iOS/ADJSessionSuccess.h"); + assetsToExport.Add(assetsPath + "/iOS/ADJSubscription.h"); + assetsToExport.Add(assetsPath + "/iOS/Adjust.h"); + assetsToExport.Add(assetsPath + "/iOS/AdjustiOS.cs"); + assetsToExport.Add(assetsPath + "/iOS/AdjustSdk.a"); + assetsToExport.Add(assetsPath + "/iOS/AdjustUnity.h"); + assetsToExport.Add(assetsPath + "/iOS/AdjustUnity.mm"); + assetsToExport.Add(assetsPath + "/iOS/AdjustUnityDelegate.h"); + assetsToExport.Add(assetsPath + "/iOS/AdjustUnityDelegate.mm"); + + assetsToExport.Add(assetsPath + "/Prefab/Adjust.prefab"); + + assetsToExport.Add(assetsPath + "/Unity/Adjust.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustAppStoreSubscription.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustAttribution.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustConfig.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustEnvironment.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustEvent.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustEventFailure.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustEventSuccess.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustLogLevel.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustPlayStoreSubscription.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustSessionFailure.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustSessionSuccess.cs"); + assetsToExport.Add(assetsPath + "/Unity/AdjustUtils.cs"); + + assetsToExport.Add(assetsPath + "/Windows/AdjustWindows.cs"); + assetsToExport.Add(assetsPath + "/Windows/WindowsPcl.dll"); + assetsToExport.Add(assetsPath + "/Windows/WindowsUap.dll"); + assetsToExport.Add(assetsPath + "/Windows/Stubs/Win10Interface.dll"); + assetsToExport.Add(assetsPath + "/Windows/Stubs/Win81Interface.dll"); + assetsToExport.Add(assetsPath + "/Windows/Stubs/WinWsInterface.dll"); + assetsToExport.Add(assetsPath + "/Windows/W81/AdjustWP81.dll"); + assetsToExport.Add(assetsPath + "/Windows/W81/Win81Interface.dll"); + assetsToExport.Add(assetsPath + "/Windows/WS/AdjustWS.dll"); + assetsToExport.Add(assetsPath + "/Windows/WS/WinWsInterface.dll"); + assetsToExport.Add(assetsPath + "/Windows/WU10/AdjustUAP10.dll"); + assetsToExport.Add(assetsPath + "/Windows/WU10/Win10Interface.dll"); + assetsToExport.Add(assetsPath + "/Windows/Newtonsoft.Json.dll"); + + AssetDatabase.ExportPackage( + assetsToExport.ToArray(), + exportedFileName, + ExportPackageOptions.IncludeDependencies | ExportPackageOptions.Interactive); + } + + [PostProcessBuild] + public static void OnPostprocessBuild(BuildTarget target, string projectPath) + { + RunPostBuildScript(target: target, projectPath: projectPath); + } + + private static void RunPostBuildScript(BuildTarget target, string projectPath = "") + { + if (target == BuildTarget.iOS) + { +#if UNITY_IOS + Debug.Log("[Adjust]: Starting to perform post build tasks for iOS platform."); + + string xcodeProjectPath = projectPath + "/Unity-iPhone.xcodeproj/project.pbxproj"; + + PBXProject xcodeProject = new PBXProject(); + xcodeProject.ReadFromFile(xcodeProjectPath); + +#if UNITY_2019_3_OR_NEWER + string xcodeTarget = xcodeProject.GetUnityMainTargetGuid(); +#else + string xcodeTarget = xcodeProject.TargetGuidByName("Unity-iPhone"); +#endif + HandlePlistIosChanges(projectPath); + + if (AdjustSettings.iOSUniversalLinksDomains.Length > 0) + { + AddUniversalLinkDomains(xcodeProject, xcodeProjectPath, xcodeTarget); + } + + // If enabled by the user, Adjust SDK will try to add following frameworks to your project: + // - AdSupport.framework (needed for access to IDFA value) + // - AdServices.framework (needed in case you are running ASA campaigns) + // - StoreKit.framework (needed for communication with SKAdNetwork framework) + // - AppTrackingTransparency.framework (needed for information about user's consent to be tracked) + // In case you don't need any of these, feel free to remove them from your app. + + if (AdjustSettings.iOSFrameworkAdSupport) + { + Debug.Log("[Adjust]: Adding AdSupport.framework to Xcode project."); + xcodeProject.AddFrameworkToProject(xcodeTarget, "AdSupport.framework", true); + Debug.Log("[Adjust]: AdSupport.framework added successfully."); + } + else + { + Debug.Log("[Adjust]: Skipping AdSupport.framework linking."); + } + if (AdjustSettings.iOSFrameworkAdServices) + { + Debug.Log("[Adjust]: Adding AdServices.framework to Xcode project."); + xcodeProject.AddFrameworkToProject(xcodeTarget, "AdServices.framework", true); + Debug.Log("[Adjust]: AdServices.framework added successfully."); + } + else + { + Debug.Log("[Adjust]: Skipping AdServices.framework linking."); + } + if (AdjustSettings.iOSFrameworkStoreKit) + { + Debug.Log("[Adjust]: Adding StoreKit.framework to Xcode project."); + xcodeProject.AddFrameworkToProject(xcodeTarget, "StoreKit.framework", true); + Debug.Log("[Adjust]: StoreKit.framework added successfully."); + } + else + { + Debug.Log("[Adjust]: Skipping StoreKit.framework linking."); + } + if (AdjustSettings.iOSFrameworkAppTrackingTransparency) + { + Debug.Log("[Adjust]: Adding AppTrackingTransparency.framework to Xcode project."); + xcodeProject.AddFrameworkToProject(xcodeTarget, "AppTrackingTransparency.framework", true); + Debug.Log("[Adjust]: AppTrackingTransparency.framework added successfully."); + } + else + { + Debug.Log("[Adjust]: Skipping AppTrackingTransparency.framework linking."); + } + + // The Adjust SDK needs to have -ObjC flag set in other linker flags section because of it's categories. + // OTHER_LDFLAGS -ObjC + // + // Seems that in newer Unity IDE versions adding -ObjC flag to Unity-iPhone target doesn't do the trick. + // Adding -ObjC to UnityFramework target however does make things work nicely again. + // This happens because Unity is linking SDK's static library into UnityFramework target. + // Check for presence of UnityFramework target and if there, include -ObjC flag inside of it. + Debug.Log("[Adjust]: Adding -ObjC flag to other linker flags (OTHER_LDFLAGS) of Unity-iPhone target."); + xcodeProject.AddBuildProperty(xcodeTarget, "OTHER_LDFLAGS", "-ObjC"); + Debug.Log("[Adjust]: -ObjC successfully added to other linker flags."); + string xcodeTargetUnityFramework = xcodeProject.TargetGuidByName("UnityFramework"); + if (!string.IsNullOrEmpty(xcodeTargetUnityFramework)) + { + Debug.Log("[Adjust]: Adding -ObjC flag to other linker flags (OTHER_LDFLAGS) of UnityFramework target."); + xcodeProject.AddBuildProperty(xcodeTargetUnityFramework, "OTHER_LDFLAGS", "-ObjC"); + Debug.Log("[Adjust]: -ObjC successfully added to other linker flags."); + } + + // The Adjust SDK needs to have Obj-C exceptions enabled. + // GCC_ENABLE_OBJC_EXCEPTIONS=YES + Debug.Log("[Adjust]: Enabling Obj-C exceptions by setting GCC_ENABLE_OBJC_EXCEPTIONS value to YES."); + xcodeProject.AddBuildProperty(xcodeTarget, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES"); + Debug.Log("[Adjust]: Obj-C exceptions enabled successfully."); + if (!string.IsNullOrEmpty(xcodeTargetUnityFramework)) + { + Debug.Log("[Adjust]: Enabling Obj-C exceptions by setting GCC_ENABLE_OBJC_EXCEPTIONS value to YES."); + xcodeProject.AddBuildProperty(xcodeTargetUnityFramework, "GCC_ENABLE_OBJC_EXCEPTIONS", "YES"); + Debug.Log("[Adjust]: Obj-C exceptions enabled successfully."); + } + + if (xcodeProject.ContainsFileByProjectPath("Libraries/Adjust/iOS/AdjustSigSdk.a")) + { + if (!string.IsNullOrEmpty(xcodeTargetUnityFramework)) + { + xcodeProject.AddBuildProperty(xcodeTargetUnityFramework, "OTHER_LDFLAGS", "-force_load $(PROJECT_DIR)/Libraries/Adjust/iOS/AdjustSigSdk.a"); + } + else + { + xcodeProject.AddBuildProperty(xcodeTarget, "OTHER_LDFLAGS", "-force_load $(PROJECT_DIR)/Libraries/Adjust/iOS/AdjustSigSdk.a"); + } + } + + // Save the changes to Xcode project file. + xcodeProject.WriteToFile(xcodeProjectPath); +#endif + } + } + +#if UNITY_IOS + private static void HandlePlistIosChanges(string projectPath) + { + const string UserTrackingUsageDescriptionKey = "NSUserTrackingUsageDescription"; + + // Check if needs to do any info plist change. + bool hasUserTrackingDescription = + !string.IsNullOrEmpty(AdjustSettings.iOSUserTrackingUsageDescription); + bool hasUrlSchemesDeepLinksEnabled = AdjustSettings.iOSUrlSchemes.Length > 0; + + if (!hasUserTrackingDescription && !hasUrlSchemesDeepLinksEnabled) + { + return; + } + + // Get and read info plist. + var plistPath = Path.Combine(projectPath, "Info.plist"); + var plist = new PlistDocument(); + plist.ReadFromFile(plistPath); + var plistRoot = plist.root; + + // Do the info plist changes. + if (hasUserTrackingDescription) + { + if (plistRoot[UserTrackingUsageDescriptionKey] != null) + { + Debug.Log("[Adjust]: Overwritting User Tracking Usage Description."); + } + plistRoot.SetString(UserTrackingUsageDescriptionKey, + AdjustSettings.iOSUserTrackingUsageDescription); + } + + if (hasUrlSchemesDeepLinksEnabled) + { + AddUrlSchemesIOS(plistRoot, AdjustSettings.iOSUrlIdentifier, AdjustSettings.iOSUrlSchemes); + } + + // Write any info plist change. + File.WriteAllText(plistPath, plist.WriteToString()); + } + + private static void AddUrlSchemesIOS(PlistElementDict plistRoot, string urlIdentifier, string[] urlSchemes) + { + // Set Array for futher deeplink values. + var urlTypesArray = CreatePlistElementArray(plistRoot, "CFBundleURLTypes"); + + // Array will contain just one deeplink dictionary + var urlSchemesItems = CreatePlistElementDict(urlTypesArray); + urlSchemesItems.SetString("CFBundleURLName", urlIdentifier); + var urlSchemesArray = CreatePlistElementArray(urlSchemesItems, "CFBundleURLSchemes"); + + // Delete old deferred deeplinks URIs + Debug.Log("[Adjust]: Removing deeplinks that already exist in the array to avoid duplicates."); + foreach (var link in urlSchemes) + { + urlSchemesArray.values.RemoveAll( + element => element != null && element.AsString().Equals(link)); + } + + Debug.Log("[Adjust]: Adding new deep links."); + foreach (var link in urlSchemes.Distinct()) + { + urlSchemesArray.AddString(link); + } + } + + private static PlistElementArray CreatePlistElementArray(PlistElementDict root, string key) + { + if (!root.values.ContainsKey(key)) + { + Debug.Log(string.Format("[Adjust]: {0} not found in Info.plist. Creating a new one.", key)); + return root.CreateArray(key); + } + var result = root.values[key].AsArray(); + return result != null ? result : root.CreateArray(key); + } + + private static PlistElementDict CreatePlistElementDict(PlistElementArray rootArray) + { + if (rootArray.values.Count == 0) + { + Debug.Log("[Adjust]: Deeplinks array doesn't contain dictionary for deeplinks. Creating a new one."); + return rootArray.AddDict(); + } + + var urlSchemesItems = rootArray.values[0].AsDict(); + Debug.Log("[Adjust]: Reading deeplinks array"); + if (urlSchemesItems == null) + { + Debug.Log("[Adjust]: Deeplinks array doesn't contain dictionary for deeplinks. Creating a new one."); + urlSchemesItems = rootArray.AddDict(); + } + + return urlSchemesItems; + } + + private static void AddUniversalLinkDomains(PBXProject project, string xCodeProjectPath, string xCodeTarget) + { + string entitlementsFileName = "Unity-iPhone.entitlements"; + + Debug.Log("[Adjust]: Adding associated domains to entitlements file."); +#if UNITY_2019_3_OR_NEWER + var projectCapabilityManager = new ProjectCapabilityManager(xCodeProjectPath, entitlementsFileName, null, project.GetUnityMainTargetGuid()); +#else + var projectCapabilityManager = new ProjectCapabilityManager(xCodeProjectPath, entitlementsFileName, PBXProject.GetUnityTargetName()); +#endif + var uniqueDomains = AdjustSettings.iOSUniversalLinksDomains.Distinct().ToArray(); + const string applinksPrefix = "applinks:"; + for (int i = 0; i < uniqueDomains.Length; i++) + { + if (!uniqueDomains[i].StartsWith(applinksPrefix)) + { + uniqueDomains[i] = applinksPrefix + uniqueDomains[i]; + } + } + + projectCapabilityManager.AddAssociatedDomains(uniqueDomains); + projectCapabilityManager.WriteToFile(); + + Debug.Log("[Adjust]: Enabling Associated Domains capability with created entitlements file."); + project.AddCapability(xCodeTarget, PBXCapabilityType.AssociatedDomains, entitlementsFileName); + } +#endif +} diff --git a/Adjust/Editor/AdjustEditor.cs.meta b/Adjust/Editor/AdjustEditor.cs.meta new file mode 100644 index 0000000..13983a5 --- /dev/null +++ b/Adjust/Editor/AdjustEditor.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: fc5962e0096e9495bbad76934c842619 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Editor/AdjustEditorPreprocessor.cs b/Adjust/Editor/AdjustEditorPreprocessor.cs new file mode 100644 index 0000000..0c8d9b1 --- /dev/null +++ b/Adjust/Editor/AdjustEditorPreprocessor.cs @@ -0,0 +1,365 @@ +using System.IO; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEditor.Build; +using UnityEditor; +using System.Xml; +using System; +using System.Text.RegularExpressions; +using System.Linq; + +#if UNITY_2018_1_OR_NEWER +public class AdjustEditorPreprocessor : IPreprocessBuildWithReport +#else +public class AdjustEditorPreprocessor : IPreprocessBuild +#endif +{ + public int callbackOrder + { + get + { + return 0; + } + } +#if UNITY_2018_1_OR_NEWER + public void OnPreprocessBuild(UnityEditor.Build.Reporting.BuildReport report) + { + OnPreprocessBuild(report.summary.platform, string.Empty); + } +#endif + + public void OnPreprocessBuild(BuildTarget target, string path) + { + if (target == BuildTarget.Android) + { +#if UNITY_ANDROID + RunPostProcessTasksAndroid(); +#endif + } + } + +#if UNITY_ANDROID + private static void RunPostProcessTasksAndroid() + { + var isAdjustManifestUsed = false; + var androidPluginsPath = Path.Combine(Application.dataPath, "Plugins/Android"); + var adjustManifestPath = Path.Combine(Application.dataPath, "Adjust/Android/AdjustAndroidManifest.xml"); + var appManifestPath = Path.Combine(Application.dataPath, "Plugins/Android/AndroidManifest.xml"); + + // Check if user has already created AndroidManifest.xml file in its location. + // If not, use already predefined AdjustAndroidManifest.xml as default one. + if (!File.Exists(appManifestPath)) + { + if (!Directory.Exists(androidPluginsPath)) + { + Directory.CreateDirectory(androidPluginsPath); + } + + isAdjustManifestUsed = true; + File.Copy(adjustManifestPath, appManifestPath); + + Debug.Log("[Adjust]: User defined AndroidManifest.xml file not found in Plugins/Android folder."); + Debug.Log("[Adjust]: Creating default app's AndroidManifest.xml from AdjustAndroidManifest.xml file."); + } + else + { + Debug.Log("[Adjust]: User defined AndroidManifest.xml file located in Plugins/Android folder."); + } + + // Let's open the app's AndroidManifest.xml file. + var manifestFile = new XmlDocument(); + manifestFile.Load(appManifestPath); + + var manifestHasChanged = false; + + // If Adjust manifest is used, we have already set up everything in it so that + // our native Android SDK can be used properly. + if (!isAdjustManifestUsed) + { + // However, if you already had your own AndroidManifest.xml, we'll now run + // some checks on it and tweak it a bit if needed to add some stuff which + // our native Android SDK needs so that it can run properly. + + // Add needed permissions if they are missing. + manifestHasChanged |= AddPermissions(manifestFile); + + // Add intent filter to main activity if it is missing. + manifestHasChanged |= AddBroadcastReceiver(manifestFile); + } + + // Add intent filter to URL schemes for deeplinking + manifestHasChanged |= AddURISchemes(manifestFile); + + if (manifestHasChanged) + { + // Save the changes. + manifestFile.Save(appManifestPath); + + Debug.Log("[Adjust]: App's AndroidManifest.xml file check and potential modification completed."); + Debug.Log("[Adjust]: Please check if any error message was displayed during this process " + + "and make sure to fix all issues in order to properly use the Adjust SDK in your app."); + } + else + { + Debug.Log("[Adjust]: App's AndroidManifest.xml file check completed."); + Debug.Log("[Adjust]: No modifications performed due to app's AndroidManifest.xml file compatibility."); + } + } + + private static bool AddURISchemes(XmlDocument manifest) + { + if (AdjustSettings.AndroidUriSchemes.Length == 0) + { + return false; + } + Debug.Log("[Adjust]: Start addition of URI schemes"); + + var intentRoot = manifest.DocumentElement.SelectSingleNode("/manifest/application/activity[@android:name='com.unity3d.player.UnityPlayerActivity']", GetNamespaceManager(manifest)); + var usedIntentFiltersChanged = false; + var usedIntentFilters = GetIntentFilter(manifest); + foreach (var uriScheme in AdjustSettings.AndroidUriSchemes) + { + Uri uri; + try + { + // The first element is android:scheme and the second one is android:host. + uri = new Uri(uriScheme); + + // Uri class converts implicit file paths to explicit file paths with the file:// scheme. + if (!uriScheme.StartsWith(uri.Scheme)) + { + throw new UriFormatException(); + } + } + catch (UriFormatException) + { + Debug.LogError(string.Format("[Adjust]: Android deeplink URI scheme \"{0}\" is invalid and will be ignored.", uriScheme)); + Debug.LogWarning(string.Format("[Adjust]: Make sure that your URI scheme entry ends with ://")); + continue; + } + + if (!IsIntentFilterAlreadyExist(manifest, uri)) + { + Debug.Log("[Adjust]: Adding new URI with scheme: " + uri.Scheme + ", and host: " + uri.Host); + var androidSchemeNode = manifest.CreateElement("data"); + AddAndroidNamespaceAttribute(manifest, "scheme", uri.Scheme, androidSchemeNode); + AddAndroidNamespaceAttribute(manifest, "host", uri.Host, androidSchemeNode); + usedIntentFilters.AppendChild(androidSchemeNode); + usedIntentFiltersChanged = true; + + Debug.Log(string.Format("[Adjust]: Android deeplink URI scheme \"{0}\" successfully added to your app's AndroidManifest.xml file.", uriScheme)); + } + } + + if (usedIntentFiltersChanged && usedIntentFilters.ParentNode == null) + { + intentRoot.AppendChild(usedIntentFilters); + } + + return usedIntentFiltersChanged; + } + + private static XmlElement GetIntentFilter(XmlDocument manifest) + { + var xpath = "/manifest/application/activity/intent-filter[data/@android:scheme and data/@android:host]"; + var intentFilter = manifest.DocumentElement.SelectSingleNode(xpath, GetNamespaceManager(manifest)) as XmlElement; + if (intentFilter == null) + { + const string androidName = "name"; + const string category = "category"; + + intentFilter = manifest.CreateElement("intent-filter"); + + var actionElement = manifest.CreateElement("action"); + AddAndroidNamespaceAttribute(manifest, androidName, "android.intent.action.VIEW", actionElement); + intentFilter.AppendChild(actionElement); + + var defaultCategory = manifest.CreateElement(category); + AddAndroidNamespaceAttribute(manifest, androidName, "android.intent.category.DEFAULT", defaultCategory); + intentFilter.AppendChild(defaultCategory); + + var browsableCategory = manifest.CreateElement(category); + AddAndroidNamespaceAttribute(manifest, androidName, "android.intent.category.BROWSABLE", browsableCategory); + intentFilter.AppendChild(browsableCategory); + } + return intentFilter; + } + + private static bool IsIntentFilterAlreadyExist(XmlDocument manifest, Uri link) + { + var xpath = string.Format("/manifest/application/activity/intent-filter/data[@android:scheme='{0}' and @android:host='{1}']", link.Scheme, link.Host); + return manifest.DocumentElement.SelectSingleNode(xpath, GetNamespaceManager(manifest)) != null; + } + + private static bool AddPermissions(XmlDocument manifest) + { + // The Adjust SDK needs two permissions to be added to you app's manifest file: + // + // + // + // + + Debug.Log("[Adjust]: Checking if all permissions needed for the Adjust SDK are present in the app's AndroidManifest.xml file."); + + var manifestHasChanged = false; + + // If enabled by the user && android.permission.INTERNET permission is missing, add it. + if (AdjustSettings.androidPermissionInternet == true) + { + manifestHasChanged |= AddPermission(manifest, "android.permission.INTERNET"); + } + // If enabled by the user && com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE permission is missing, add it. + if (AdjustSettings.androidPermissionInstallReferrerService == true) + { + manifestHasChanged |= AddPermission(manifest, "com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE"); + } + // If enabled by the user && com.google.android.gms.permission.AD_ID permission is missing, add it. + if (AdjustSettings.androidPermissionAdId == true) + { + manifestHasChanged |= AddPermission(manifest, "com.google.android.gms.permission.AD_ID"); + } + // If enabled by the user && android.permission.ACCESS_NETWORK_STATE permission is missing, add it. + if (AdjustSettings.androidPermissionAccessNetworkState == true) + { + manifestHasChanged |= AddPermission(manifest, "android.permission.ACCESS_NETWORK_STATE"); + } + + return manifestHasChanged; + } + + private static bool AddPermission(XmlDocument manifest, string permissionValue) + { + if (DoesPermissionExist(manifest, permissionValue)) + { + Debug.Log(string.Format("[Adjust]: Your app's AndroidManifest.xml file already contains {0} permission.", permissionValue)); + return false; + } + + var element = manifest.CreateElement("uses-permission"); + AddAndroidNamespaceAttribute(manifest, "name", permissionValue, element); + manifest.DocumentElement.AppendChild(element); + Debug.Log(string.Format("[Adjust]: {0} permission successfully added to your app's AndroidManifest.xml file.", permissionValue)); + + return true; + } + + private static bool DoesPermissionExist(XmlDocument manifest, string permissionValue) + { + var xpath = string.Format("/manifest/uses-permission[@android:name='{0}']", permissionValue); + return manifest.DocumentElement.SelectSingleNode(xpath, GetNamespaceManager(manifest)) != null; + } + + private static bool AddBroadcastReceiver(XmlDocument manifest) + { + // We're looking for existence of broadcast receiver in the AndroidManifest.xml + // Check out the example below how that usually looks like: + + // > + // + // /> + // + // > + // + // + // + // + // + // + // + // + // + // + // + // > + // + // + + Debug.Log("[Adjust]: Checking if app's AndroidManifest.xml file contains receiver for INSTALL_REFERRER intent."); + + // Find the application node + var applicationNodeXpath = "/manifest/application"; + var applicationNode = manifest.DocumentElement.SelectSingleNode(applicationNodeXpath); + + // If there's no application node, something is really wrong with your AndroidManifest.xml. + if (applicationNode == null) + { + Debug.LogError("[Adjust]: Your app's AndroidManifest.xml file does not contain \"\" node."); + Debug.LogError("[Adjust]: Unable to add the Adjust broadcast receiver to AndroidManifest.xml."); + return false; + } + + // Okay, there's an application node in the AndroidManifest.xml file. + // Let's now check if user has already defined a receiver which is listening to INSTALL_REFERRER intent. + // If that is already defined, don't force the Adjust broadcast receiver to the manifest file. + // If not, add the Adjust broadcast receiver to the manifest file. + + var customBroadcastReceiversNodes = GetCustomRecieverNodes(manifest); + if (customBroadcastReceiversNodes.Count > 0) + { + if (DoesAdjustBroadcastReceiverExist(manifest)) + { + Debug.Log("[Adjust]: It seems like you are already using Adjust broadcast receiver. Yay."); + } + else + { + Debug.Log("[Adjust]: It seems like you are using your own broadcast receiver."); + Debug.Log("[Adjust]: Please, add the calls to the Adjust broadcast receiver like described in here: https://github.com/adjust/android_sdk/blob/master/doc/english/referrer.md"); + } + + return false; + } + + // Generate Adjust broadcast receiver entry and add it to the application node. + var receiverElement = manifest.CreateElement("receiver"); + AddAndroidNamespaceAttribute(manifest, "name", "com.adjust.sdk.AdjustReferrerReceiver", receiverElement); + AddAndroidNamespaceAttribute(manifest, "permission", "android.permission.INSTALL_PACKAGES", receiverElement); + AddAndroidNamespaceAttribute(manifest, "exported", "true", receiverElement); + + var intentFilterElement = manifest.CreateElement("intent-filter"); + var actionElement = manifest.CreateElement("action"); + AddAndroidNamespaceAttribute(manifest, "name", "com.android.vending.INSTALL_REFERRER", actionElement); + + intentFilterElement.AppendChild(actionElement); + receiverElement.AppendChild(intentFilterElement); + applicationNode.AppendChild(receiverElement); + + Debug.Log("[Adjust]: Adjust broadcast receiver successfully added to your app's AndroidManifest.xml file."); + + return true; + } + + private static bool DoesAdjustBroadcastReceiverExist(XmlDocument manifest) + { + var xpath = "/manifest/application/receiver[@android:name='com.adjust.sdk.AdjustReferrerReceiver']"; + return manifest.SelectSingleNode(xpath, GetNamespaceManager(manifest)) != null; + } + + private static List GetCustomRecieverNodes(XmlDocument manifest) + { + var xpath = "/manifest/application/receiver[intent-filter/action[@android:name='com.android.vending.INSTALL_REFERRER']]"; + return new List(manifest.DocumentElement.SelectNodes(xpath, GetNamespaceManager(manifest)).OfType()); + } + + private static void AddAndroidNamespaceAttribute(XmlDocument manifest, string key, string value, XmlElement node) + { + var androidSchemeAttribute = manifest.CreateAttribute("android", key, "http://schemas.android.com/apk/res/android"); + androidSchemeAttribute.InnerText = value; + node.SetAttributeNode(androidSchemeAttribute); + } + + private static XmlNamespaceManager GetNamespaceManager(XmlDocument manifest) + { + var namespaceManager = new XmlNamespaceManager(manifest.NameTable); + namespaceManager.AddNamespace("android", "http://schemas.android.com/apk/res/android"); + return namespaceManager; + } +#endif +} diff --git a/Adjust/Editor/AdjustEditorPreprocessor.cs.meta b/Adjust/Editor/AdjustEditorPreprocessor.cs.meta new file mode 100644 index 0000000..1aa966b --- /dev/null +++ b/Adjust/Editor/AdjustEditorPreprocessor.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: c88a79442bb9342b6956c7d59705f982 +timeCreated: 1621599616 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Editor/AdjustSettings.cs b/Adjust/Editor/AdjustSettings.cs new file mode 100644 index 0000000..ed46907 --- /dev/null +++ b/Adjust/Editor/AdjustSettings.cs @@ -0,0 +1,161 @@ +// Inspired by: https://github.com/facebook/facebook-sdk-for-unity/blob/master/Facebook.Unity.Settings/FacebookSettings.cs + +using System.Collections.Generic; +using UnityEditor; +using UnityEngine; + +public class AdjustSettings : ScriptableObject +{ + private static AdjustSettings instance; + + [SerializeField] + private bool _iOSFrameworkAdSupport = true; + [SerializeField] + private bool _iOSFrameworkAdServices = false; + [SerializeField] + private bool _iOSFrameworkAppTrackingTransparency = false; + [SerializeField] + private bool _iOSFrameworkStoreKit = false; + [SerializeField] + private bool _androidPermissionInternet = true; + [SerializeField] + private bool _androidPermissionInstallReferrerService = true; + [SerializeField] + private bool _androidPermissionAdId = true; + [SerializeField] + private bool _androidPermissionAccessNetworkState = false; + [SerializeField] + private string _iOSUserTrackingUsageDescription; + [SerializeField] + private string _iOSUrlIdentifier; + [SerializeField] + private string[] _iOSUrlSchemes = new string[0]; + [SerializeField] + private string[] _iOSUniversalLinksDomains = new string[0]; + [SerializeField] + private string[] androidUriSchemes = new string[0]; + + public static AdjustSettings Instance + { + get + { + instance = NullableInstance; + + if (instance == null) + { + // Create AdjustSettings.asset inside the folder in which AdjustSettings.cs reside. + instance = ScriptableObject.CreateInstance(); + var guids = AssetDatabase.FindAssets(string.Format("{0} t:script", "AdjustSettings")); + if (guids == null || guids.Length <= 0) + { + return instance; + } +// var assetPath = AssetDatabase.GUIDToAssetPath(guids[0]).Replace("AdjustSettings.cs", "AdjustSettings.asset"); + // ************ Auto fixed by Guru Adjust ************ + if(!System.IO.Directory.Exists("Assets/Guru/Editor")) System.IO.Directory.CreateDirectory("Assets/Guru/Editor"); + var assetPath = "Assets/Guru/Editor/AdjustSettings.asset"; + // ************ Auto fixed by Guru Adjust ************ + AssetDatabase.CreateAsset(instance, assetPath); + } + + return instance; + } + } + + public static AdjustSettings NullableInstance + { + get + { + if (instance == null) + { + var guids = AssetDatabase.FindAssets(string.Format("{0} t:ScriptableObject", "AdjustSettings")); + if (guids == null || guids.Length <= 0) + { + return instance; + } + var assetPath = AssetDatabase.GUIDToAssetPath(guids[0]); + instance = (AdjustSettings)AssetDatabase.LoadAssetAtPath(assetPath, typeof(AdjustSettings)); + } + + return instance; + } + } + + public static bool iOSFrameworkAdSupport + { + get { return Instance._iOSFrameworkAdSupport; } + set { Instance._iOSFrameworkAdSupport = value; } + } + + public static bool iOSFrameworkAdServices + { + get { return Instance._iOSFrameworkAdServices; } + set { Instance._iOSFrameworkAdServices = value; } + } + + public static bool iOSFrameworkAppTrackingTransparency + { + get { return Instance._iOSFrameworkAppTrackingTransparency; } + set { Instance._iOSFrameworkAppTrackingTransparency = value; } + } + + public static bool iOSFrameworkStoreKit + { + get { return Instance._iOSFrameworkStoreKit; } + set { Instance._iOSFrameworkStoreKit = value; } + } + + public static bool androidPermissionInternet + { + get { return Instance._androidPermissionInternet; } + set { Instance._androidPermissionInternet = value; } + } + + public static bool androidPermissionInstallReferrerService + { + get { return Instance._androidPermissionInstallReferrerService; } + set { Instance._androidPermissionInstallReferrerService = value; } + } + + public static bool androidPermissionAdId + { + get { return Instance._androidPermissionAdId; } + set { Instance._androidPermissionAdId = value; } + } + + public static bool androidPermissionAccessNetworkState + { + get { return Instance._androidPermissionAccessNetworkState; } + set { Instance._androidPermissionAccessNetworkState = value; } + } + + public static string iOSUserTrackingUsageDescription + { + get { return Instance._iOSUserTrackingUsageDescription; } + set { Instance._iOSUserTrackingUsageDescription = value; } + } + + public static string iOSUrlIdentifier + { + get { return Instance._iOSUrlIdentifier; } + set { Instance._iOSUrlIdentifier = value; } + } + + public static string[] iOSUrlSchemes + { + get { return Instance._iOSUrlSchemes; } + set { Instance._iOSUrlSchemes = value; } + } + + public static string[] iOSUniversalLinksDomains + { + get { return Instance._iOSUniversalLinksDomains; } + set { Instance._iOSUniversalLinksDomains = value; } + } + + public static string[] AndroidUriSchemes + { + get { return Instance.androidUriSchemes; } + set { Instance.androidUriSchemes = value; } + } +} diff --git a/Adjust/Editor/AdjustSettings.cs.meta b/Adjust/Editor/AdjustSettings.cs.meta new file mode 100644 index 0000000..aefcdd0 --- /dev/null +++ b/Adjust/Editor/AdjustSettings.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: ea4d495dc6d5ba64b90db7afda6a48a4 +timeCreated: 1601333126 +licenseType: Pro +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Editor/AdjustSettingsEditor.cs b/Adjust/Editor/AdjustSettingsEditor.cs new file mode 100644 index 0000000..ec49d76 --- /dev/null +++ b/Adjust/Editor/AdjustSettingsEditor.cs @@ -0,0 +1,126 @@ +using System.Collections.Generic; +using UnityEngine; +using UnityEditor; + +namespace com.adjust.sdk +{ + [CustomEditor(typeof(AdjustSettings))] + public class AdjustSettingsEditor : Editor + { + SerializedProperty iOSFrameworkAdSupport; + SerializedProperty iOSFrameworkAdServices; + SerializedProperty iOSFrameworkAppTrackingTransparency; + SerializedProperty iOSFrameworkStoreKit; + SerializedProperty androidPermissionInternet; + SerializedProperty androidPermissionInstallReferrerService; + SerializedProperty androidPermissionAdId; + SerializedProperty androidPermissionAccessNetworkState; + SerializedProperty iOSUserTrackingUsageDescription; + SerializedProperty iOSUrlIdentifier; + SerializedProperty iOSUrlSchemes; + SerializedProperty iOSUniversalLinksDomains; + SerializedProperty androidUriSchemes; + + void OnEnable() + { + iOSFrameworkAdSupport = serializedObject.FindProperty("_iOSFrameworkAdSupport"); + iOSFrameworkAdServices = serializedObject.FindProperty("_iOSFrameworkAdServices"); + iOSFrameworkAppTrackingTransparency = serializedObject.FindProperty("_iOSFrameworkAppTrackingTransparency"); + iOSFrameworkStoreKit = serializedObject.FindProperty("_iOSFrameworkStoreKit"); + androidPermissionInternet = serializedObject.FindProperty("_androidPermissionInternet"); + androidPermissionInstallReferrerService = serializedObject.FindProperty("_androidPermissionInstallReferrerService"); + androidPermissionAdId = serializedObject.FindProperty("_androidPermissionAdId"); + androidPermissionAccessNetworkState = serializedObject.FindProperty("_androidPermissionAccessNetworkState"); + iOSUserTrackingUsageDescription = serializedObject.FindProperty("_iOSUserTrackingUsageDescription"); + iOSUrlIdentifier = serializedObject.FindProperty("_iOSUrlIdentifier"); + iOSUrlSchemes = serializedObject.FindProperty("_iOSUrlSchemes"); + iOSUniversalLinksDomains = serializedObject.FindProperty("_iOSUniversalLinksDomains"); + androidUriSchemes = serializedObject.FindProperty("androidUriSchemes"); + } + public override void OnInspectorGUI() + { + GUIStyle darkerCyanTextFieldStyles = new GUIStyle(EditorStyles.boldLabel); + darkerCyanTextFieldStyles.normal.textColor = new Color(0f/255f, 190f/255f, 190f/255f); + + EditorGUILayout.Space(); + EditorGUILayout.LabelField("LINK IOS FRAMEWORKS:", darkerCyanTextFieldStyles); + EditorGUI.indentLevel += 1; + EditorGUILayout.PropertyField(iOSFrameworkAdSupport, + new GUIContent("AdSupport.framework", + "iOS framework needed to access IDFA value"), + true); + EditorGUILayout.PropertyField(iOSFrameworkAdServices, + new GUIContent("AdServices.framework", + "iOS framework needed to support AdServices based Apple Search Ads attribution"), + true); + EditorGUILayout.PropertyField(iOSFrameworkAppTrackingTransparency, + new GUIContent("AppTrackingTransparency.framework", + "iOS framework needed to display tracking consent dialog"), + true); + EditorGUILayout.PropertyField(iOSFrameworkStoreKit, + new GUIContent("StoreKit.framework", + "iOS framework needed to use SKAdNetwork capabilities"), + true); + EditorGUI.indentLevel -= 1; + EditorGUILayout.Space(); + EditorGUILayout.LabelField("ADD ANDROID PERMISSIONS:", darkerCyanTextFieldStyles); + EditorGUI.indentLevel += 1; + EditorGUILayout.PropertyField(androidPermissionInternet, + new GUIContent("android.permission.INTERNET", + "Android permission needed to send data to Adjust backend"), + true); + EditorGUILayout.PropertyField(androidPermissionInstallReferrerService, + new GUIContent("com.google.android.finsky.permission.BIND_GET_INSTALL_REFERRER_SERVICE", + "Android permission needed to read install referrer"), + true); + EditorGUILayout.PropertyField(androidPermissionAdId, + new GUIContent("com.google.android.gms.permission.AD_ID", + "Android permission needed to read Google Advertising ID if you target API 33 or later"), + true); + EditorGUILayout.PropertyField(androidPermissionAccessNetworkState, + new GUIContent("android.permission.ACCESS_NETWORK_STATE", + "Android permission needed to determine type of network device is connected to"), + true); + EditorGUI.indentLevel -= 1; + EditorGUILayout.Space(); + EditorGUILayout.LabelField("IOS PRIVACY:", darkerCyanTextFieldStyles); + EditorGUI.indentLevel += 1; + EditorGUILayout.PropertyField(iOSUserTrackingUsageDescription, + new GUIContent("User Tracking Description", + "String you would like to display to your users describing the reason " + + "behind asking for tracking permission."), + true); + EditorGUI.indentLevel -= 1; + EditorGUILayout.Space(); + EditorGUILayout.LabelField("DEEP LINKING:", darkerCyanTextFieldStyles); + EditorGUI.indentLevel += 1; + EditorGUILayout.PropertyField(iOSUrlIdentifier, + new GUIContent("iOS URL Identifier", + "Value of CFBundleURLName property of the root CFBundleURLTypes element. " + + "If not needed otherwise, value should be your bundle ID."), + true); + EditorGUILayout.PropertyField(iOSUrlSchemes, + new GUIContent("iOS URL Schemes", + "URL schemes handled by your app. " + + "Make sure to enter just the scheme name without :// part at the end."), + true); + EditorGUILayout.PropertyField(iOSUniversalLinksDomains, + new GUIContent("iOS Universal Links Domains", + "Associated domains handled by your app. State just the domain part without applinks: part in front."), + true); + EditorGUILayout.PropertyField(androidUriSchemes, + new GUIContent("Android URI Schemes", + "URI schemes handled by your app. " + + "Make sure to enter just the scheme name with :// part at the end."), + true); + EditorGUILayout.HelpBox( + "Please note that Adjust SDK doesn't remove existing URI Schemes, " + + "so if you need to clean previously added entries, " + + "you need to do it manually from \"Assets/Plugins/Android/AndroidManifest.xml\"", + MessageType.Info, + true); + EditorGUI.indentLevel -= 1; + serializedObject.ApplyModifiedProperties(); + } + } +} diff --git a/Adjust/Editor/AdjustSettingsEditor.cs.meta b/Adjust/Editor/AdjustSettingsEditor.cs.meta new file mode 100644 index 0000000..d667ac7 --- /dev/null +++ b/Adjust/Editor/AdjustSettingsEditor.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: e957ffb3938e94bcaab247e46bd9804c +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/ExampleGUI.meta b/Adjust/ExampleGUI.meta new file mode 100644 index 0000000..efca979 --- /dev/null +++ b/Adjust/ExampleGUI.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: c173c46523b75714d945d694e8b89742 +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/ExampleGUI/ExampleGUI.cs b/Adjust/ExampleGUI/ExampleGUI.cs new file mode 100644 index 0000000..57a5490 --- /dev/null +++ b/Adjust/ExampleGUI/ExampleGUI.cs @@ -0,0 +1,290 @@ +using System; +using System.Text; +using System.Collections; +using System.Runtime.InteropServices; +using UnityEngine; +using UnityEngine.UI; +using com.adjust.sdk; + +public class ExampleGUI : MonoBehaviour +{ + private int numberOfButtons = 8; + private bool isEnabled; + private bool showPopUp = false; + private string txtSetEnabled = "Disable SDK"; + private string txtManualLaunch = "Manual Launch"; + private string txtSetOfflineMode = "Turn Offline Mode ON"; + + void OnGUI() + { + if (showPopUp) + { + GUI.Window(0, new Rect((Screen.width / 2) - 150, (Screen.height / 2) - 65, 300, 130), ShowGUI, "Is SDK enabled?"); + } + + if (GUI.Button(new Rect(0, Screen.height * 0 / numberOfButtons, Screen.width, Screen.height / numberOfButtons), txtManualLaunch)) + { + if (!string.Equals(txtManualLaunch, "SDK Launched", StringComparison.OrdinalIgnoreCase)) + { + AdjustConfig adjustConfig = new AdjustConfig("2fm9gkqubvpc", AdjustEnvironment.Sandbox); + adjustConfig.setLogLevel(AdjustLogLevel.Verbose); + adjustConfig.setLogDelegate(msg => Debug.Log(msg)); + adjustConfig.setEventSuccessDelegate(EventSuccessCallback); + adjustConfig.setEventFailureDelegate(EventFailureCallback); + adjustConfig.setSessionSuccessDelegate(SessionSuccessCallback); + adjustConfig.setSessionFailureDelegate(SessionFailureCallback); + adjustConfig.setDeferredDeeplinkDelegate(DeferredDeeplinkCallback); + adjustConfig.setAttributionChangedDelegate(AttributionChangedCallback); + Adjust.start(adjustConfig); + + isEnabled = true; + txtManualLaunch = "SDK Launched"; + } + } + + if (GUI.Button(new Rect(0, Screen.height * 1 / numberOfButtons, Screen.width, Screen.height / numberOfButtons), "Track Simple Event")) + { + AdjustEvent adjustEvent = new AdjustEvent("g3mfiw"); + Adjust.trackEvent(adjustEvent); + } + + if (GUI.Button(new Rect(0, Screen.height * 2 / numberOfButtons, Screen.width, Screen.height / numberOfButtons), "Track Revenue Event")) + { + AdjustEvent adjustEvent = new AdjustEvent("a4fd35"); + adjustEvent.setRevenue(0.25, "EUR"); + Adjust.trackEvent(adjustEvent); + } + + if (GUI.Button(new Rect(0, Screen.height * 3 / numberOfButtons, Screen.width, Screen.height / numberOfButtons), "Track Callback Event")) + { + AdjustEvent adjustEvent = new AdjustEvent("34vgg9"); + adjustEvent.addCallbackParameter("key", "value"); + adjustEvent.addCallbackParameter("foo", "bar"); + Adjust.trackEvent(adjustEvent); + } + + if (GUI.Button(new Rect(0, Screen.height * 4 / numberOfButtons, Screen.width, Screen.height / numberOfButtons), "Track Partner Event")) + { + AdjustEvent adjustEvent = new AdjustEvent("w788qs"); + adjustEvent.addPartnerParameter("key", "value"); + adjustEvent.addPartnerParameter("foo", "bar"); + Adjust.trackEvent(adjustEvent); + } + + if (GUI.Button(new Rect(0, Screen.height * 5 / numberOfButtons, Screen.width, Screen.height / numberOfButtons), txtSetOfflineMode)) + { + if (string.Equals(txtSetOfflineMode, "Turn Offline Mode ON", StringComparison.OrdinalIgnoreCase)) + { + Adjust.setOfflineMode(true); + txtSetOfflineMode = "Turn Offline Mode OFF"; + } + else + { + Adjust.setOfflineMode(false); + txtSetOfflineMode = "Turn Offline Mode ON"; + } + } + + if (GUI.Button(new Rect(0, Screen.height * 6 / numberOfButtons, Screen.width, Screen.height / numberOfButtons), txtSetEnabled)) + { + if (string.Equals(txtSetEnabled, "Disable SDK", StringComparison.OrdinalIgnoreCase)) + { + Adjust.setEnabled(false); + txtSetEnabled = "Enable SDK"; + } + else + { + Adjust.setEnabled(true); + txtSetEnabled = "Disable SDK"; + } + } + + if (GUI.Button(new Rect(0, Screen.height * 7 / numberOfButtons, Screen.width, Screen.height / numberOfButtons), "Is SDK Enabled?")) + { + isEnabled = Adjust.isEnabled(); + showPopUp = true; + } + } + + void ShowGUI(int windowID) + { + if (isEnabled) + { + GUI.Label(new Rect(65, 40, 200, 30), "Adjust SDK is ENABLED!"); + } + else + { + GUI.Label(new Rect(65, 40, 200, 30), "Adjust SDK is DISABLED!"); + } + + if (GUI.Button(new Rect(90, 75, 120, 40), "OK")) + { + showPopUp = false; + } + } + + public void HandleGooglePlayId(String adId) + { + Debug.Log("Google Play Ad ID = " + adId); + } + + public void AttributionChangedCallback(AdjustAttribution attributionData) + { + Debug.Log("Attribution changed!"); + + if (attributionData.trackerName != null) + { + Debug.Log("Tracker name: " + attributionData.trackerName); + } + if (attributionData.trackerToken != null) + { + Debug.Log("Tracker token: " + attributionData.trackerToken); + } + if (attributionData.network != null) + { + Debug.Log("Network: " + attributionData.network); + } + if (attributionData.campaign != null) + { + Debug.Log("Campaign: " + attributionData.campaign); + } + if (attributionData.adgroup != null) + { + Debug.Log("Adgroup: " + attributionData.adgroup); + } + if (attributionData.creative != null) + { + Debug.Log("Creative: " + attributionData.creative); + } + if (attributionData.clickLabel != null) + { + Debug.Log("Click label: " + attributionData.clickLabel); + } + if (attributionData.adid != null) + { + Debug.Log("ADID: " + attributionData.adid); + } + } + + public void EventSuccessCallback(AdjustEventSuccess eventSuccessData) + { + Debug.Log("Event tracked successfully!"); + + if (eventSuccessData.Message != null) + { + Debug.Log("Message: " + eventSuccessData.Message); + } + if (eventSuccessData.Timestamp != null) + { + Debug.Log("Timestamp: " + eventSuccessData.Timestamp); + } + if (eventSuccessData.Adid != null) + { + Debug.Log("Adid: " + eventSuccessData.Adid); + } + if (eventSuccessData.EventToken != null) + { + Debug.Log("EventToken: " + eventSuccessData.EventToken); + } + if (eventSuccessData.CallbackId != null) + { + Debug.Log("CallbackId: " + eventSuccessData.CallbackId); + } + if (eventSuccessData.JsonResponse != null) + { + Debug.Log("JsonResponse: " + eventSuccessData.GetJsonResponse()); + } + } + + public void EventFailureCallback(AdjustEventFailure eventFailureData) + { + Debug.Log("Event tracking failed!"); + + if (eventFailureData.Message != null) + { + Debug.Log("Message: " + eventFailureData.Message); + } + if (eventFailureData.Timestamp != null) + { + Debug.Log("Timestamp: " + eventFailureData.Timestamp); + } + if (eventFailureData.Adid != null) + { + Debug.Log("Adid: " + eventFailureData.Adid); + } + if (eventFailureData.EventToken != null) + { + Debug.Log("EventToken: " + eventFailureData.EventToken); + } + if (eventFailureData.CallbackId != null) + { + Debug.Log("CallbackId: " + eventFailureData.CallbackId); + } + if (eventFailureData.JsonResponse != null) + { + Debug.Log("JsonResponse: " + eventFailureData.GetJsonResponse()); + } + + Debug.Log("WillRetry: " + eventFailureData.WillRetry.ToString()); + } + + public void SessionSuccessCallback(AdjustSessionSuccess sessionSuccessData) + { + Debug.Log("Session tracked successfully!"); + + if (sessionSuccessData.Message != null) + { + Debug.Log("Message: " + sessionSuccessData.Message); + } + if (sessionSuccessData.Timestamp != null) + { + Debug.Log("Timestamp: " + sessionSuccessData.Timestamp); + } + if (sessionSuccessData.Adid != null) + { + Debug.Log("Adid: " + sessionSuccessData.Adid); + } + if (sessionSuccessData.JsonResponse != null) + { + Debug.Log("JsonResponse: " + sessionSuccessData.GetJsonResponse()); + } + } + + public void SessionFailureCallback(AdjustSessionFailure sessionFailureData) + { + Debug.Log("Session tracking failed!"); + + if (sessionFailureData.Message != null) + { + Debug.Log("Message: " + sessionFailureData.Message); + } + if (sessionFailureData.Timestamp != null) + { + Debug.Log("Timestamp: " + sessionFailureData.Timestamp); + } + if (sessionFailureData.Adid != null) + { + Debug.Log("Adid: " + sessionFailureData.Adid); + } + if (sessionFailureData.JsonResponse != null) + { + Debug.Log("JsonResponse: " + sessionFailureData.GetJsonResponse()); + } + + Debug.Log("WillRetry: " + sessionFailureData.WillRetry.ToString()); + } + + private void DeferredDeeplinkCallback(string deeplinkURL) + { + Debug.Log("Deferred deeplink reported!"); + + if (deeplinkURL != null) + { + Debug.Log("Deeplink URL: " + deeplinkURL); + } + else + { + Debug.Log("Deeplink URL is null!"); + } + } +} diff --git a/Adjust/ExampleGUI/ExampleGUI.cs.meta b/Adjust/ExampleGUI/ExampleGUI.cs.meta new file mode 100644 index 0000000..b52508e --- /dev/null +++ b/Adjust/ExampleGUI/ExampleGUI.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 196c5c89d4b1e46dfbf423ae77d31a68 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/ExampleGUI/ExampleGUI.prefab b/Adjust/ExampleGUI/ExampleGUI.prefab new file mode 100644 index 0000000..377b508 --- /dev/null +++ b/Adjust/ExampleGUI/ExampleGUI.prefab @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &100000 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 400000} + - component: {fileID: 11400000} + m_Layer: 0 + m_Name: ExampleGUI + m_TagString: MainCamera + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &400000 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 100000} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 1, z: -10} + 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 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 100000} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 196c5c89d4b1e46dfbf423ae77d31a68, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 100000} + m_IsPrefabParent: 1 diff --git a/Adjust/ExampleGUI/ExampleGUI.prefab.meta b/Adjust/ExampleGUI/ExampleGUI.prefab.meta new file mode 100644 index 0000000..e70eb6c --- /dev/null +++ b/Adjust/ExampleGUI/ExampleGUI.prefab.meta @@ -0,0 +1,4 @@ +fileFormatVersion: 2 +guid: 50b53da2a7a154d63a33a49ad08c24a8 +NativeFormatImporter: + userData: diff --git a/Adjust/ExampleGUI/ExampleGUI.unity b/Adjust/ExampleGUI/ExampleGUI.unity new file mode 100644 index 0000000..5026f26 --- /dev/null +++ b/Adjust/ExampleGUI/ExampleGUI.unity @@ -0,0 +1,292 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!29 &1 +OcclusionCullingSettings: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_OcclusionBakeSettings: + smallestOccluder: 5 + smallestHole: 0.25 + backfaceThreshold: 100 + m_SceneGUID: 00000000000000000000000000000000 + m_OcclusionCullingData: {fileID: 0} +--- !u!104 &2 +RenderSettings: + m_ObjectHideFlags: 0 + serializedVersion: 8 + m_Fog: 0 + m_FogColor: {r: 0.5, g: 0.5, b: 0.5, a: 1} + m_FogMode: 3 + m_FogDensity: 0.01 + m_LinearFogStart: 0 + m_LinearFogEnd: 300 + m_AmbientSkyColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientEquatorColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientGroundColor: {r: 0.2, g: 0.2, b: 0.2, a: 1} + m_AmbientIntensity: 1 + m_AmbientMode: 3 + m_SubtractiveShadowColor: {r: 0.42, g: 0.478, b: 0.627, a: 1} + m_SkyboxMaterial: {fileID: 0} + m_HaloStrength: 0.5 + m_FlareStrength: 1 + m_FlareFadeSpeed: 3 + m_HaloTexture: {fileID: 0} + m_SpotCookie: {fileID: 10001, guid: 0000000000000000e000000000000000, type: 0} + m_DefaultReflectionMode: 0 + m_DefaultReflectionResolution: 128 + m_ReflectionBounces: 1 + m_ReflectionIntensity: 1 + m_CustomReflection: {fileID: 0} + m_Sun: {fileID: 0} + m_IndirectSpecularColor: {r: 0, g: 0, b: 0, a: 1} +--- !u!157 &4 +LightmapSettings: + m_ObjectHideFlags: 0 + serializedVersion: 11 + m_GIWorkflowMode: 1 + m_GISettings: + serializedVersion: 2 + m_BounceScale: 1 + m_IndirectOutputScale: 1 + m_AlbedoBoost: 1 + m_TemporalCoherenceThreshold: 1 + m_EnvironmentLightingMode: 0 + m_EnableBakedLightmaps: 1 + m_EnableRealtimeLightmaps: 0 + m_LightmapEditorSettings: + serializedVersion: 9 + m_Resolution: 1 + m_BakeResolution: 50 + m_TextureWidth: 1024 + m_TextureHeight: 1024 + m_AO: 0 + m_AOMaxDistance: 1 + m_CompAOExponent: 0 + m_CompAOExponentDirect: 0 + m_Padding: 2 + m_LightmapParameters: {fileID: 0} + m_LightmapsBakeMode: 1 + m_TextureCompression: 0 + m_FinalGather: 0 + m_FinalGatherFiltering: 1 + m_FinalGatherRayCount: 1024 + m_ReflectionCompression: 2 + m_MixedBakeMode: 1 + m_BakeBackend: 0 + m_PVRSampling: 1 + m_PVRDirectSampleCount: 32 + m_PVRSampleCount: 500 + m_PVRBounces: 2 + m_PVRFilterTypeDirect: 0 + m_PVRFilterTypeIndirect: 0 + m_PVRFilterTypeAO: 0 + m_PVRFilteringMode: 0 + m_PVRCulling: 1 + m_PVRFilteringGaussRadiusDirect: 1 + m_PVRFilteringGaussRadiusIndirect: 5 + m_PVRFilteringGaussRadiusAO: 2 + m_PVRFilteringAtrousPositionSigmaDirect: 0.5 + m_PVRFilteringAtrousPositionSigmaIndirect: 2 + m_PVRFilteringAtrousPositionSigmaAO: 1 + m_ShowResolutionOverlay: 1 + m_LightingDataAsset: {fileID: 0} + m_UseShadowmask: 0 +--- !u!196 &5 +NavMeshSettings: + serializedVersion: 2 + m_ObjectHideFlags: 0 + m_BuildSettings: + serializedVersion: 2 + agentTypeID: 0 + agentRadius: 0.5 + agentHeight: 2 + agentSlope: 45 + agentClimb: 0.4 + ledgeDropHeight: 0 + maxJumpAcrossDistance: 0 + minRegionArea: 2 + manualCellSize: 0 + cellSize: 0.16666666 + manualTileSize: 0 + tileSize: 256 + accuratePlacement: 0 + debug: + m_Flags: 0 + m_NavMeshData: {fileID: 0} +--- !u!1001 &7284787 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 415478, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 415478, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: m_LocalPosition.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 415478, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 415478, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 415478, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 415478, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 415478, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 415478, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: m_RootOrder + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 11482148, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: startManually + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 11482148, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: logLevel + value: 3 + objectReference: {fileID: 0} + - target: {fileID: 11482148, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + propertyPath: appToken + value: '{YourAppToken}' + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: a3267720e82aa41c1a05ab29824902b4, type: 2} + m_IsPrefabParent: 0 +--- !u!1 &231489158 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + serializedVersion: 5 + m_Component: + - component: {fileID: 231489162} + - component: {fileID: 231489161} + - component: {fileID: 231489160} + - component: {fileID: 231489159} + m_Layer: 0 + m_Name: Camera + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!81 &231489159 +AudioListener: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 231489158} + m_Enabled: 1 +--- !u!124 &231489160 +Behaviour: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 231489158} + m_Enabled: 1 +--- !u!20 &231489161 +Camera: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 231489158} + m_Enabled: 1 + serializedVersion: 2 + m_ClearFlags: 1 + m_BackGroundColor: {r: 0.19215687, g: 0.3019608, b: 0.4745098, a: 0} + m_NormalizedViewPortRect: + serializedVersion: 2 + x: 0 + y: 0 + width: 1 + height: 1 + near clip plane: 0.3 + far clip plane: 1000 + field of view: 60 + orthographic: 0 + orthographic size: 5 + m_Depth: 0 + m_CullingMask: + serializedVersion: 2 + m_Bits: 4294967295 + m_RenderingPath: -1 + m_TargetTexture: {fileID: 0} + m_TargetDisplay: 0 + m_TargetEye: 3 + m_HDR: 1 + m_AllowMSAA: 1 + m_AllowDynamicResolution: 0 + m_ForceIntoRT: 0 + m_OcclusionCulling: 1 + m_StereoConvergence: 10 + m_StereoSeparation: 0.022 +--- !u!4 &231489162 +Transform: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_GameObject: {fileID: 231489158} + 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!1001 &1861285553 +Prefab: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: + - target: {fileID: 400000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + propertyPath: m_LocalPosition.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + propertyPath: m_LocalPosition.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + propertyPath: m_LocalPosition.z + value: -10 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + propertyPath: m_LocalRotation.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + propertyPath: m_LocalRotation.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + propertyPath: m_LocalRotation.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + propertyPath: m_LocalRotation.w + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 400000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 100100000, guid: 50b53da2a7a154d63a33a49ad08c24a8, type: 2} + m_IsPrefabParent: 0 diff --git a/Adjust/ExampleGUI/ExampleGUI.unity.meta b/Adjust/ExampleGUI/ExampleGUI.unity.meta new file mode 100644 index 0000000..60d5d95 --- /dev/null +++ b/Adjust/ExampleGUI/ExampleGUI.unity.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 6aa8afcd558084586bce9f8efd3eb5d6 +timeCreated: 1447689503 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Prefab.meta b/Adjust/Prefab.meta new file mode 100644 index 0000000..6bc38d1 --- /dev/null +++ b/Adjust/Prefab.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0acdd227ad1b8d147ade044242671e15 +folderAsset: yes +timeCreated: 1578652549 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Prefab/Adjust.prefab b/Adjust/Prefab/Adjust.prefab new file mode 100644 index 0000000..394a83f --- /dev/null +++ b/Adjust/Prefab/Adjust.prefab @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &115478 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 415478} + - component: {fileID: 114179903453641630} + m_Layer: 0 + m_Name: Adjust + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &415478 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 115478} + 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!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 115478} + m_IsPrefabParent: 1 +--- !u!114 &114179903453641630 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 115478} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 525ece82a472e4dea837e1ef938fd15d, type: 3} + m_Name: + m_EditorClassIdentifier: + startManually: 1 + appToken: + environment: 0 + logLevel: 3 + eventBuffering: 0 + sendInBackground: 0 + launchDeferredDeeplink: 1 + needsCost: 0 + coppaCompliant: 0 + linkMe: 0 + defaultTracker: + urlStrategy: 0 + startDelay: 0 + secretId: 0 + info1: 0 + info2: 0 + info3: 0 + info4: 0 + preinstallTracking: 0 + preinstallFilePath: + playStoreKidsApp: 0 + adServicesInfoReading: 1 + idfaInfoReading: 1 + skAdNetworkHandling: 1 diff --git a/Adjust/Prefab/Adjust.prefab.meta b/Adjust/Prefab/Adjust.prefab.meta new file mode 100644 index 0000000..ca66937 --- /dev/null +++ b/Adjust/Prefab/Adjust.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a3267720e82aa41c1a05ab29824902b4 +NativeFormatImporter: + mainObjectFileID: -1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity.meta b/Adjust/Unity.meta new file mode 100644 index 0000000..bf99afe --- /dev/null +++ b/Adjust/Unity.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 1ac00d53de34e29419cae749db3f6528 +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/Adjust.cs b/Adjust/Unity/Adjust.cs new file mode 100644 index 0000000..fc7ef1d --- /dev/null +++ b/Adjust/Unity/Adjust.cs @@ -0,0 +1,1211 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace com.adjust.sdk +{ + public class Adjust : MonoBehaviour + { + private const string errorMsgEditor = "[Adjust]: SDK can not be used in Editor."; + private const string errorMsgStart = "[Adjust]: SDK not started. Start it manually using the 'start' method."; + private const string errorMsgPlatform = "[Adjust]: SDK can only be used in Android, iOS, Windows Phone 8.1, Windows Store or Universal Windows apps."; + + // [Header("SDK SETTINGS:")] + // [Space(5)] + // [Tooltip("If selected, it is expected from you to initialize Adjust SDK from your app code. " + + // "Any SDK configuration settings from prefab will be ignored in that case.")] + [HideInInspector] + public bool startManually = true; + [HideInInspector] + public string appToken; + [HideInInspector] + public AdjustEnvironment environment = AdjustEnvironment.Sandbox; + [HideInInspector] + public AdjustLogLevel logLevel = AdjustLogLevel.Info; + [HideInInspector] + public bool eventBuffering = false; + [HideInInspector] + public bool sendInBackground = false; + [HideInInspector] + public bool launchDeferredDeeplink = true; + [HideInInspector] + public bool needsCost = false; + [HideInInspector] + public bool coppaCompliant = false; + [HideInInspector] + public bool linkMe = false; + [HideInInspector] + public string defaultTracker; + [HideInInspector] + public AdjustUrlStrategy urlStrategy = AdjustUrlStrategy.Default; + [HideInInspector] + public double startDelay = 0; + + // [Header("APP SECRET:")] + // [Space(5)] + [HideInInspector] + public long secretId = 0; + [HideInInspector] + public long info1 = 0; + [HideInInspector] + public long info2 = 0; + [HideInInspector] + public long info3 = 0; + [HideInInspector] + public long info4 = 0; + + // [Header("ANDROID SPECIFIC FEATURES:")] + // [Space(5)] + [HideInInspector] + public bool preinstallTracking = false; + [HideInInspector] + public string preinstallFilePath; + [HideInInspector] + public bool playStoreKidsApp = false; + + // [Header("iOS SPECIFIC FEATURES:")] + // [Space(5)] + [HideInInspector] + public bool adServicesInfoReading = true; + [HideInInspector] + public bool idfaInfoReading = true; + [HideInInspector] + public bool skAdNetworkHandling = true; + +#if UNITY_IOS + // Delegate references for iOS callback triggering + private static List> authorizationStatusDelegates = null; + private static Action deferredDeeplinkDelegate = null; + private static Action eventSuccessDelegate = null; + private static Action eventFailureDelegate = null; + private static Action sessionSuccessDelegate = null; + private static Action sessionFailureDelegate = null; + private static Action attributionChangedDelegate = null; + private static Action conversionValueUpdatedDelegate = null; + private static Action skad4ConversionValueUpdatedDelegate = null; + private static Action skadUpdateConversionValueDelegate = null; + private static Action skad4UpdateConversionValueDelegate = null; + private static Action verificationInfoDelegate = null; +#endif + + void Awake() + { + if (IsEditor()) + { + return; + } + + DontDestroyOnLoad(transform.gameObject); + +#if UNITY_ANDROID && UNITY_2019_2_OR_NEWER + Application.deepLinkActivated += Adjust.appWillOpenUrl; + if (!string.IsNullOrEmpty(Application.absoluteURL)) + { + // Cold start and Application.absoluteURL not null so process Deep Link. + Adjust.appWillOpenUrl(Application.absoluteURL); + } +#endif + + if (!this.startManually) + { + AdjustConfig adjustConfig = new AdjustConfig(this.appToken, this.environment, (this.logLevel == AdjustLogLevel.Suppress)); + adjustConfig.setLogLevel(this.logLevel); + adjustConfig.setSendInBackground(this.sendInBackground); + adjustConfig.setEventBufferingEnabled(this.eventBuffering); + adjustConfig.setLaunchDeferredDeeplink(this.launchDeferredDeeplink); + adjustConfig.setDefaultTracker(this.defaultTracker); + adjustConfig.setUrlStrategy(this.urlStrategy.ToLowerCaseString()); + adjustConfig.setAppSecret(this.secretId, this.info1, this.info2, this.info3, this.info4); + adjustConfig.setDelayStart(this.startDelay); + adjustConfig.setNeedsCost(this.needsCost); + adjustConfig.setPreinstallTrackingEnabled(this.preinstallTracking); + adjustConfig.setPreinstallFilePath(this.preinstallFilePath); + adjustConfig.setAllowAdServicesInfoReading(this.adServicesInfoReading); + adjustConfig.setAllowIdfaReading(this.idfaInfoReading); + adjustConfig.setCoppaCompliantEnabled(this.coppaCompliant); + adjustConfig.setPlayStoreKidsAppEnabled(this.playStoreKidsApp); + adjustConfig.setLinkMeEnabled(this.linkMe); + if (!skAdNetworkHandling) + { + adjustConfig.deactivateSKAdNetworkHandling(); + } + Adjust.start(adjustConfig); + } + } + + void OnApplicationPause(bool pauseStatus) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + // No action, iOS SDK is subscribed to iOS lifecycle notifications. +#elif UNITY_ANDROID + if (pauseStatus) + { + AdjustAndroid.OnPause(); + } + else + { + AdjustAndroid.OnResume(); + } +#elif (UNITY_WSA || UNITY_WP8) + if (pauseStatus) + { + AdjustWindows.OnPause(); + } + else + { + AdjustWindows.OnResume(); + } +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void start(AdjustConfig adjustConfig) + { + if (IsEditor()) + { + return; + } + + if (adjustConfig == null) + { + Debug.Log("[Adjust]: Missing config to start."); + return; + } + +#if UNITY_IOS + Adjust.eventSuccessDelegate = adjustConfig.getEventSuccessDelegate(); + Adjust.eventFailureDelegate = adjustConfig.getEventFailureDelegate(); + Adjust.sessionSuccessDelegate = adjustConfig.getSessionSuccessDelegate(); + Adjust.sessionFailureDelegate = adjustConfig.getSessionFailureDelegate(); + Adjust.deferredDeeplinkDelegate = adjustConfig.getDeferredDeeplinkDelegate(); + Adjust.attributionChangedDelegate = adjustConfig.getAttributionChangedDelegate(); + Adjust.conversionValueUpdatedDelegate = adjustConfig.getConversionValueUpdatedDelegate(); + Adjust.skad4ConversionValueUpdatedDelegate = adjustConfig.getSkad4ConversionValueUpdatedDelegate(); + AdjustiOS.Start(adjustConfig); +#elif UNITY_ANDROID + AdjustAndroid.Start(adjustConfig); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.Start(adjustConfig); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void trackEvent(AdjustEvent adjustEvent) + { + if (IsEditor()) + { + return; + } + + if (adjustEvent == null) + { + Debug.Log("[Adjust]: Missing event to track."); + return; + } +#if UNITY_IOS + AdjustiOS.TrackEvent(adjustEvent); +#elif UNITY_ANDROID + AdjustAndroid.TrackEvent(adjustEvent); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.TrackEvent(adjustEvent); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void setEnabled(bool enabled) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.SetEnabled(enabled); +#elif UNITY_ANDROID + AdjustAndroid.SetEnabled(enabled); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SetEnabled(enabled); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static bool isEnabled() + { + if (IsEditor()) + { + return false; + } + +#if UNITY_IOS + return AdjustiOS.IsEnabled(); +#elif UNITY_ANDROID + return AdjustAndroid.IsEnabled(); +#elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.IsEnabled(); +#else + Debug.Log(errorMsgPlatform); + return false; +#endif + } + + public static void setOfflineMode(bool enabled) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.SetOfflineMode(enabled); +#elif UNITY_ANDROID + AdjustAndroid.SetOfflineMode(enabled); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SetOfflineMode(enabled); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void setDeviceToken(string deviceToken) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.SetDeviceToken(deviceToken); +#elif UNITY_ANDROID + AdjustAndroid.SetDeviceToken(deviceToken); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SetDeviceToken(deviceToken); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void gdprForgetMe() + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.GdprForgetMe(); +#elif UNITY_ANDROID + AdjustAndroid.GdprForgetMe(); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.GdprForgetMe(); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void disableThirdPartySharing() + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.DisableThirdPartySharing(); +#elif UNITY_ANDROID + AdjustAndroid.DisableThirdPartySharing(); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Disable third party sharing is only supported for Android and iOS platforms."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void appWillOpenUrl(string url) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.AppWillOpenUrl(url); +#elif UNITY_ANDROID + AdjustAndroid.AppWillOpenUrl(url); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.AppWillOpenUrl(url); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void sendFirstPackages() + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.SendFirstPackages(); +#elif UNITY_ANDROID + AdjustAndroid.SendFirstPackages(); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SendFirstPackages(); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void addSessionPartnerParameter(string key, string value) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.AddSessionPartnerParameter(key, value); +#elif UNITY_ANDROID + AdjustAndroid.AddSessionPartnerParameter(key, value); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.AddSessionPartnerParameter(key, value); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void addSessionCallbackParameter(string key, string value) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.AddSessionCallbackParameter(key, value); +#elif UNITY_ANDROID + AdjustAndroid.AddSessionCallbackParameter(key, value); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.AddSessionCallbackParameter(key, value); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void removeSessionPartnerParameter(string key) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.RemoveSessionPartnerParameter(key); +#elif UNITY_ANDROID + AdjustAndroid.RemoveSessionPartnerParameter(key); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.RemoveSessionPartnerParameter(key); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void removeSessionCallbackParameter(string key) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.RemoveSessionCallbackParameter(key); +#elif UNITY_ANDROID + AdjustAndroid.RemoveSessionCallbackParameter(key); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.RemoveSessionCallbackParameter(key); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void resetSessionPartnerParameters() + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.ResetSessionPartnerParameters(); +#elif UNITY_ANDROID + AdjustAndroid.ResetSessionPartnerParameters(); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.ResetSessionPartnerParameters(); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void resetSessionCallbackParameters() + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.ResetSessionCallbackParameters(); +#elif UNITY_ANDROID + AdjustAndroid.ResetSessionCallbackParameters(); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.ResetSessionCallbackParameters(); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void trackAdRevenue(string source, string payload) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.TrackAdRevenue(source, payload); +#elif UNITY_ANDROID + AdjustAndroid.TrackAdRevenue(source, payload); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Ad revenue tracking is only supported for Android and iOS platforms."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void trackAdRevenue(AdjustAdRevenue adRevenue) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.TrackAdRevenue(adRevenue); +#elif UNITY_ANDROID + AdjustAndroid.TrackAdRevenue(adRevenue); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Ad revenue tracking is only supported for Android and iOS platforms."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void trackAppStoreSubscription(AdjustAppStoreSubscription subscription) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.TrackAppStoreSubscription(subscription); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: App Store subscription tracking is only supported for iOS platform."); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: App Store subscription tracking is only supported for iOS platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void trackPlayStoreSubscription(AdjustPlayStoreSubscription subscription) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + Debug.Log("[Adjust]: Play Store subscription tracking is only supported for Android platform."); +#elif UNITY_ANDROID + AdjustAndroid.TrackPlayStoreSubscription(subscription); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Play Store subscription tracking is only supported for Android platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void trackThirdPartySharing(AdjustThirdPartySharing thirdPartySharing) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.TrackThirdPartySharing(thirdPartySharing); +#elif UNITY_ANDROID + AdjustAndroid.TrackThirdPartySharing(thirdPartySharing); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Third party sharing tracking is only supported for iOS and Android platforms."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void trackMeasurementConsent(bool measurementConsent) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.TrackMeasurementConsent(measurementConsent); +#elif UNITY_ANDROID + AdjustAndroid.TrackMeasurementConsent(measurementConsent); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Measurement consent tracking is only supported for iOS and Android platforms."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void requestTrackingAuthorizationWithCompletionHandler(Action statusCallback, string sceneName = "Adjust") + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + if (Adjust.authorizationStatusDelegates == null) + { + Adjust.authorizationStatusDelegates = new List>(); + } + Adjust.authorizationStatusDelegates.Add(statusCallback); + AdjustiOS.RequestTrackingAuthorizationWithCompletionHandler(sceneName); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Requesting tracking authorization is only supported for iOS platform."); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Requesting tracking authorization is only supported for iOS platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void updateConversionValue(int conversionValue) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.UpdateConversionValue(conversionValue); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Updating SKAdNetwork conversion value is only supported for iOS platform."); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Updating SKAdNetwork conversion value is only supported for iOS platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void updateConversionValue(int conversionValue, Action completionCallback, string sceneName = "Adjust") + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + Adjust.skadUpdateConversionValueDelegate = completionCallback; + AdjustiOS.UpdateConversionValue(conversionValue, sceneName); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Updating SKAdNetwork conversion value is only supported for iOS platform."); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Updating SKAdNetwork conversion value is only supported for iOS platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void updateConversionValue(int conversionValue, string coarseValue, bool lockWindow, Action completionCallback, string sceneName = "Adjust") + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + Adjust.skad4UpdateConversionValueDelegate = completionCallback; + AdjustiOS.UpdateConversionValue(conversionValue, coarseValue, lockWindow, sceneName); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Updating SKAdNetwork conversion value is only supported for iOS platform."); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Updating SKAdNetwork conversion value is only supported for iOS platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void checkForNewAttStatus() + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.CheckForNewAttStatus(); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Checking for new ATT status is only supported for iOS platform."); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Checking for new ATT status is only supported for iOS platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static int getAppTrackingAuthorizationStatus() + { + if (IsEditor()) + { + return -1; + } + +#if UNITY_IOS + return AdjustiOS.GetAppTrackingAuthorizationStatus(); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Error! App tracking authorization status is only supported for iOS platform."); + return -1; +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Error! App tracking authorization status is only supported for iOS platform."); + return -1; +#else + Debug.Log(errorMsgPlatform); + return -1; +#endif + } + + public static string getAdid() + { + if (IsEditor()) + { + return string.Empty; + } + +#if UNITY_IOS + return AdjustiOS.GetAdid(); +#elif UNITY_ANDROID + return AdjustAndroid.GetAdid(); +#elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.GetAdid(); +#else + Debug.Log(errorMsgPlatform); + return string.Empty; +#endif + } + + public static AdjustAttribution getAttribution() + { + if (IsEditor()) + { + return null; + } + +#if UNITY_IOS + return AdjustiOS.GetAttribution(); +#elif UNITY_ANDROID + return AdjustAndroid.GetAttribution(); +#elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.GetAttribution(); +#else + Debug.Log(errorMsgPlatform); + return null; +#endif + } + + public static string getWinAdid() + { + if (IsEditor()) + { + return string.Empty; + } + +#if UNITY_IOS + Debug.Log("[Adjust]: Error! Windows Advertising ID is not available on iOS platform."); + return string.Empty; +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Error! Windows Advertising ID is not available on Android platform."); + return string.Empty; +#elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.GetWinAdId(); +#else + Debug.Log(errorMsgPlatform); + return string.Empty; +#endif + } + + public static string getIdfa() + { + if (IsEditor()) + { + return string.Empty; + } + +#if UNITY_IOS + return AdjustiOS.GetIdfa(); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Error! IDFA is not available on Android platform."); + return string.Empty; +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Error! IDFA is not available on Windows platform."); + return string.Empty; +#else + Debug.Log(errorMsgPlatform); + return string.Empty; +#endif + } + + public static string getIdfv() + { + if (IsEditor()) + { + return string.Empty; + } + +#if UNITY_IOS + return AdjustiOS.GetIdfv(); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Error! IDFV is not available on Android platform."); + return string.Empty; +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Error! IDFV is not available on Windows platform."); + return string.Empty; +#else + Debug.Log(errorMsgPlatform); + return string.Empty; +#endif + } + + public static string getSdkVersion() + { + if (IsEditor()) + { + return string.Empty; + } + +#if UNITY_IOS + return AdjustiOS.GetSdkVersion(); +#elif UNITY_ANDROID + return AdjustAndroid.GetSdkVersion(); +#elif (UNITY_WSA || UNITY_WP8) + return AdjustWindows.GetSdkVersion(); +#else + Debug.Log(errorMsgPlatform); + return string.Empty; +#endif + } + + [Obsolete("This method is intended for testing purposes only. Do not use it.")] + public static void setReferrer(string referrer) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + Debug.Log("[Adjust]: Install referrer is not available on iOS platform."); +#elif UNITY_ANDROID + AdjustAndroid.SetReferrer(referrer); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Error! Install referrer is not available on Windows platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void getGoogleAdId(Action onDeviceIdsRead) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + Debug.Log("[Adjust]: Google Play Advertising ID is not available on iOS platform."); + onDeviceIdsRead(string.Empty); +#elif UNITY_ANDROID + AdjustAndroid.GetGoogleAdId(onDeviceIdsRead); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Google Play Advertising ID is not available on Windows platform."); + onDeviceIdsRead(string.Empty); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static string getAmazonAdId() + { + if (IsEditor()) + { + return string.Empty; + } + +#if UNITY_IOS + Debug.Log("[Adjust]: Amazon Advertising ID is not available on iOS platform."); + return string.Empty; +#elif UNITY_ANDROID + return AdjustAndroid.GetAmazonAdId(); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Amazon Advertising ID not available on Windows platform."); + return string.Empty; +#else + Debug.Log(errorMsgPlatform); + return string.Empty; +#endif + } + + public static string getLastDeeplink() + { + if (IsEditor()) + { + return string.Empty; + } + +#if UNITY_IOS + return AdjustiOS.GetLastDeeplink(); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: Error! Last deeplink getter is not available on Android platform."); + return string.Empty; +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Error! Last deeplink getter is not available on Windows platform."); + return string.Empty; +#else + Debug.Log(errorMsgPlatform); + return string.Empty; +#endif + } + + public static void verifyAppStorePurchase( + AdjustAppStorePurchase purchase, + Action verificationInfoDelegate, + string sceneName = "Adjust") + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + if (purchase == null || + purchase.transactionId == null || + purchase.productId == null || + purchase.receipt == null) + { + Debug.Log("[Adjust]: Invalid App Store purchase parameters."); + return; + } + + Adjust.verificationInfoDelegate = verificationInfoDelegate; + AdjustiOS.VerifyAppStorePurchase(purchase, sceneName); +#elif UNITY_ANDROID + Debug.Log("[Adjust]: App Store purchase verification is only supported for iOS platform."); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: App Store purchase verification is only supported for iOS platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + + public static void verifyPlayStorePurchase( + AdjustPlayStorePurchase purchase, + Action verificationInfoDelegate) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + Debug.Log("[Adjust]: Play Store purchase verification is only supported for Android platform."); +#elif UNITY_ANDROID + if (purchase == null || + purchase.productId == null || + purchase.purchaseToken == null) + { + Debug.Log("[Adjust]: Invalid Play Store purchase parameters."); + return; + } + + AdjustAndroid.VerifyPlayStorePurchase(purchase, verificationInfoDelegate); +#elif (UNITY_WSA || UNITY_WP8) + Debug.Log("[Adjust]: Play Store purchase verification is only supported for Android platform."); +#else + Debug.Log(errorMsgPlatform); +#endif + } + +#if UNITY_IOS + public void GetNativeAttribution(string attributionData) + { + if (IsEditor()) + { + return; + } + + if (Adjust.attributionChangedDelegate == null) + { + Debug.Log("[Adjust]: Attribution changed delegate was not set."); + return; + } + + var attribution = new AdjustAttribution(attributionData); + Adjust.attributionChangedDelegate(attribution); + } + + public void GetNativeEventSuccess(string eventSuccessData) + { + if (IsEditor()) + { + return; + } + + if (Adjust.eventSuccessDelegate == null) + { + Debug.Log("[Adjust]: Event success delegate was not set."); + return; + } + + var eventSuccess = new AdjustEventSuccess(eventSuccessData); + Adjust.eventSuccessDelegate(eventSuccess); + } + + public void GetNativeEventFailure(string eventFailureData) + { + if (IsEditor()) + { + return; + } + + if (Adjust.eventFailureDelegate == null) + { + Debug.Log("[Adjust]: Event failure delegate was not set."); + return; + } + + var eventFailure = new AdjustEventFailure(eventFailureData); + Adjust.eventFailureDelegate(eventFailure); + } + + public void GetNativeSessionSuccess(string sessionSuccessData) + { + if (IsEditor()) + { + return; + } + + if (Adjust.sessionSuccessDelegate == null) + { + Debug.Log("[Adjust]: Session success delegate was not set."); + return; + } + + var sessionSuccess = new AdjustSessionSuccess(sessionSuccessData); + Adjust.sessionSuccessDelegate(sessionSuccess); + } + + public void GetNativeSessionFailure(string sessionFailureData) + { + if (IsEditor()) + { + return; + } + + if (Adjust.sessionFailureDelegate == null) + { + Debug.Log("[Adjust]: Session failure delegate was not set."); + return; + } + + var sessionFailure = new AdjustSessionFailure(sessionFailureData); + Adjust.sessionFailureDelegate(sessionFailure); + } + + public void GetNativeDeferredDeeplink(string deeplinkURL) + { + if (IsEditor()) + { + return; + } + + if (Adjust.deferredDeeplinkDelegate == null) + { + Debug.Log("[Adjust]: Deferred deeplink delegate was not set."); + return; + } + + Adjust.deferredDeeplinkDelegate(deeplinkURL); + } + + public void GetNativeConversionValueUpdated(string conversionValue) + { + if (IsEditor()) + { + return; + } + + if (Adjust.conversionValueUpdatedDelegate == null) + { + Debug.Log("[Adjust]: Conversion value updated delegate was not set."); + return; + } + + int cv = -1; + if (Int32.TryParse(conversionValue, out cv)) + { + if (cv != -1) + { + Adjust.conversionValueUpdatedDelegate(cv); + } + } + } + + public void GetNativeSkad4ConversionValueUpdated(string conversionValueUpdate) + { + if (IsEditor()) + { + return; + } + + if (Adjust.skad4ConversionValueUpdatedDelegate == null) + { + Debug.Log("[Adjust]: SKAD4 Conversion value updated delegate was not set."); + return; + } + + int conversionValue = AdjustUtils.GetSkad4ConversionValue(conversionValueUpdate); + string coarseValue = AdjustUtils.GetSkad4CoarseValue(conversionValueUpdate); + bool lockWindow = AdjustUtils.GetSkad4LockWindow(conversionValueUpdate); + + Adjust.skad4ConversionValueUpdatedDelegate(conversionValue, coarseValue, lockWindow); + } + + public void GetNativeSkadCompletionDelegate(string message) + { + if (IsEditor()) + { + return; + } + + if (Adjust.skadUpdateConversionValueDelegate == null) + { + Debug.Log("[Adjust]: SKAD completion delegate was not set."); + return; + } + + if (message != null) + { + Adjust.skadUpdateConversionValueDelegate(message); + } + } + + public void GetNativeSkad4CompletionDelegate(string message) + { + if (IsEditor()) + { + return; + } + + if (Adjust.skad4UpdateConversionValueDelegate == null) + { + Debug.Log("[Adjust]: SKAD4 completion delegate was not set."); + return; + } + + if (message != null) + { + Adjust.skad4UpdateConversionValueDelegate(message); + } + } + + public void GetAuthorizationStatus(string authorizationStatus) + { + if (IsEditor()) + { + return; + } + + if (Adjust.authorizationStatusDelegates == null) + { + Debug.Log("[Adjust]: Authorization status delegates were not set."); + return; + } + + foreach (Action callback in Adjust.authorizationStatusDelegates) + { + callback(Int16.Parse(authorizationStatus)); + } + Adjust.authorizationStatusDelegates.Clear(); + } + + public void GetNativeVerificationInfo(string verificationInfoData) + { + if (IsEditor()) + { + return; + } + + if (Adjust.verificationInfoDelegate == null) + { + Debug.Log("[Adjust]: Purchase verification info delegate was not set."); + return; + } + + var verificationInfo = new AdjustPurchaseVerificationInfo(verificationInfoData); + Adjust.verificationInfoDelegate(verificationInfo); + } +#endif + + private static bool IsEditor() + { +#if UNITY_EDITOR + Debug.Log(errorMsgEditor); + return true; +#else + return false; +#endif + } + + public static void SetTestOptions(Dictionary testOptions) + { + if (IsEditor()) + { + return; + } + +#if UNITY_IOS + AdjustiOS.SetTestOptions(testOptions); +#elif UNITY_ANDROID + AdjustAndroid.SetTestOptions(testOptions); +#elif (UNITY_WSA || UNITY_WP8) + AdjustWindows.SetTestOptions(testOptions); +#else + Debug.Log("[Adjust]: Cannot run integration tests. None of the supported platforms selected."); +#endif + } + } +} diff --git a/Adjust/Unity/Adjust.cs.meta b/Adjust/Unity/Adjust.cs.meta new file mode 100644 index 0000000..08f7cad --- /dev/null +++ b/Adjust/Unity/Adjust.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 525ece82a472e4dea837e1ef938fd15d +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Unity/AdjustAdRevenue.cs b/Adjust/Unity/AdjustAdRevenue.cs new file mode 100644 index 0000000..95d3e2b --- /dev/null +++ b/Adjust/Unity/AdjustAdRevenue.cs @@ -0,0 +1,69 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustAdRevenue + { + internal string source; + internal double? revenue; + internal string currency; + internal int? adImpressionsCount; + internal string adRevenueNetwork; + internal string adRevenueUnit; + internal string adRevenuePlacement; + internal List partnerList; + internal List callbackList; + + public AdjustAdRevenue(string source) + { + this.source = source; + } + + public void setRevenue(double amount, string currency) + { + this.revenue = amount; + this.currency = currency; + } + + public void setAdImpressionsCount(int adImpressionsCount) + { + this.adImpressionsCount = adImpressionsCount; + } + + public void setAdRevenueNetwork(string adRevenueNetwork) + { + this.adRevenueNetwork = adRevenueNetwork; + } + + public void setAdRevenueUnit(string adRevenueUnit) + { + this.adRevenueUnit = adRevenueUnit; + } + + public void setAdRevenuePlacement(string adRevenuePlacement) + { + this.adRevenuePlacement = adRevenuePlacement; + } + + public void addCallbackParameter(string key, string value) + { + if (callbackList == null) + { + callbackList = new List(); + } + callbackList.Add(key); + callbackList.Add(value); + } + + public void addPartnerParameter(string key, string value) + { + if (partnerList == null) + { + partnerList = new List(); + } + partnerList.Add(key); + partnerList.Add(value); + } + } +} diff --git a/Adjust/Unity/AdjustAdRevenue.cs.meta b/Adjust/Unity/AdjustAdRevenue.cs.meta new file mode 100644 index 0000000..bb3834f --- /dev/null +++ b/Adjust/Unity/AdjustAdRevenue.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 776a9d4b715bc44c68724248a5a75cb9 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustAppStorePurchase.cs b/Adjust/Unity/AdjustAppStorePurchase.cs new file mode 100644 index 0000000..8add7af --- /dev/null +++ b/Adjust/Unity/AdjustAppStorePurchase.cs @@ -0,0 +1,19 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustAppStorePurchase + { + internal string transactionId; + internal string productId; + internal string receipt; + + public AdjustAppStorePurchase(string transactionId, string productId, string receipt) + { + this.transactionId = transactionId; + this.productId = productId; + this.receipt = receipt; + } + } +} diff --git a/Adjust/Unity/AdjustAppStorePurchase.cs.meta b/Adjust/Unity/AdjustAppStorePurchase.cs.meta new file mode 100644 index 0000000..dbd826d --- /dev/null +++ b/Adjust/Unity/AdjustAppStorePurchase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 828a981c8c96741afa5d16ccb679e5af +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustAppStoreSubscription.cs b/Adjust/Unity/AdjustAppStoreSubscription.cs new file mode 100644 index 0000000..73ec83a --- /dev/null +++ b/Adjust/Unity/AdjustAppStoreSubscription.cs @@ -0,0 +1,56 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustAppStoreSubscription + { + internal string price; + internal string currency; + internal string transactionId; + internal string receipt; + internal string billingStore; + internal string transactionDate; + internal string salesRegion; + internal List partnerList; + internal List callbackList; + + public AdjustAppStoreSubscription(string price, string currency, string transactionId, string receipt) + { + this.price = price; + this.currency = currency; + this.transactionId = transactionId; + this.receipt = receipt; + } + + public void setTransactionDate(string transactionDate) + { + this.transactionDate = transactionDate; + } + + public void setSalesRegion(string salesRegion) + { + this.salesRegion = salesRegion; + } + + public void addCallbackParameter(string key, string value) + { + if (callbackList == null) + { + callbackList = new List(); + } + callbackList.Add(key); + callbackList.Add(value); + } + + public void addPartnerParameter(string key, string value) + { + if (partnerList == null) + { + partnerList = new List(); + } + partnerList.Add(key); + partnerList.Add(value); + } + } +} diff --git a/Adjust/Unity/AdjustAppStoreSubscription.cs.meta b/Adjust/Unity/AdjustAppStoreSubscription.cs.meta new file mode 100644 index 0000000..f5af330 --- /dev/null +++ b/Adjust/Unity/AdjustAppStoreSubscription.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 7e2d69221b1124370a4c016edce5a95a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustAttribution.cs b/Adjust/Unity/AdjustAttribution.cs new file mode 100644 index 0000000..3373887 --- /dev/null +++ b/Adjust/Unity/AdjustAttribution.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustAttribution + { + public string adid { get; set; } + public string network { get; set; } + public string adgroup { get; set; } + public string campaign { get; set; } + public string creative { get; set; } + public string clickLabel { get; set; } + public string trackerName { get; set; } + public string trackerToken { get; set; } + public string costType { get; set; } + public double? costAmount { get; set; } + public string costCurrency { get; set; } + // Android only + public string fbInstallReferrer { get; set; } + + public AdjustAttribution() {} + + public AdjustAttribution(string jsonString) + { + var jsonNode = JSON.Parse(jsonString); + if (jsonNode == null) + { + return; + } + + trackerName = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyTrackerName); + trackerToken = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyTrackerToken); + network = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyNetwork); + campaign = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCampaign); + adgroup = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdgroup); + creative = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCreative); + clickLabel = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyClickLabel); + adid = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdid); + costType = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCostType); + try + { + costAmount = double.Parse(AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCostAmount), + System.Globalization.CultureInfo.InvariantCulture); + } + catch (Exception) + { + // attribution response doesn't contain cost amount attached + // value will default to null + } + costCurrency = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCostCurrency); + fbInstallReferrer = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyFbInstallReferrer); + } + + public AdjustAttribution(Dictionary dicAttributionData) + { + if (dicAttributionData == null) + { + return; + } + + trackerName = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyTrackerName); + trackerToken = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyTrackerToken); + network = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyNetwork); + campaign = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCampaign); + adgroup = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyAdgroup); + creative = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCreative); + clickLabel = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyClickLabel); + adid = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyAdid); + costType = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCostType); + try + { + costAmount = double.Parse(AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCostAmount), + System.Globalization.CultureInfo.InvariantCulture); + } + catch (Exception) + { + // attribution response doesn't contain cost amount attached + // value will default to null + } + costCurrency = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyCostCurrency); + fbInstallReferrer = AdjustUtils.TryGetValue(dicAttributionData, AdjustUtils.KeyFbInstallReferrer); + } + } +} diff --git a/Adjust/Unity/AdjustAttribution.cs.meta b/Adjust/Unity/AdjustAttribution.cs.meta new file mode 100644 index 0000000..37c4bbd --- /dev/null +++ b/Adjust/Unity/AdjustAttribution.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cc46748ad0e664f6d839a4f1a23d9f47 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Unity/AdjustConfig.cs b/Adjust/Unity/AdjustConfig.cs new file mode 100644 index 0000000..e3629d8 --- /dev/null +++ b/Adjust/Unity/AdjustConfig.cs @@ -0,0 +1,328 @@ +using System; + +namespace com.adjust.sdk +{ + public class AdjustConfig + { + public const string AdjustUrlStrategyChina = "china"; + public const string AdjustUrlStrategyIndia = "india"; + public const string AdjustUrlStrategyCn = "cn"; + public const string AdjustUrlStrategyCnOnly = "cn-only"; + + public const string AdjustDataResidencyEU = "data-residency-eu"; + public const string AdjustDataResidencyTR = "data-residency-tr"; + public const string AdjustDataResidencyUS = "data-residency-us"; + + public const string AdjustAdRevenueSourceAppLovinMAX = "applovin_max_sdk"; + public const string AdjustAdRevenueSourceMopub = "mopub"; + public const string AdjustAdRevenueSourceAdMob = "admob_sdk"; + public const string AdjustAdRevenueSourceIronSource = "ironsource_sdk"; + public const string AdjustAdRevenueSourceAdmost = "admost_sdk"; + public const string AdjustAdRevenueSourceUnity = "unity_sdk"; + public const string AdjustAdRevenueSourceHeliumChartboost = "helium_chartboost_sdk"; + public const string AdjustAdRevenueSourcePublisher = "publisher_sdk"; + public const string AdjustAdRevenueSourceTopOn = "topon_sdk"; + public const string AdjustAdRevenueSourceAdx = "adx_sdk"; + + internal string appToken; + internal string sceneName; + internal string userAgent; + internal string defaultTracker; + internal string externalDeviceId; + internal string urlStrategy; + internal long? info1; + internal long? info2; + internal long? info3; + internal long? info4; + internal long? secretId; + internal double? delayStart; + internal bool? isDeviceKnown; + internal bool? sendInBackground; + internal bool? eventBufferingEnabled; + internal bool? coppaCompliantEnabled; + internal bool? playStoreKidsAppEnabled; + internal bool? allowSuppressLogLevel; + internal bool? needsCost; + internal bool launchDeferredDeeplink; + internal AdjustLogLevel? logLevel; + internal AdjustEnvironment environment; + internal Action deferredDeeplinkDelegate; + internal Action eventSuccessDelegate; + internal Action eventFailureDelegate; + internal Action sessionSuccessDelegate; + internal Action sessionFailureDelegate; + internal Action attributionChangedDelegate; + internal Action conversionValueUpdatedDelegate; + internal Action skad4ConversionValueUpdatedDelegate; + + // Android specific members + internal string processName; + internal bool? readImei; + internal bool? preinstallTrackingEnabled; + internal string preinstallFilePath; + internal bool? finalAndroidAttributionEnabled; + internal string fbAppId; + internal bool? readDeviceInfoOnceEnabled; + // iOS specific members + internal bool? allowAdServicesInfoReading; + internal bool? allowIdfaReading; + internal bool? skAdNetworkHandling; + internal bool? linkMeEnabled; + internal int? attConsentWaitingInterval; + // Windows specific members + internal Action logDelegate; + + public AdjustConfig(string appToken, AdjustEnvironment environment) + { + this.sceneName = ""; + this.processName = ""; + this.appToken = appToken; + this.environment = environment; + } + + public AdjustConfig(string appToken, AdjustEnvironment environment, bool allowSuppressLogLevel) + { + this.sceneName = ""; + this.processName = ""; + this.appToken = appToken; + this.environment = environment; + this.allowSuppressLogLevel = allowSuppressLogLevel; + } + + public void setLogLevel(AdjustLogLevel logLevel) + { + this.logLevel = logLevel; + } + + public void setDefaultTracker(string defaultTracker) + { + this.defaultTracker = defaultTracker; + } + + public void setExternalDeviceId(string externalDeviceId) + { + this.externalDeviceId = externalDeviceId; + } + + public void setLaunchDeferredDeeplink(bool launchDeferredDeeplink) + { + this.launchDeferredDeeplink = launchDeferredDeeplink; + } + + public void setSendInBackground(bool sendInBackground) + { + this.sendInBackground = sendInBackground; + } + + public void setEventBufferingEnabled(bool eventBufferingEnabled) + { + this.eventBufferingEnabled = eventBufferingEnabled; + } + + public void setCoppaCompliantEnabled(bool coppaCompliantEnabled) + { + this.coppaCompliantEnabled = coppaCompliantEnabled; + } + + public void setNeedsCost(bool needsCost) + { + this.needsCost = needsCost; + } + + public void setDelayStart(double delayStart) + { + this.delayStart = delayStart; + } + + public void setUserAgent(string userAgent) + { + this.userAgent = userAgent; + } + + public void setIsDeviceKnown(bool isDeviceKnown) + { + this.isDeviceKnown = isDeviceKnown; + } + + public void setUrlStrategy(String urlStrategy) + { + this.urlStrategy = urlStrategy; + } + + public void setAppSecret(long secretId, long info1, long info2, long info3, long info4) + { + this.secretId = secretId; + this.info1 = info1; + this.info2 = info2; + this.info3 = info3; + this.info4 = info4; + } + + public void setDeferredDeeplinkDelegate(Action deferredDeeplinkDelegate, string sceneName = "Adjust") + { + this.deferredDeeplinkDelegate = deferredDeeplinkDelegate; + this.sceneName = sceneName; + } + + public Action getDeferredDeeplinkDelegate() + { + return this.deferredDeeplinkDelegate; + } + + public void setAttributionChangedDelegate(Action attributionChangedDelegate, string sceneName = "Adjust") + { + this.attributionChangedDelegate = attributionChangedDelegate; + this.sceneName = sceneName; + } + + public Action getAttributionChangedDelegate() + { + return this.attributionChangedDelegate; + } + + public void setEventSuccessDelegate(Action eventSuccessDelegate, string sceneName = "Adjust") + { + this.eventSuccessDelegate = eventSuccessDelegate; + this.sceneName = sceneName; + } + + public Action getEventSuccessDelegate() + { + return this.eventSuccessDelegate; + } + + public void setEventFailureDelegate(Action eventFailureDelegate, string sceneName = "Adjust") + { + this.eventFailureDelegate = eventFailureDelegate; + this.sceneName = sceneName; + } + + public Action getEventFailureDelegate() + { + return this.eventFailureDelegate; + } + + public void setSessionSuccessDelegate(Action sessionSuccessDelegate, string sceneName = "Adjust") + { + this.sessionSuccessDelegate = sessionSuccessDelegate; + this.sceneName = sceneName; + } + + public Action getSessionSuccessDelegate() + { + return this.sessionSuccessDelegate; + } + + public void setSessionFailureDelegate(Action sessionFailureDelegate, string sceneName = "Adjust") + { + this.sessionFailureDelegate = sessionFailureDelegate; + this.sceneName = sceneName; + } + + public Action getSessionFailureDelegate() + { + return this.sessionFailureDelegate; + } + + // iOS specific methods. + [Obsolete("This is an obsolete method. Apple Search Ads attribution with usage of iAd.framework has been sunset by Apple as of February 7th 2023.")] + public void setAllowiAdInfoReading(bool allowiAdInfoReading) + { + } + + public void setAllowAdServicesInfoReading(bool allowAdServicesInfoReading) + { + this.allowAdServicesInfoReading = allowAdServicesInfoReading; + } + + public void setAllowIdfaReading(bool allowIdfaReading) + { + this.allowIdfaReading = allowIdfaReading; + } + + public void deactivateSKAdNetworkHandling() + { + this.skAdNetworkHandling = true; + } + + public void setLinkMeEnabled(bool linkMeEnabled) + { + this.linkMeEnabled = linkMeEnabled; + } + + public void setConversionValueUpdatedDelegate(Action conversionValueUpdatedDelegate, string sceneName = "Adjust") + { + this.conversionValueUpdatedDelegate = conversionValueUpdatedDelegate; + this.sceneName = sceneName; + } + + public Action getConversionValueUpdatedDelegate() + { + return this.conversionValueUpdatedDelegate; + } + + public void setSkad4ConversionValueUpdatedDelegate(Action skad4ConversionValueUpdatedDelegate, string sceneName = "Adjust") + { + this.skad4ConversionValueUpdatedDelegate = skad4ConversionValueUpdatedDelegate; + this.sceneName = sceneName; + } + + public Action getSkad4ConversionValueUpdatedDelegate() + { + return this.skad4ConversionValueUpdatedDelegate; + } + + public void setAttConsentWaitingInterval(int numberOfSeconds) + { + this.attConsentWaitingInterval = numberOfSeconds; + } + + // Android specific methods. + public void setProcessName(string processName) + { + this.processName = processName; + } + + [Obsolete("This is an obsolete method.")] + public void setReadMobileEquipmentIdentity(bool readMobileEquipmentIdentity) + { + // this.readImei = readMobileEquipmentIdentity; + } + + public void setPreinstallTrackingEnabled(bool preinstallTrackingEnabled) + { + this.preinstallTrackingEnabled = preinstallTrackingEnabled; + } + + public void setPreinstallFilePath(string preinstallFilePath) + { + this.preinstallFilePath = preinstallFilePath; + } + + public void setPlayStoreKidsAppEnabled(bool playStoreKidsAppEnabled) + { + this.playStoreKidsAppEnabled = playStoreKidsAppEnabled; + } + + public void setFinalAndroidAttributionEnabled(bool finalAndroidAttributionEnabled) + { + this.finalAndroidAttributionEnabled = finalAndroidAttributionEnabled; + } + + public void setFbAppId(string fbAppId) + { + this.fbAppId = fbAppId; + } + + public void setReadDeviceInfoOnceEnabled(bool readDeviceInfoOnceEnabled) + { + this.readDeviceInfoOnceEnabled = readDeviceInfoOnceEnabled; + } + + // Windows specific methods. + public void setLogDelegate(Action logDelegate) + { + this.logDelegate = logDelegate; + } + } +} diff --git a/Adjust/Unity/AdjustConfig.cs.meta b/Adjust/Unity/AdjustConfig.cs.meta new file mode 100644 index 0000000..d98ac07 --- /dev/null +++ b/Adjust/Unity/AdjustConfig.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 02d4cad14fc094b17afde3b685897e5e +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Unity/AdjustEnvironment.cs b/Adjust/Unity/AdjustEnvironment.cs new file mode 100644 index 0000000..65f3555 --- /dev/null +++ b/Adjust/Unity/AdjustEnvironment.cs @@ -0,0 +1,25 @@ +namespace com.adjust.sdk +{ + [System.Serializable] + public enum AdjustEnvironment + { + Sandbox, + Production + } + + public static class AdjustEnvironmentExtension + { + public static string ToLowercaseString(this AdjustEnvironment adjustEnvironment) + { + switch (adjustEnvironment) + { + case AdjustEnvironment.Sandbox: + return "sandbox"; + case AdjustEnvironment.Production: + return "production"; + default: + return "unknown"; + } + } + } +} diff --git a/Adjust/Unity/AdjustEnvironment.cs.meta b/Adjust/Unity/AdjustEnvironment.cs.meta new file mode 100644 index 0000000..fb47242 --- /dev/null +++ b/Adjust/Unity/AdjustEnvironment.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 633f6fa279b2244fdb999db0441f9aac +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Unity/AdjustEvent.cs b/Adjust/Unity/AdjustEvent.cs new file mode 100644 index 0000000..7382beb --- /dev/null +++ b/Adjust/Unity/AdjustEvent.cs @@ -0,0 +1,90 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustEvent + { + internal string currency; + internal string eventToken; + internal string callbackId; + internal string transactionId; + internal string productId; + internal double? revenue; + internal List partnerList; + internal List callbackList; + // iOS specific members + internal string receipt; + internal bool isReceiptSet; + // Android specific members + internal string purchaseToken; + + public AdjustEvent(string eventToken) + { + this.eventToken = eventToken; + this.isReceiptSet = false; + } + + public void setRevenue(double amount, string currency) + { + this.revenue = amount; + this.currency = currency; + } + + public void addCallbackParameter(string key, string value) + { + if (callbackList == null) + { + callbackList = new List(); + } + callbackList.Add(key); + callbackList.Add(value); + } + + public void addPartnerParameter(string key, string value) + { + if (partnerList == null) + { + partnerList = new List(); + } + partnerList.Add(key); + partnerList.Add(value); + } + + public void setCallbackId(string callbackId) + { + this.callbackId = callbackId; + } + + // iOS / Android mixed + public void setTransactionId(string transactionId) + { + this.transactionId = transactionId; + } + + public void setProductId(string productId) + { + this.productId = productId; + } + + // iOS specific methods + [Obsolete("This is an obsolete method. Please use separate setter methods for purchase verification parameters.")] + public void setReceipt(string receipt, string transactionId) + { + // this.receipt = receipt; + // this.transactionId = transactionId; + // this.isReceiptSet = true; + } + + public void setReceipt(string receipt) + { + this.receipt = receipt; + } + + // Android specific methods + public void setPurchaseToken(string purchaseToken) + { + this.purchaseToken = purchaseToken; + } + } +} diff --git a/Adjust/Unity/AdjustEvent.cs.meta b/Adjust/Unity/AdjustEvent.cs.meta new file mode 100644 index 0000000..41ea634 --- /dev/null +++ b/Adjust/Unity/AdjustEvent.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: cd89f7713977f497a862f1a1b6f60933 +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Unity/AdjustEventFailure.cs b/Adjust/Unity/AdjustEventFailure.cs new file mode 100644 index 0000000..71d63af --- /dev/null +++ b/Adjust/Unity/AdjustEventFailure.cs @@ -0,0 +1,92 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustEventFailure + { + public string Adid { get; set; } + public string Message { get; set; } + public string Timestamp { get; set; } + public string EventToken { get; set; } + public string CallbackId { get; set; } + public bool WillRetry { get; set; } + public Dictionary JsonResponse { get; set; } + + public AdjustEventFailure() {} + + public AdjustEventFailure(Dictionary eventFailureDataMap) + { + if (eventFailureDataMap == null) + { + return; + } + + Adid = AdjustUtils.TryGetValue(eventFailureDataMap, AdjustUtils.KeyAdid); + Message = AdjustUtils.TryGetValue(eventFailureDataMap, AdjustUtils.KeyMessage); + Timestamp = AdjustUtils.TryGetValue(eventFailureDataMap, AdjustUtils.KeyTimestamp); + EventToken = AdjustUtils.TryGetValue(eventFailureDataMap, AdjustUtils.KeyEventToken); + CallbackId = AdjustUtils.TryGetValue(eventFailureDataMap, AdjustUtils.KeyCallbackId); + + bool willRetry; + if (bool.TryParse(AdjustUtils.TryGetValue(eventFailureDataMap, AdjustUtils.KeyWillRetry), out willRetry)) + { + WillRetry = willRetry; + } + + string jsonResponseString = AdjustUtils.TryGetValue(eventFailureDataMap, AdjustUtils.KeyJsonResponse); + var jsonResponseNode = JSON.Parse(jsonResponseString); + if (jsonResponseNode != null && jsonResponseNode.AsObject != null) + { + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse); + } + } + + public AdjustEventFailure(string jsonString) + { + var jsonNode = JSON.Parse(jsonString); + if (jsonNode == null) + { + return; + } + + Adid = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdid); + Message = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyMessage); + Timestamp = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyTimestamp); + EventToken = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyEventToken); + CallbackId = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCallbackId); + WillRetry = Convert.ToBoolean(AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyWillRetry)); + + var jsonResponseNode = jsonNode[AdjustUtils.KeyJsonResponse]; + if (jsonResponseNode == null) + { + return; + } + if (jsonResponseNode.AsObject == null) + { + return; + } + + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse); + } + + public void BuildJsonResponseFromString(string jsonResponseString) + { + var jsonNode = JSON.Parse(jsonResponseString); + if (jsonNode == null) + { + return; + } + + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonNode.AsObject, JsonResponse); + } + + public string GetJsonResponse() + { + return AdjustUtils.GetJsonResponseCompact(JsonResponse); + } + } +} diff --git a/Adjust/Unity/AdjustEventFailure.cs.meta b/Adjust/Unity/AdjustEventFailure.cs.meta new file mode 100644 index 0000000..ee12da9 --- /dev/null +++ b/Adjust/Unity/AdjustEventFailure.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ea86cd4e1c6d0496397920902d0f0b5f +timeCreated: 1458128791 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustEventSuccess.cs b/Adjust/Unity/AdjustEventSuccess.cs new file mode 100644 index 0000000..3b15253 --- /dev/null +++ b/Adjust/Unity/AdjustEventSuccess.cs @@ -0,0 +1,85 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustEventSuccess + { + public string Adid { get; set; } + public string Message { get; set; } + public string Timestamp { get; set; } + public string EventToken { get; set; } + public string CallbackId { get; set; } + + public Dictionary JsonResponse { get; set; } + + public AdjustEventSuccess() {} + + public AdjustEventSuccess(Dictionary eventSuccessDataMap) + { + if (eventSuccessDataMap == null) + { + return; + } + + Adid = AdjustUtils.TryGetValue(eventSuccessDataMap, AdjustUtils.KeyAdid); + Message = AdjustUtils.TryGetValue(eventSuccessDataMap, AdjustUtils.KeyMessage); + Timestamp = AdjustUtils.TryGetValue(eventSuccessDataMap, AdjustUtils.KeyTimestamp); + EventToken = AdjustUtils.TryGetValue(eventSuccessDataMap, AdjustUtils.KeyEventToken); + CallbackId = AdjustUtils.TryGetValue(eventSuccessDataMap, AdjustUtils.KeyCallbackId); + + string jsonResponseString = AdjustUtils.TryGetValue(eventSuccessDataMap, AdjustUtils.KeyJsonResponse); + var jsonResponseNode = JSON.Parse(jsonResponseString); + if (jsonResponseNode != null && jsonResponseNode.AsObject != null) + { + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse); + } + } + + public AdjustEventSuccess(string jsonString) + { + var jsonNode = JSON.Parse(jsonString); + if (jsonNode == null) + { + return; + } + + Adid = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdid); + Message = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyMessage); + Timestamp = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyTimestamp); + EventToken = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyEventToken); + CallbackId = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCallbackId); + + var jsonResponseNode = jsonNode[AdjustUtils.KeyJsonResponse]; + if (jsonResponseNode == null) + { + return; + } + if (jsonResponseNode.AsObject == null) + { + return; + } + + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse); + } + + public void BuildJsonResponseFromString(string jsonResponseString) + { + var jsonNode = JSON.Parse(jsonResponseString); + if (jsonNode == null) + { + return; + } + + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonNode.AsObject, JsonResponse); + } + + public string GetJsonResponse() + { + return AdjustUtils.GetJsonResponseCompact(JsonResponse); + } + } +} diff --git a/Adjust/Unity/AdjustEventSuccess.cs.meta b/Adjust/Unity/AdjustEventSuccess.cs.meta new file mode 100644 index 0000000..a750f56 --- /dev/null +++ b/Adjust/Unity/AdjustEventSuccess.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 1957a0e6e9aa14f0e8adefa2120f1e02 +timeCreated: 1458128791 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustLogLevel.cs b/Adjust/Unity/AdjustLogLevel.cs new file mode 100644 index 0000000..a61994d --- /dev/null +++ b/Adjust/Unity/AdjustLogLevel.cs @@ -0,0 +1,63 @@ +namespace com.adjust.sdk +{ + [System.Serializable] + public enum AdjustLogLevel + { + Verbose = 1, + Debug, + Info, + Warn, + Error, + Assert, + Suppress + } + + public static class AdjustLogLevelExtension + { + public static string ToLowercaseString(this AdjustLogLevel AdjustLogLevel) + { + switch (AdjustLogLevel) + { + case AdjustLogLevel.Verbose: + return "verbose"; + case AdjustLogLevel.Debug: + return "debug"; + case AdjustLogLevel.Info: + return "info"; + case AdjustLogLevel.Warn: + return "warn"; + case AdjustLogLevel.Error: + return "error"; + case AdjustLogLevel.Assert: + return "assert"; + case AdjustLogLevel.Suppress: + return "suppress"; + default: + return "unknown"; + } + } + + public static string ToUppercaseString(this AdjustLogLevel AdjustLogLevel) + { + switch (AdjustLogLevel) + { + case AdjustLogLevel.Verbose: + return "VERBOSE"; + case AdjustLogLevel.Debug: + return "DEBUG"; + case AdjustLogLevel.Info: + return "INFO"; + case AdjustLogLevel.Warn: + return "WARN"; + case AdjustLogLevel.Error: + return "ERROR"; + case AdjustLogLevel.Assert: + return "ASSERT"; + case AdjustLogLevel.Suppress: + return "SUPPRESS"; + default: + return "UNKNOWN"; + } + } + } +} diff --git a/Adjust/Unity/AdjustLogLevel.cs.meta b/Adjust/Unity/AdjustLogLevel.cs.meta new file mode 100644 index 0000000..226164e --- /dev/null +++ b/Adjust/Unity/AdjustLogLevel.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 428ab44990df24973902248a9d2b43dd +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Adjust/Unity/AdjustPlayStorePurchase.cs b/Adjust/Unity/AdjustPlayStorePurchase.cs new file mode 100644 index 0000000..9bbf955 --- /dev/null +++ b/Adjust/Unity/AdjustPlayStorePurchase.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustPlayStorePurchase + { + internal string productId; + internal string purchaseToken; + + public AdjustPlayStorePurchase(string productId, string purchaseToken) + { + this.productId = productId; + this.purchaseToken = purchaseToken; + } + } +} diff --git a/Adjust/Unity/AdjustPlayStorePurchase.cs.meta b/Adjust/Unity/AdjustPlayStorePurchase.cs.meta new file mode 100644 index 0000000..004849b --- /dev/null +++ b/Adjust/Unity/AdjustPlayStorePurchase.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: d875a71a5aeb1496d93afac749ab17f6 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustPlayStoreSubscription.cs b/Adjust/Unity/AdjustPlayStoreSubscription.cs new file mode 100644 index 0000000..c86e45c --- /dev/null +++ b/Adjust/Unity/AdjustPlayStoreSubscription.cs @@ -0,0 +1,54 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustPlayStoreSubscription + { + internal string price; + internal string currency; + internal string sku; + internal string orderId; + internal string signature; + internal string purchaseToken; + internal string billingStore; + internal string purchaseTime; + internal List partnerList; + internal List callbackList; + + public AdjustPlayStoreSubscription(string price, string currency, string sku, string orderId, string signature, string purchaseToken) + { + this.price = price; + this.currency = currency; + this.sku = sku; + this.orderId = orderId; + this.signature = signature; + this.purchaseToken = purchaseToken; + } + + public void setPurchaseTime(string purchaseTime) + { + this.purchaseTime = purchaseTime; + } + + public void addCallbackParameter(string key, string value) + { + if (callbackList == null) + { + callbackList = new List(); + } + callbackList.Add(key); + callbackList.Add(value); + } + + public void addPartnerParameter(string key, string value) + { + if (partnerList == null) + { + partnerList = new List(); + } + partnerList.Add(key); + partnerList.Add(value); + } + } +} diff --git a/Adjust/Unity/AdjustPlayStoreSubscription.cs.meta b/Adjust/Unity/AdjustPlayStoreSubscription.cs.meta new file mode 100644 index 0000000..8b82732 --- /dev/null +++ b/Adjust/Unity/AdjustPlayStoreSubscription.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 69e7a4074abb44758b3f011d8352a57a +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustPurchaseVerificationInfo.cs b/Adjust/Unity/AdjustPurchaseVerificationInfo.cs new file mode 100644 index 0000000..beb4d83 --- /dev/null +++ b/Adjust/Unity/AdjustPurchaseVerificationInfo.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustPurchaseVerificationInfo + { + #region Properties + public int code { get; set; } + public string message { get; set; } + public string verificationStatus { get; set; } + #endregion + + #region Constructors + public AdjustPurchaseVerificationInfo() + { + } + + public AdjustPurchaseVerificationInfo(string jsonString) + { + var jsonNode = JSON.Parse(jsonString); + + if (jsonNode == null) + { + return; + } + + string stringCode = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyCode); + code = Int32.Parse(stringCode); + message = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyMessage); + verificationStatus = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyVerificationStatus); + } + #endregion + } +} diff --git a/Adjust/Unity/AdjustPurchaseVerificationInfo.cs.meta b/Adjust/Unity/AdjustPurchaseVerificationInfo.cs.meta new file mode 100644 index 0000000..486c641 --- /dev/null +++ b/Adjust/Unity/AdjustPurchaseVerificationInfo.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: c0c97a5152b31474d89bc1ba521644de +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustSessionFailure.cs b/Adjust/Unity/AdjustSessionFailure.cs new file mode 100644 index 0000000..6d06286 --- /dev/null +++ b/Adjust/Unity/AdjustSessionFailure.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustSessionFailure + { + public string Adid { get; set; } + public string Message { get; set; } + public string Timestamp { get; set; } + public bool WillRetry { get; set; } + public Dictionary JsonResponse { get; set; } + + public AdjustSessionFailure() {} + + public AdjustSessionFailure(Dictionary sessionFailureDataMap) + { + if (sessionFailureDataMap == null) + { + return; + } + + Adid = AdjustUtils.TryGetValue(sessionFailureDataMap, AdjustUtils.KeyAdid); + Message = AdjustUtils.TryGetValue(sessionFailureDataMap, AdjustUtils.KeyMessage); + Timestamp = AdjustUtils.TryGetValue(sessionFailureDataMap, AdjustUtils.KeyTimestamp); + + bool willRetry; + if (bool.TryParse(AdjustUtils.TryGetValue(sessionFailureDataMap, AdjustUtils.KeyWillRetry), out willRetry)) + { + WillRetry = willRetry; + } + + string jsonResponseString = AdjustUtils.TryGetValue(sessionFailureDataMap, AdjustUtils.KeyJsonResponse); + var jsonResponseNode = JSON.Parse(jsonResponseString); + if (jsonResponseNode != null && jsonResponseNode.AsObject != null) + { + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse); + } + } + + public AdjustSessionFailure(string jsonString) + { + var jsonNode = JSON.Parse(jsonString); + if (jsonNode == null) + { + return; + } + + Adid = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdid); + Message = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyMessage); + Timestamp = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyTimestamp); + WillRetry = Convert.ToBoolean(AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyWillRetry)); + + var jsonResponseNode = jsonNode[AdjustUtils.KeyJsonResponse]; + if (jsonResponseNode == null) + { + return; + } + if (jsonResponseNode.AsObject == null) + { + return; + } + + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse); + } + + public void BuildJsonResponseFromString(string jsonResponseString) + { + var jsonNode = JSON.Parse(jsonResponseString); + if (jsonNode == null) + { + return; + } + + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonNode.AsObject, JsonResponse); + } + + public string GetJsonResponse() + { + return AdjustUtils.GetJsonResponseCompact(JsonResponse); + } + } +} diff --git a/Adjust/Unity/AdjustSessionFailure.cs.meta b/Adjust/Unity/AdjustSessionFailure.cs.meta new file mode 100644 index 0000000..4e905a4 --- /dev/null +++ b/Adjust/Unity/AdjustSessionFailure.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: b4de268ab985448a594fb82264190742 +timeCreated: 1458128791 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustSessionSuccess.cs b/Adjust/Unity/AdjustSessionSuccess.cs new file mode 100644 index 0000000..fd55aff --- /dev/null +++ b/Adjust/Unity/AdjustSessionSuccess.cs @@ -0,0 +1,78 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustSessionSuccess + { + public string Adid { get; set; } + public string Message { get; set; } + public string Timestamp { get; set; } + public Dictionary JsonResponse { get; set; } + + public AdjustSessionSuccess() {} + + public AdjustSessionSuccess(Dictionary sessionSuccessDataMap) + { + if (sessionSuccessDataMap == null) + { + return; + } + + Adid = AdjustUtils.TryGetValue(sessionSuccessDataMap, AdjustUtils.KeyAdid); + Message = AdjustUtils.TryGetValue(sessionSuccessDataMap, AdjustUtils.KeyMessage); + Timestamp = AdjustUtils.TryGetValue(sessionSuccessDataMap, AdjustUtils.KeyTimestamp); + + string jsonResponseString = AdjustUtils.TryGetValue(sessionSuccessDataMap, AdjustUtils.KeyJsonResponse); + var jsonResponseNode = JSON.Parse(jsonResponseString); + if (jsonResponseNode != null && jsonResponseNode.AsObject != null) + { + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse); + } + } + + public AdjustSessionSuccess(string jsonString) + { + var jsonNode = JSON.Parse(jsonString); + if (jsonNode == null) + { + return; + } + + Adid = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyAdid); + Message = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyMessage); + Timestamp = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeyTimestamp); + + var jsonResponseNode = jsonNode[AdjustUtils.KeyJsonResponse]; + if (jsonResponseNode == null) + { + return; + } + if (jsonResponseNode.AsObject == null) + { + return; + } + + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonResponseNode.AsObject, JsonResponse); + } + + public void BuildJsonResponseFromString(string jsonResponseString) + { + var jsonNode = JSON.Parse(jsonResponseString); + if (jsonNode == null) + { + return; + } + + JsonResponse = new Dictionary(); + AdjustUtils.WriteJsonResponseDictionary(jsonNode.AsObject, JsonResponse); + } + + public string GetJsonResponse() + { + return AdjustUtils.GetJsonResponseCompact(JsonResponse); + } + } +} diff --git a/Adjust/Unity/AdjustSessionSuccess.cs.meta b/Adjust/Unity/AdjustSessionSuccess.cs.meta new file mode 100644 index 0000000..643c083 --- /dev/null +++ b/Adjust/Unity/AdjustSessionSuccess.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c23847e7a1f464d7a8c7f9b35829af17 +timeCreated: 1458128791 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustThirdPartySharing.cs b/Adjust/Unity/AdjustThirdPartySharing.cs new file mode 100644 index 0000000..091cacf --- /dev/null +++ b/Adjust/Unity/AdjustThirdPartySharing.cs @@ -0,0 +1,65 @@ +using System; +using System.Collections.Generic; + +namespace com.adjust.sdk +{ + public class AdjustThirdPartySharing + { + internal bool? isEnabled; + internal Dictionary> granularOptions; + internal Dictionary> partnerSharingSettings; + + public AdjustThirdPartySharing(bool? isEnabled) + { + this.isEnabled = isEnabled; + this.granularOptions = new Dictionary>(); + this.partnerSharingSettings = new Dictionary>(); + } + + public void addGranularOption(string partnerName, string key, string value) + { + // TODO: consider to add some logs about the error case + if (partnerName == null || key == null || value == null) + { + return; + } + + List partnerOptions; + if (granularOptions.ContainsKey(partnerName)) + { + partnerOptions = granularOptions[partnerName]; + } + else + { + partnerOptions = new List(); + granularOptions.Add(partnerName, partnerOptions); + } + + partnerOptions.Add(key); + partnerOptions.Add(value); + } + + public void addPartnerSharingSetting(string partnerName, string key, bool value) + { + // TODO: consider to add some logs about the error case + if (partnerName == null || key == null) + { + return; + } + + List partnerSharingSetting; + if (partnerSharingSettings.ContainsKey(partnerName)) + { + partnerSharingSetting = partnerSharingSettings[partnerName]; + } + else + { + partnerSharingSetting = new List(); + partnerSharingSettings.Add(partnerName, partnerSharingSetting); + } + + partnerSharingSetting.Add(key); + partnerSharingSetting.Add(value.ToString()); + } + } +} diff --git a/Adjust/Unity/AdjustThirdPartySharing.cs.meta b/Adjust/Unity/AdjustThirdPartySharing.cs.meta new file mode 100644 index 0000000..5270a0b --- /dev/null +++ b/Adjust/Unity/AdjustThirdPartySharing.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: dcb2591dfab904327904b8879af699ca +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustUrlStrategy.cs b/Adjust/Unity/AdjustUrlStrategy.cs new file mode 100644 index 0000000..6d4974a --- /dev/null +++ b/Adjust/Unity/AdjustUrlStrategy.cs @@ -0,0 +1,30 @@ +namespace com.adjust.sdk +{ + [System.Serializable] + public enum AdjustUrlStrategy + { + Default, + DataResidencyEU, + DataResidencyTK, + DataResidencyUS, + India, + China, + } + + public static class AdjustUrlStrategyExtension + { + public static string ToLowerCaseString(this AdjustUrlStrategy strategy) + { + switch (strategy) + { + case AdjustUrlStrategy.India: return "india"; + case AdjustUrlStrategy.China: return "china"; + case AdjustUrlStrategy.DataResidencyEU: return "data-residency-eu"; + case AdjustUrlStrategy.DataResidencyTK: return "data-residency-tr"; + case AdjustUrlStrategy.DataResidencyUS: return "data-residency-us"; + default: return string.Empty; + } + } + } +} + diff --git a/Adjust/Unity/AdjustUrlStrategy.cs.meta b/Adjust/Unity/AdjustUrlStrategy.cs.meta new file mode 100644 index 0000000..cd90919 --- /dev/null +++ b/Adjust/Unity/AdjustUrlStrategy.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 034243ca816f644dc97675a908e24e8c +timeCreated: 1617092915 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Unity/AdjustUtils.cs b/Adjust/Unity/AdjustUtils.cs new file mode 100644 index 0000000..77b1b59 --- /dev/null +++ b/Adjust/Unity/AdjustUtils.cs @@ -0,0 +1,374 @@ +using System; +using System.Collections.Generic; + +using UnityEngine; + +namespace com.adjust.sdk +{ + public class AdjustUtils + { + public static string KeyAdid = "adid"; + public static string KeyMessage = "message"; + public static string KeyNetwork = "network"; + public static string KeyAdgroup = "adgroup"; + public static string KeyCampaign = "campaign"; + public static string KeyCreative = "creative"; + public static string KeyWillRetry = "willRetry"; + public static string KeyTimestamp = "timestamp"; + public static string KeyCallbackId = "callbackId"; + public static string KeyEventToken = "eventToken"; + public static string KeyClickLabel = "clickLabel"; + public static string KeyTrackerName = "trackerName"; + public static string KeyTrackerToken = "trackerToken"; + public static string KeyJsonResponse = "jsonResponse"; + public static string KeyCostType = "costType"; + public static string KeyCostAmount = "costAmount"; + public static string KeyCostCurrency = "costCurrency"; + public static string KeyFbInstallReferrer = "fbInstallReferrer"; + public static string KeySkadConversionValue = "fineValue"; + public static string KeySkadCoarseValue = "coarseValue"; + public static string KeySkadLockWindow = "lockWindow"; + public static string KeyCode = "code"; + public static string KeyVerificationStatus = "verificationStatus"; + + // For testing purposes. + public static string KeyTestOptionsBaseUrl = "baseUrl"; + public static string KeyTestOptionsGdprUrl = "gdprUrl"; + public static string KeyTestOptionsSubscriptionUrl = "subscriptionUrl"; + public static string KeyTestOptionsPurchaseVerificationUrl = "purchaseVerificationUrl"; + public static string KeyTestOptionsExtraPath = "extraPath"; + public static string KeyTestOptionsBasePath = "basePath"; + public static string KeyTestOptionsGdprPath = "gdprPath"; + public static string KeyTestOptionsDeleteState = "deleteState"; + public static string KeyTestOptionsUseTestConnectionOptions = "useTestConnectionOptions"; + public static string KeyTestOptionsTimerIntervalInMilliseconds = "timerIntervalInMilliseconds"; + public static string KeyTestOptionsTimerStartInMilliseconds = "timerStartInMilliseconds"; + public static string KeyTestOptionsSessionIntervalInMilliseconds = "sessionIntervalInMilliseconds"; + public static string KeyTestOptionsSubsessionIntervalInMilliseconds = "subsessionIntervalInMilliseconds"; + public static string KeyTestOptionsTeardown = "teardown"; + public static string KeyTestOptionsNoBackoffWait = "noBackoffWait"; + public static string KeyTestOptionsAdServicesFrameworkEnabled = "adServicesFrameworkEnabled"; + + public static int ConvertLogLevel(AdjustLogLevel? logLevel) + { + if (logLevel == null) + { + return -1; + } + + return (int)logLevel; + } + + public static int ConvertBool(bool? value) + { + if (value == null) + { + return -1; + } + if (value.Value) + { + return 1; + } + else + { + return 0; + } + } + + public static double ConvertDouble(double? value) + { + if (value == null) + { + return -1; + } + + return (double)value; + } + + public static int ConvertInt(int? value) + { + if (value == null) + { + return -1; + } + + return (int)value; + } + + public static long ConvertLong(long? value) + { + if (value == null) + { + return -1; + } + + return (long)value; + } + + public static string ConvertListToJson(List list) + { + if (list == null) + { + return null; + } + // list of callback / partner parameters must contain even number of elements + if (list.Count % 2 != 0) + { + return null; + } + + List processedList = new List(); + for (int i = 0; i < list.Count; i += 2) + { + String key = list[i]; + String value = list[i + 1]; + + if (key == null || value == null) + { + continue; + } + + processedList.Add(key); + processedList.Add(value); + } + + // create JSON array + var jsonArray = new JSONArray(); + foreach (var listItem in processedList) + { + jsonArray.Add(new JSONData(listItem)); + } + + return jsonArray.ToString(); + } + + public static string GetJsonResponseCompact(Dictionary dictionary) + { + string logJsonResponse = ""; + + if (dictionary == null) + { + return logJsonResponse; + } + else + { + int preLoopCounter = 0; + logJsonResponse += "{"; + + foreach (KeyValuePair pair in dictionary) + { + String valueString = pair.Value as string; + + if (valueString != null) + { + if (++preLoopCounter > 1) + { + logJsonResponse += ","; + } + + // if the value is another JSON/complex-structure + if (valueString.StartsWith("{") && valueString.EndsWith("}")) + { + logJsonResponse += "\"" + pair.Key + "\"" + ":" + valueString; + } + else + { + logJsonResponse += "\"" + pair.Key + "\"" + ":" + "\"" + valueString + "\""; + } + + continue; + } + + Dictionary valueDictionary = pair.Value as Dictionary; + + if (++preLoopCounter > 1) + { + logJsonResponse += ","; + } + + logJsonResponse += "\"" + pair.Key + "\"" + ":"; + logJsonResponse += GetJsonResponseCompact(valueDictionary); + } + + logJsonResponse += "}"; + } + + return logJsonResponse; + } + + public static String GetJsonString(JSONNode node, string key) + { + if (node == null) + { + return null; + } + + // Access value object and cast it to JSONData. + var nodeValue = node[key] as JSONData; + + if (nodeValue == null) + { + return null; + } + + // https://github.com/adjust/unity_sdk/issues/137 + if (nodeValue == "") + { + return null; + } + + return nodeValue.Value; + } + + public static void WriteJsonResponseDictionary(JSONClass jsonObject, Dictionary output) + { + foreach (KeyValuePair pair in jsonObject) + { + // Try to cast value as a complex object. + var subNode = pair.Value.AsObject; + var key = pair.Key; + + // Value is not a complex object. + if (subNode == null) + { + var value = pair.Value.Value; + output.Add(key, value); + continue; + } + + // Create new dictionary for complex type. + var newSubDictionary = new Dictionary(); + + // Save it in the current dictionary. + output.Add(key, newSubDictionary); + + // Recursive call to fill new dictionary. + WriteJsonResponseDictionary(subNode, newSubDictionary); + } + } + + public static string TryGetValue(Dictionary dictionary, string key) + { + string value; + if (dictionary.TryGetValue(key, out value)) + { + // https://github.com/adjust/unity_sdk/issues/137 + if (value == "") + { + return null; + } + return value; + } + return null; + } + + public static int GetSkad4ConversionValue(string conversionValueUpdate) + { + var jsonNode = JSON.Parse(conversionValueUpdate); + if (jsonNode == null) + { + return -1; + } + + string strConversionValue = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeySkadConversionValue); + int conversionValue = 0; + if (Int32.TryParse(strConversionValue, out conversionValue)) + { + return conversionValue; + } + else + { + return -1; + } + } + + public static string GetSkad4CoarseValue(string conversionValueUpdate) + { + var jsonNode = JSON.Parse(conversionValueUpdate); + if (jsonNode == null) + { + return null; + } + string coarseValue = AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeySkadCoarseValue); + return coarseValue; + } + + public static bool GetSkad4LockWindow(string conversionValueUpdate) + { + var jsonNode = JSON.Parse(conversionValueUpdate); + if (jsonNode == null) + { + return false; + } + bool lockWindow = Convert.ToBoolean(AdjustUtils.GetJsonString(jsonNode, AdjustUtils.KeySkadLockWindow)); + return lockWindow; + } + +#if UNITY_ANDROID + public static AndroidJavaObject TestOptionsMap2AndroidJavaObject(Dictionary testOptionsMap, AndroidJavaObject ajoCurrentActivity) + { + AndroidJavaObject ajoTestOptions = new AndroidJavaObject("com.adjust.sdk.AdjustTestOptions"); + ajoTestOptions.Set("baseUrl", testOptionsMap[KeyTestOptionsBaseUrl]); + ajoTestOptions.Set("gdprUrl", testOptionsMap[KeyTestOptionsGdprUrl]); + ajoTestOptions.Set("subscriptionUrl", testOptionsMap[KeyTestOptionsSubscriptionUrl]); + ajoTestOptions.Set("purchaseVerificationUrl", testOptionsMap[KeyTestOptionsPurchaseVerificationUrl]); + + if (testOptionsMap.ContainsKey(KeyTestOptionsExtraPath) && !string.IsNullOrEmpty(testOptionsMap[KeyTestOptionsExtraPath])) + { + ajoTestOptions.Set("basePath", testOptionsMap[KeyTestOptionsExtraPath]); + ajoTestOptions.Set("gdprPath", testOptionsMap[KeyTestOptionsExtraPath]); + ajoTestOptions.Set("subscriptionPath", testOptionsMap[KeyTestOptionsExtraPath]); + ajoTestOptions.Set("purchaseVerificationPath", testOptionsMap[KeyTestOptionsExtraPath]); + } + if (testOptionsMap.ContainsKey(KeyTestOptionsDeleteState) && ajoCurrentActivity != null) + { + ajoTestOptions.Set("context", ajoCurrentActivity); + } + if (testOptionsMap.ContainsKey(KeyTestOptionsUseTestConnectionOptions)) + { + bool useTestConnectionOptions = testOptionsMap[KeyTestOptionsUseTestConnectionOptions].ToLower() == "true"; + AndroidJavaObject ajoUseTestConnectionOptions = new AndroidJavaObject("java.lang.Boolean", useTestConnectionOptions); + ajoTestOptions.Set("useTestConnectionOptions", ajoUseTestConnectionOptions); + } + if (testOptionsMap.ContainsKey(KeyTestOptionsTimerIntervalInMilliseconds)) + { + var timerIntervalInMilliseconds = long.Parse(testOptionsMap[KeyTestOptionsTimerIntervalInMilliseconds]); + AndroidJavaObject ajoTimerIntervalInMilliseconds = new AndroidJavaObject("java.lang.Long", timerIntervalInMilliseconds); + ajoTestOptions.Set("timerIntervalInMilliseconds", ajoTimerIntervalInMilliseconds); + } + if (testOptionsMap.ContainsKey(KeyTestOptionsTimerStartInMilliseconds)) + { + var timerStartInMilliseconds = long.Parse(testOptionsMap[KeyTestOptionsTimerStartInMilliseconds]); + AndroidJavaObject ajoTimerStartInMilliseconds = new AndroidJavaObject("java.lang.Long", timerStartInMilliseconds); + ajoTestOptions.Set("timerStartInMilliseconds", ajoTimerStartInMilliseconds); + } + if (testOptionsMap.ContainsKey(KeyTestOptionsSessionIntervalInMilliseconds)) + { + var sessionIntervalInMilliseconds = long.Parse(testOptionsMap[KeyTestOptionsSessionIntervalInMilliseconds]); + AndroidJavaObject ajoSessionIntervalInMilliseconds = new AndroidJavaObject("java.lang.Long", sessionIntervalInMilliseconds); + ajoTestOptions.Set("sessionIntervalInMilliseconds", ajoSessionIntervalInMilliseconds); + } + if (testOptionsMap.ContainsKey(KeyTestOptionsSubsessionIntervalInMilliseconds)) + { + var subsessionIntervalInMilliseconds = long.Parse(testOptionsMap[KeyTestOptionsSubsessionIntervalInMilliseconds]); + AndroidJavaObject ajoSubsessionIntervalInMilliseconds = new AndroidJavaObject("java.lang.Long", subsessionIntervalInMilliseconds); + ajoTestOptions.Set("subsessionIntervalInMilliseconds", ajoSubsessionIntervalInMilliseconds); + } + if (testOptionsMap.ContainsKey(KeyTestOptionsTeardown)) + { + bool teardown = testOptionsMap[KeyTestOptionsTeardown].ToLower() == "true"; + AndroidJavaObject ajoTeardown = new AndroidJavaObject("java.lang.Boolean", teardown); + ajoTestOptions.Set("teardown", ajoTeardown); + } + if (testOptionsMap.ContainsKey(KeyTestOptionsNoBackoffWait)) + { + bool noBackoffWait = testOptionsMap[KeyTestOptionsNoBackoffWait].ToLower() == "true"; + AndroidJavaObject ajoNoBackoffWait = new AndroidJavaObject("java.lang.Boolean", noBackoffWait); + ajoTestOptions.Set("noBackoffWait", ajoNoBackoffWait); + } + + return ajoTestOptions; + } +#endif + } +} diff --git a/Adjust/Unity/AdjustUtils.cs.meta b/Adjust/Unity/AdjustUtils.cs.meta new file mode 100644 index 0000000..5f6f1ad --- /dev/null +++ b/Adjust/Unity/AdjustUtils.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 98e51a1481cc24ddebf93f61f6c1eb9d +timeCreated: 1458230617 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows.meta b/Adjust/Windows.meta new file mode 100644 index 0000000..09f85b2 --- /dev/null +++ b/Adjust/Windows.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: b2eaef4e025b6a64c942a8a88ad33333 +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/AdjustWindows.cs b/Adjust/Windows/AdjustWindows.cs new file mode 100644 index 0000000..4a79826 --- /dev/null +++ b/Adjust/Windows/AdjustWindows.cs @@ -0,0 +1,340 @@ +#if UNITY_WSA +using System; +using System.Collections; +using System.Collections.Generic; +using System.Reflection; +using UnityEngine; + +#if UNITY_WSA_10_0 +using Win10Interface; +#elif UNITY_WP_8_1 +using Win81Interface; +#elif UNITY_WSA +using WinWsInterface; +#endif + +namespace com.adjust.sdk +{ + public class AdjustWindows + { + private const string sdkPrefix = "unity4.36.0"; + private static bool appLaunched = false; + + public static void Start(AdjustConfig adjustConfig) + { + string logLevelString = null; + string environment = adjustConfig.environment.ToLowercaseString(); + + Action> attributionChangedAction = null; + Action> sessionSuccessChangedAction = null; + Action> sessionFailureChangedAction = null; + Action> eventSuccessChangedAction = null; + Action> eventFailureChangedAction = null; + Func deeplinkResponseFunc = null; + + if (adjustConfig.logLevel.HasValue) + { + logLevelString = adjustConfig.logLevel.Value.ToLowercaseString(); + } + + if (adjustConfig.attributionChangedDelegate != null) + { + attributionChangedAction = (attributionMap) => + { + var attribution = new AdjustAttribution(attributionMap); + adjustConfig.attributionChangedDelegate(attribution); + }; + } + + if (adjustConfig.sessionSuccessDelegate != null) + { + sessionSuccessChangedAction = (sessionMap) => + { + var sessionData = new AdjustSessionSuccess(sessionMap); + adjustConfig.sessionSuccessDelegate(sessionData); + }; + } + + if (adjustConfig.sessionFailureDelegate != null) + { + sessionFailureChangedAction = (sessionMap) => + { + var sessionData = new AdjustSessionFailure(sessionMap); + adjustConfig.sessionFailureDelegate(sessionData); + }; + } + + if (adjustConfig.eventSuccessDelegate != null) + { + eventSuccessChangedAction = (eventMap) => + { + var eventData = new AdjustEventSuccess(eventMap); + adjustConfig.eventSuccessDelegate(eventData); + }; + } + + if (adjustConfig.eventFailureDelegate != null) + { + eventFailureChangedAction = (eventMap) => + { + var eventData = new AdjustEventFailure(eventMap); + adjustConfig.eventFailureDelegate(eventData); + }; + } + + if (adjustConfig.deferredDeeplinkDelegate != null) + { + deeplinkResponseFunc = uri => + { + if (adjustConfig.launchDeferredDeeplink) + { + adjustConfig.deferredDeeplinkDelegate(uri); + } + + return adjustConfig.launchDeferredDeeplink; + }; + } + + bool sendInBackground = false; + if (adjustConfig.sendInBackground.HasValue) + { + sendInBackground = adjustConfig.sendInBackground.Value; + } + + double delayStartSeconds = 0; + if (adjustConfig.delayStart.HasValue) + { + delayStartSeconds = adjustConfig.delayStart.Value; + } + + AdjustConfigDto adjustConfigDto = new AdjustConfigDto { + AppToken = adjustConfig.appToken, + Environment = environment, + SdkPrefix = sdkPrefix, + SendInBackground = sendInBackground, + DelayStart = delayStartSeconds, + UserAgent = adjustConfig.userAgent, + DefaultTracker = adjustConfig.defaultTracker, + EventBufferingEnabled = adjustConfig.eventBufferingEnabled, + LaunchDeferredDeeplink = adjustConfig.launchDeferredDeeplink, + LogLevelString = logLevelString, + LogDelegate = adjustConfig.logDelegate, + ActionAttributionChangedData = attributionChangedAction, + ActionSessionSuccessData = sessionSuccessChangedAction, + ActionSessionFailureData = sessionFailureChangedAction, + ActionEventSuccessData = eventSuccessChangedAction, + ActionEventFailureData = eventFailureChangedAction, + FuncDeeplinkResponseData = deeplinkResponseFunc, + IsDeviceKnown = adjustConfig.isDeviceKnown, + SecretId = adjustConfig.secretId, + Info1 = adjustConfig.info1, + Info2 = adjustConfig.info2, + Info3 = adjustConfig.info3, + Info4 = adjustConfig.info4 + }; + + AdjustWinInterface.ApplicationLaunching(adjustConfigDto); + AdjustWinInterface.ApplicationActivated(); + appLaunched = true; + } + + public static void TrackEvent(AdjustEvent adjustEvent) + { + AdjustWinInterface.TrackEvent( + eventToken: adjustEvent.eventToken, + revenue: adjustEvent.revenue, + currency: adjustEvent.currency, + purchaseId: adjustEvent.transactionId, + callbackId: adjustEvent.callbackId, + callbackList: adjustEvent.callbackList, + partnerList: adjustEvent.partnerList + ); + } + + public static bool IsEnabled() + { + return AdjustWinInterface.IsEnabled(); + } + + public static void OnResume() + { + if (!appLaunched) + { + return; + } + + AdjustWinInterface.ApplicationActivated(); + } + + public static void OnPause() + { + AdjustWinInterface.ApplicationDeactivated(); + } + + public static void SetEnabled(bool enabled) + { + AdjustWinInterface.SetEnabled(enabled); + } + + public static void SetOfflineMode(bool offlineMode) + { + AdjustWinInterface.SetOfflineMode(offlineMode); + } + + public static void SendFirstPackages() + { + AdjustWinInterface.SendFirstPackages(); + } + + public static void SetDeviceToken(string deviceToken) + { + AdjustWinInterface.SetDeviceToken(deviceToken); + } + + public static void AppWillOpenUrl(string url) + { + AdjustWinInterface.AppWillOpenUrl(url); + } + + public static void AddSessionPartnerParameter(string key, string value) + { + AdjustWinInterface.AddSessionPartnerParameter(key, value); + } + + public static void AddSessionCallbackParameter(string key, string value) + { + AdjustWinInterface.AddSessionCallbackParameter(key, value); + } + + public static void RemoveSessionPartnerParameter(string key) + { + AdjustWinInterface.RemoveSessionPartnerParameter(key); + } + + public static void RemoveSessionCallbackParameter(string key) + { + AdjustWinInterface.RemoveSessionCallbackParameter(key); + } + + public static void ResetSessionPartnerParameters() + { + AdjustWinInterface.ResetSessionPartnerParameters(); + } + + public static void ResetSessionCallbackParameters() + { + AdjustWinInterface.ResetSessionCallbackParameters(); + } + + public static string GetAdid() + { + return AdjustWinInterface.GetAdid(); + } + + public static string GetSdkVersion() + { + return sdkPrefix + "@" + AdjustWinInterface.GetSdkVersion(); + } + + public static AdjustAttribution GetAttribution() + { + var attributionMap = AdjustWinInterface.GetAttribution(); + if (attributionMap == null) + { + return new AdjustAttribution(); + } + + return new AdjustAttribution(attributionMap); + } + + public static void GdprForgetMe() + { + AdjustWinInterface.GdprForgetMe(); + } + + public static string GetWinAdId() + { + return AdjustWinInterface.GetWindowsAdId(); + } + + public static void SetTestOptions(Dictionary testOptions) + { + string basePath = testOptions.ContainsKey(AdjustUtils.KeyTestOptionsBasePath) ? + testOptions[AdjustUtils.KeyTestOptionsBasePath] : null; + string gdprPath = testOptions.ContainsKey(AdjustUtils.KeyTestOptionsGdprPath) ? + testOptions[AdjustUtils.KeyTestOptionsGdprPath] : null; + long timerIntervalMls = -1; + long timerStartMls = -1; + long sessionIntMls = -1; + long subsessionIntMls = -1; + bool teardown = false; + bool deleteState = false; + bool noBackoffWait = false; + + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsTimerIntervalInMilliseconds)) + { + timerIntervalMls = long.Parse(testOptions[AdjustUtils.KeyTestOptionsTimerIntervalInMilliseconds]); + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsTimerStartInMilliseconds)) + { + timerStartMls = long.Parse(testOptions[AdjustUtils.KeyTestOptionsTimerStartInMilliseconds]); + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsSessionIntervalInMilliseconds)) + { + sessionIntMls = long.Parse(testOptions[AdjustUtils.KeyTestOptionsSessionIntervalInMilliseconds]); + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsSubsessionIntervalInMilliseconds)) + { + subsessionIntMls = long.Parse(testOptions[AdjustUtils.KeyTestOptionsSubsessionIntervalInMilliseconds]); + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsTeardown)) + { + teardown = testOptions[AdjustUtils.KeyTestOptionsTeardown].ToLower() == "true"; + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsDeleteState)) + { + deleteState = testOptions[AdjustUtils.KeyTestOptionsDeleteState].ToLower() == "true"; + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsNoBackoffWait)) + { + noBackoffWait = testOptions[AdjustUtils.KeyTestOptionsNoBackoffWait].ToLower() == "true"; + } + + Type testLibInterfaceType = Type.GetType("TestLibraryInterface.TestLibraryInterface, TestLibraryInterface"); + Type adjustTestOptionsDtoType = Type.GetType("TestLibraryInterface.AdjustTestOptionsDto, TestLibraryInterface"); + if (testLibInterfaceType == null || adjustTestOptionsDtoType == null) + { + return; + } + + PropertyInfo baseUrlInfo = adjustTestOptionsDtoType.GetProperty("BaseUrl"); + PropertyInfo gdprUrlInfo = adjustTestOptionsDtoType.GetProperty("GdprUrl"); + PropertyInfo basePathInfo = adjustTestOptionsDtoType.GetProperty("BasePath"); + PropertyInfo gdprPathInfo = adjustTestOptionsDtoType.GetProperty("GdprPath"); + PropertyInfo sessionIntervalInMillisecondsInfo = adjustTestOptionsDtoType.GetProperty("SessionIntervalInMilliseconds"); + PropertyInfo subsessionIntervalInMillisecondsInfo = adjustTestOptionsDtoType.GetProperty("SubsessionIntervalInMilliseconds"); + PropertyInfo timerIntervalInMillisecondsInfo = adjustTestOptionsDtoType.GetProperty("TimerIntervalInMilliseconds"); + PropertyInfo timerStartInMillisecondsInfo = adjustTestOptionsDtoType.GetProperty("TimerStartInMilliseconds"); + PropertyInfo deleteStateInfo = adjustTestOptionsDtoType.GetProperty("DeleteState"); + PropertyInfo teardownInfo = adjustTestOptionsDtoType.GetProperty("Teardown"); + PropertyInfo noBackoffWaitInfo = adjustTestOptionsDtoType.GetProperty("NoBackoffWait"); + + object adjustTestOptionsDtoInstance = Activator.CreateInstance(adjustTestOptionsDtoType); + baseUrlInfo.SetValue(adjustTestOptionsDtoInstance, testOptions[AdjustUtils.KeyTestOptionsBaseUrl], null); + gdprUrlInfo.SetValue(adjustTestOptionsDtoInstance, testOptions[AdjustUtils.KeyTestOptionsGdprUrl], null); + basePathInfo.SetValue(adjustTestOptionsDtoInstance, basePath, null); + gdprPathInfo.SetValue(adjustTestOptionsDtoInstance, gdprPath, null); + sessionIntervalInMillisecondsInfo.SetValue(adjustTestOptionsDtoInstance, sessionIntMls, null); + subsessionIntervalInMillisecondsInfo.SetValue(adjustTestOptionsDtoInstance, subsessionIntMls, null); + timerIntervalInMillisecondsInfo.SetValue(adjustTestOptionsDtoInstance, timerIntervalMls, null); + timerStartInMillisecondsInfo.SetValue(adjustTestOptionsDtoInstance, timerStartMls, null); + deleteStateInfo.SetValue(adjustTestOptionsDtoInstance, deleteState, null); + teardownInfo.SetValue(adjustTestOptionsDtoInstance, teardown, null); + noBackoffWaitInfo.SetValue(adjustTestOptionsDtoInstance, noBackoffWait, null); + + MethodInfo setTestOptionsMethodInfo = testLibInterfaceType.GetMethod("SetTestOptions"); + setTestOptionsMethodInfo.Invoke(null, new object[] { adjustTestOptionsDtoInstance }); + } + } +} +#endif diff --git a/Adjust/Windows/AdjustWindows.cs.meta b/Adjust/Windows/AdjustWindows.cs.meta new file mode 100644 index 0000000..2dba026 --- /dev/null +++ b/Adjust/Windows/AdjustWindows.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3427d1638e7de554f822f2758d5efa5d +timeCreated: 1510134931 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/Newtonsoft.Json.dll b/Adjust/Windows/Newtonsoft.Json.dll new file mode 100644 index 0000000..89bc2b8 Binary files /dev/null and b/Adjust/Windows/Newtonsoft.Json.dll differ diff --git a/Adjust/Windows/Newtonsoft.Json.dll.meta b/Adjust/Windows/Newtonsoft.Json.dll.meta new file mode 100644 index 0000000..99f3c9f --- /dev/null +++ b/Adjust/Windows/Newtonsoft.Json.dll.meta @@ -0,0 +1,142 @@ +fileFormatVersion: 2 +guid: dde5cfaaa61544444adb278e3df09051 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + - first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/Stubs.meta b/Adjust/Windows/Stubs.meta new file mode 100644 index 0000000..5031f1b --- /dev/null +++ b/Adjust/Windows/Stubs.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: f843c58f3da8cd04ca908f6ae7cc4584 +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/Stubs/Win10Interface.dll b/Adjust/Windows/Stubs/Win10Interface.dll new file mode 100644 index 0000000..3d92833 Binary files /dev/null and b/Adjust/Windows/Stubs/Win10Interface.dll differ diff --git a/Adjust/Windows/Stubs/Win10Interface.dll.meta b/Adjust/Windows/Stubs/Win10Interface.dll.meta new file mode 100644 index 0000000..21ae70c --- /dev/null +++ b/Adjust/Windows/Stubs/Win10Interface.dll.meta @@ -0,0 +1,142 @@ +fileFormatVersion: 2 +guid: 437f3d4f145f71f48ad0468a8cdd840a +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 1 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + - first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/Stubs/Win81Interface.dll b/Adjust/Windows/Stubs/Win81Interface.dll new file mode 100644 index 0000000..3b577e9 Binary files /dev/null and b/Adjust/Windows/Stubs/Win81Interface.dll differ diff --git a/Adjust/Windows/Stubs/Win81Interface.dll.meta b/Adjust/Windows/Stubs/Win81Interface.dll.meta new file mode 100644 index 0000000..b3c6256 --- /dev/null +++ b/Adjust/Windows/Stubs/Win81Interface.dll.meta @@ -0,0 +1,142 @@ +fileFormatVersion: 2 +guid: 4a3249a2bc5a2fc4b90ec1effe1d74ce +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 1 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + - first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/Stubs/WinWsInterface.dll b/Adjust/Windows/Stubs/WinWsInterface.dll new file mode 100644 index 0000000..610ee9b Binary files /dev/null and b/Adjust/Windows/Stubs/WinWsInterface.dll differ diff --git a/Adjust/Windows/Stubs/WinWsInterface.dll.meta b/Adjust/Windows/Stubs/WinWsInterface.dll.meta new file mode 100644 index 0000000..c9c268b --- /dev/null +++ b/Adjust/Windows/Stubs/WinWsInterface.dll.meta @@ -0,0 +1,142 @@ +fileFormatVersion: 2 +guid: 28d42f4475bd4c9498aea78c129a80b7 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 0 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 1 + Exclude iOS: 1 + Exclude tvOS: 1 + - first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + - first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 1 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + - first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + - first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: x86 + - first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: None + - first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: None + - first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 0 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + - first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + - first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/W81.meta b/Adjust/Windows/W81.meta new file mode 100644 index 0000000..e843641 --- /dev/null +++ b/Adjust/Windows/W81.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 0a2e5ebe768d3b74a9047dc0592c78b1 +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/W81/AdjustWP81.dll b/Adjust/Windows/W81/AdjustWP81.dll new file mode 100644 index 0000000..adf479a Binary files /dev/null and b/Adjust/Windows/W81/AdjustWP81.dll differ diff --git a/Adjust/Windows/W81/AdjustWP81.dll.meta b/Adjust/Windows/W81/AdjustWP81.dll.meta new file mode 100644 index 0000000..760c329 --- /dev/null +++ b/Adjust/Windows/W81/AdjustWP81.dll.meta @@ -0,0 +1,132 @@ +fileFormatVersion: 2 +guid: 1e03a607fa75e4a488d6d61ca75c352a +timeCreated: 1510575008 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: PhoneSDK81 + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/W81/Win81Interface.dll b/Adjust/Windows/W81/Win81Interface.dll new file mode 100644 index 0000000..7dc09b4 Binary files /dev/null and b/Adjust/Windows/W81/Win81Interface.dll differ diff --git a/Adjust/Windows/W81/Win81Interface.dll.meta b/Adjust/Windows/W81/Win81Interface.dll.meta new file mode 100644 index 0000000..94bba2a --- /dev/null +++ b/Adjust/Windows/W81/Win81Interface.dll.meta @@ -0,0 +1,132 @@ +fileFormatVersion: 2 +guid: 72c922127edd0e94b972c6e40580ec90 +timeCreated: 1510575009 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: Assets/Adjust/Windows/Stubs/Win81Interface.dll + SDK: PhoneSDK81 + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/WS.meta b/Adjust/Windows/WS.meta new file mode 100644 index 0000000..9194a83 --- /dev/null +++ b/Adjust/Windows/WS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 200065618516a3b479c4dff78f23cdd9 +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/WS/AdjustWS.dll b/Adjust/Windows/WS/AdjustWS.dll new file mode 100644 index 0000000..7845be9 Binary files /dev/null and b/Adjust/Windows/WS/AdjustWS.dll differ diff --git a/Adjust/Windows/WS/AdjustWS.dll.meta b/Adjust/Windows/WS/AdjustWS.dll.meta new file mode 100644 index 0000000..3a8b3b2 --- /dev/null +++ b/Adjust/Windows/WS/AdjustWS.dll.meta @@ -0,0 +1,132 @@ +fileFormatVersion: 2 +guid: 244b7bed1ea0ae147b5732f948d3e207 +timeCreated: 1510575008 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: SDK81 + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/WS/WinWsInterface.dll b/Adjust/Windows/WS/WinWsInterface.dll new file mode 100644 index 0000000..b07e176 Binary files /dev/null and b/Adjust/Windows/WS/WinWsInterface.dll differ diff --git a/Adjust/Windows/WS/WinWsInterface.dll.meta b/Adjust/Windows/WS/WinWsInterface.dll.meta new file mode 100644 index 0000000..c8b1089 --- /dev/null +++ b/Adjust/Windows/WS/WinWsInterface.dll.meta @@ -0,0 +1,132 @@ +fileFormatVersion: 2 +guid: 35b13abbb89b9874d811856667cc3186 +timeCreated: 1510575009 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: Assets/Adjust/Windows/Stubs/WinWsInterface.dll + SDK: SDK81 + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/WU10.meta b/Adjust/Windows/WU10.meta new file mode 100644 index 0000000..d6949b1 --- /dev/null +++ b/Adjust/Windows/WU10.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: abbcaca8b21383f4eaece6c3b078825a +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/WU10/AdjustUAP10.dll b/Adjust/Windows/WU10/AdjustUAP10.dll new file mode 100644 index 0000000..c407a2e Binary files /dev/null and b/Adjust/Windows/WU10/AdjustUAP10.dll differ diff --git a/Adjust/Windows/WU10/AdjustUAP10.dll.meta b/Adjust/Windows/WU10/AdjustUAP10.dll.meta new file mode 100644 index 0000000..eee9c48 --- /dev/null +++ b/Adjust/Windows/WU10/AdjustUAP10.dll.meta @@ -0,0 +1,146 @@ +fileFormatVersion: 2 +guid: 3b969527d95894f4b8710cce1119c292 +timeCreated: 1509723106 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + Exclude iOS: 1 + Exclude tvOS: 1 + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: UWP + ScriptingBackend: AnyScriptingBackend + data: + first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/WU10/Win10Interface.dll b/Adjust/Windows/WU10/Win10Interface.dll new file mode 100644 index 0000000..4f9a867 Binary files /dev/null and b/Adjust/Windows/WU10/Win10Interface.dll differ diff --git a/Adjust/Windows/WU10/Win10Interface.dll.meta b/Adjust/Windows/WU10/Win10Interface.dll.meta new file mode 100644 index 0000000..63690a8 --- /dev/null +++ b/Adjust/Windows/WU10/Win10Interface.dll.meta @@ -0,0 +1,151 @@ +fileFormatVersion: 2 +guid: 64aebd589aa21cd489368a1570e09acd +timeCreated: 1509723107 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + Exclude iOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + DefaultValueInitialized: true + OS: AnyOS + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: Assets/Adjust/Windows/Stubs/Win10Interface.dll + SDK: UWP + ScriptingBackend: AnyScriptingBackend + data: + first: + iPhone: iOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/WindowsPcl.dll b/Adjust/Windows/WindowsPcl.dll new file mode 100644 index 0000000..0708bc3 Binary files /dev/null and b/Adjust/Windows/WindowsPcl.dll differ diff --git a/Adjust/Windows/WindowsPcl.dll.meta b/Adjust/Windows/WindowsPcl.dll.meta new file mode 100644 index 0000000..44ff1b1 --- /dev/null +++ b/Adjust/Windows/WindowsPcl.dll.meta @@ -0,0 +1,132 @@ +fileFormatVersion: 2 +guid: f29a24c7f8821a04b948fa281beaadc0 +timeCreated: 1509723108 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/Windows/WindowsUap.dll b/Adjust/Windows/WindowsUap.dll new file mode 100644 index 0000000..6a1ce93 Binary files /dev/null and b/Adjust/Windows/WindowsUap.dll differ diff --git a/Adjust/Windows/WindowsUap.dll.meta b/Adjust/Windows/WindowsUap.dll.meta new file mode 100644 index 0000000..4b14581 --- /dev/null +++ b/Adjust/Windows/WindowsUap.dll.meta @@ -0,0 +1,132 @@ +fileFormatVersion: 2 +guid: 50382477c784d8146a4c96803ec33711 +timeCreated: 1509723107 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude WindowsStoreApps: 0 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Windows Store Apps: WindowsStoreApps + second: + enabled: 1 + settings: + CPU: AnyCPU + DontProcess: False + PlaceholderPath: + SDK: AnySDK + ScriptingBackend: AnyScriptingBackend + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS.meta b/Adjust/iOS.meta new file mode 100644 index 0000000..c1433be --- /dev/null +++ b/Adjust/iOS.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 28da4e9eb3d011141b258019c71a8416 +folderAsset: yes +timeCreated: 1578652520 +licenseType: Pro +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJAdRevenue.h b/Adjust/iOS/ADJAdRevenue.h new file mode 100644 index 0000000..4b167ad --- /dev/null +++ b/Adjust/iOS/ADJAdRevenue.h @@ -0,0 +1,80 @@ +// +// ADJAdRevenue.h +// Adjust SDK +// +// Created by Uglješa Erceg (@uerceg) on 13th April 2021 +// Copyright (c) 2021 Adjust GmbH. All rights reserved. +// + +#import + +/** + * @brief Adjust ad revenue class. + */ +@interface ADJAdRevenue : NSObject + +/** + * @brief Ad revenue source value. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *source; + +/** + * @brief Revenue value. + */ +@property (nonatomic, copy, readonly, nonnull) NSNumber *revenue; + +/** + * @brief Currency value. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *currency; + +/** + * @brief Ad impressions count. + */ +@property (nonatomic, copy, readonly, nonnull) NSNumber *adImpressionsCount; + +/** + * @brief Ad revenue network. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *adRevenueNetwork; + +/** + * @brief Ad revenue unit. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *adRevenueUnit; + +/** + * @brief Ad revenue placement. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *adRevenuePlacement; + +/** + * @brief List of partner parameters. + */ +@property (nonatomic, copy, readonly, nonnull) NSDictionary *partnerParameters; + +/** + * @brief List of callback parameters. + */ +@property (nonatomic, copy, readonly, nonnull) NSDictionary *callbackParameters; + + +- (nullable id)initWithSource:(nonnull NSString *)source; + +- (void)setRevenue:(double)amount currency:(nonnull NSString *)currency; + +- (void)setAdImpressionsCount:(int)adImpressionsCount; + +- (void)setAdRevenueNetwork:(nonnull NSString *)adRevenueNetwork; + +- (void)setAdRevenueUnit:(nonnull NSString *)adRevenueUnit; + +- (void)setAdRevenuePlacement:(nonnull NSString *)adRevenuePlacement; + +- (void)addCallbackParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +- (void)addPartnerParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +- (BOOL)isValid; + +@end diff --git a/Adjust/iOS/ADJAdRevenue.h.meta b/Adjust/iOS/ADJAdRevenue.h.meta new file mode 100644 index 0000000..7bf1899 --- /dev/null +++ b/Adjust/iOS/ADJAdRevenue.h.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: f382ac4ce0db3407baf40dd118470093 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJAttribution.h b/Adjust/iOS/ADJAttribution.h new file mode 100644 index 0000000..845a909 --- /dev/null +++ b/Adjust/iOS/ADJAttribution.h @@ -0,0 +1,99 @@ +// +// ADJAttribution.h +// adjust +// +// Created by Pedro Filipe on 29/10/14. +// Copyright (c) 2014 adjust GmbH. All rights reserved. +// + +#import + +/** + * @brief Adjust attribution object. + */ +@interface ADJAttribution : NSObject + +/** + * @brief Tracker token. + */ +@property (nonatomic, copy, nullable) NSString *trackerToken; + +/** + * @brief Tracker name. + */ +@property (nonatomic, copy, nullable) NSString *trackerName; + +/** + * @brief Network name. + */ +@property (nonatomic, copy, nullable) NSString *network; + +/** + * @brief Campaign name. + */ +@property (nonatomic, copy, nullable) NSString *campaign; + +/** + * @brief Adgroup name. + */ +@property (nonatomic, copy, nullable) NSString *adgroup; + +/** + * @brief Creative name. + */ +@property (nonatomic, copy, nullable) NSString *creative; + +/** + * @brief Click label content. + */ +@property (nonatomic, copy, nullable) NSString *clickLabel; + +/** + * @brief Adjust identifier value. + */ +@property (nonatomic, copy, nullable) NSString *adid; + +/** + * @brief Cost type. + */ +@property (nonatomic, copy, nullable) NSString *costType; + +/** + * @brief Cost amount. + */ +@property (nonatomic, copy, nullable) NSNumber *costAmount; + +/** + * @brief Cost currency. + */ +@property (nonatomic, copy, nullable) NSString *costCurrency; + +/** + * @brief Make attribution object. + * + * @param jsonDict Dictionary holding attribution key value pairs. + * @param adid Adjust identifier value. + * + * @return Adjust attribution object. + */ ++ (nullable ADJAttribution *)dataWithJsonDict:(nonnull NSDictionary *)jsonDict adid:(nonnull NSString *)adid; + +- (nullable id)initWithJsonDict:(nonnull NSDictionary *)jsonDict adid:(nonnull NSString *)adid; + +/** + * @brief Check if given attribution equals current one. + * + * @param attribution Attribution object to be compared with current one. + * + * @return Boolean indicating whether two attribution objects are the equal. + */ +- (BOOL)isEqualToAttribution:(nonnull ADJAttribution *)attribution; + +/** + * @brief Get attribution value as dictionary. + * + * @return Dictionary containing attribution as key-value pairs. + */ +- (nullable NSDictionary *)dictionary; + +@end diff --git a/Adjust/iOS/ADJAttribution.h.meta b/Adjust/iOS/ADJAttribution.h.meta new file mode 100644 index 0000000..339eebc --- /dev/null +++ b/Adjust/iOS/ADJAttribution.h.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: 7dddf8beb94ee49a7aba11b4e22e059c +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJConfig.h b/Adjust/iOS/ADJConfig.h new file mode 100644 index 0000000..d07993a --- /dev/null +++ b/Adjust/iOS/ADJConfig.h @@ -0,0 +1,294 @@ +// +// ADJConfig.h +// adjust +// +// Created by Pedro Filipe on 30/10/14. +// Copyright (c) 2014 adjust GmbH. All rights reserved. +// + +#import + +#import "ADJLogger.h" +#import "ADJAttribution.h" +#import "ADJEventSuccess.h" +#import "ADJEventFailure.h" +#import "ADJSessionSuccess.h" +#import "ADJSessionFailure.h" + +/** + * @brief Optional delegate that will get informed about tracking results. + */ +@protocol AdjustDelegate + +@optional + +/** + * @brief Optional delegate method that gets called when the attribution information changed. + * + * @param attribution The attribution information. + * + * @note See ADJAttribution for details. + */ +- (void)adjustAttributionChanged:(nullable ADJAttribution *)attribution; + +/** + * @brief Optional delegate method that gets called when an event is tracked with success. + * + * @param eventSuccessResponseData The response information from tracking with success + * + * @note See ADJEventSuccess for details. + */ +- (void)adjustEventTrackingSucceeded:(nullable ADJEventSuccess *)eventSuccessResponseData; + +/** + * @brief Optional delegate method that gets called when an event is tracked with failure. + * + * @param eventFailureResponseData The response information from tracking with failure + * + * @note See ADJEventFailure for details. + */ +- (void)adjustEventTrackingFailed:(nullable ADJEventFailure *)eventFailureResponseData; + +/** + * @brief Optional delegate method that gets called when an session is tracked with success. + * + * @param sessionSuccessResponseData The response information from tracking with success + * + * @note See ADJSessionSuccess for details. + */ +- (void)adjustSessionTrackingSucceeded:(nullable ADJSessionSuccess *)sessionSuccessResponseData; + +/** + * @brief Optional delegate method that gets called when an session is tracked with failure. + * + * @param sessionFailureResponseData The response information from tracking with failure + * + * @note See ADJSessionFailure for details. + */ +- (void)adjustSessionTrackingFailed:(nullable ADJSessionFailure *)sessionFailureResponseData; + +/** + * @brief Optional delegate method that gets called when a deferred deep link is about to be opened by the adjust SDK. + * + * @param deeplink The deep link url that was received by the adjust SDK to be opened. + * + * @return Boolean that indicates whether the deep link should be opened by the adjust SDK or not. + */ +- (BOOL)adjustDeeplinkResponse:(nullable NSURL *)deeplink; + +/** + * @brief Optional SKAdNetwork pre 4.0 style delegate method that gets called when Adjust SDK sets conversion value for the user. + * + * @param conversionValue Conversion value used by Adjust SDK to invoke updateConversionValue: API. + */ +- (void)adjustConversionValueUpdated:(nullable NSNumber *)conversionValue; + +/** + * @brief Optional SKAdNetwork 4.0 style delegate method that gets called when Adjust SDK sets conversion value for the user. + * You can use this callback even with using pre 4.0 SKAdNetwork. + * In that case you can expect coarseValue and lockWindow values to be nil. + * + * @param fineValue Conversion value set by Adjust SDK. + * @param coarseValue Coarse value set by Adjust SDK. + * @param lockWindow Lock window set by Adjust SDK. + */ +- (void)adjustConversionValueUpdated:(nullable NSNumber *)fineValue + coarseValue:(nullable NSString *)coarseValue + lockWindow:(nullable NSNumber *)lockWindow; + +@end + +/** + * @brief Adjust configuration object class. + */ +@interface ADJConfig : NSObject + +/** + * @brief SDK prefix. + * + * @note Not to be used by users, intended for non-native adjust SDKs only. + */ +@property (nonatomic, copy, nullable) NSString *sdkPrefix; + +/** + * @brief Default tracker to attribute organic installs to (optional). + */ +@property (nonatomic, copy, nullable) NSString *defaultTracker; + +@property (nonatomic, copy, nullable) NSString *externalDeviceId; + +/** + * @brief Adjust app token. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *appToken; + +/** + * @brief Adjust environment variable. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *environment; + +/** + * @brief Change the verbosity of Adjust's logs. + * + * @note You can increase or reduce the amount of logs from Adjust by passing + * one of the following parameters. Use ADJLogLevelSuppress to disable all logging. + * The desired minimum log level (default: info) + * Must be one of the following: + * - ADJLogLevelVerbose (enable all logging) + * - ADJLogLevelDebug (enable more logging) + * - ADJLogLevelInfo (the default) + * - ADJLogLevelWarn (disable info logging) + * - ADJLogLevelError (disable warnings as well) + * - ADJLogLevelAssert (disable errors as well) + * - ADJLogLevelSuppress (suppress all logging) + */ +@property (nonatomic, assign) ADJLogLevel logLevel; + +/** + * @brief Enable event buffering if your app triggers a lot of events. + * When enabled, events get buffered and only get tracked each + * minute. Buffered events are still persisted, of course. + */ +@property (nonatomic, assign) BOOL eventBufferingEnabled; + +/** + * @brief Set the optional delegate that will inform you about attribution or events. + * + * @note See the AdjustDelegate declaration above for details. + */ +@property (nonatomic, weak, nullable) NSObject *delegate; + +/** + * @brief Enables sending in the background. + */ +@property (nonatomic, assign) BOOL sendInBackground; + +/** + * @brief Enables/disables reading of iAd framework data needed for ASA tracking. + */ +@property (nonatomic, assign) BOOL allowiAdInfoReading DEPRECATED_MSG_ATTRIBUTE("Apple Search Ads attribution with usage of iAd.framework has been sunset by Apple as of February 7th 2023"); + +/** + * @brief Enables/disables reading of AdServices framework data needed for attribution. + */ +@property (nonatomic, assign) BOOL allowAdServicesInfoReading; + +/** + * @brief Enables/disables reading of IDFA parameter. + */ +@property (nonatomic, assign) BOOL allowIdfaReading; + +/** + * @brief Enables delayed start of the SDK. + */ +@property (nonatomic, assign) double delayStart; + +/** + * @brief Define how many seconds to wait for ATT status before sending the first data. + */ +@property (nonatomic, assign) NSUInteger attConsentWaitingInterval; + +/** + * @brief User agent for the requests. + */ +@property (nonatomic, copy, nullable) NSString *userAgent; + +/** + * @brief Set if the device is known. + */ +@property (nonatomic, assign) BOOL isDeviceKnown; + +/** + * @brief Set if cost data is needed in attribution response. + */ +@property (nonatomic, assign) BOOL needsCost; + +/** + * @brief Adjust app secret id. + */ +@property (nonatomic, copy, readonly, nullable) NSString *secretId; + +/** + * @brief Adjust app secret. + */ +@property (nonatomic, copy, readonly, nullable) NSString *appSecret; + +/** + * @brief Adjust set app secret. + */ +- (void)setAppSecret:(NSUInteger)secretId + info1:(NSUInteger)info1 + info2:(NSUInteger)info2 + info3:(NSUInteger)info3 + info4:(NSUInteger)info4; + + +@property (nonatomic, assign, readonly) BOOL isSKAdNetworkHandlingActive; + +- (void)deactivateSKAdNetworkHandling; + +/** + * @brief Adjust url strategy. + */ +@property (nonatomic, copy, readwrite, nullable) NSString *urlStrategy; + +/** + * @brief Enables/disables linkMe + */ +@property (nonatomic, assign) BOOL linkMeEnabled; + +/** + * @brief Get configuration object for the initialization of the Adjust SDK. + * + * @param appToken The App Token of your app. This unique identifier can + * be found it in your dashboard at http://adjust.com and should always + * be 12 characters long. + * @param environment The current environment your app. We use this environment to + * distinguish between real traffic and artificial traffic from test devices. + * It is very important that you keep this value meaningful at all times! + * Especially if you are tracking revenue. + * + * @returns Adjust configuration object. + */ ++ (nullable ADJConfig *)configWithAppToken:(nonnull NSString *)appToken + environment:(nonnull NSString *)environment; + +- (nullable id)initWithAppToken:(nonnull NSString *)appToken + environment:(nonnull NSString *)environment; + +/** + * @brief Configuration object for the initialization of the Adjust SDK. + * + * @param appToken The App Token of your app. This unique identifier can + * be found it in your dashboard at http://adjust.com and should always + * be 12 characters long. + * @param environment The current environment your app. We use this environment to + * distinguish between real traffic and artificial traffic from test devices. + * It is very important that you keep this value meaningful at all times! + * Especially if you are tracking revenue. + * @param allowSuppressLogLevel If set to true, it allows usage of ADJLogLevelSuppress + * and replaces the default value for production environment. + * + * @returns Adjust configuration object. + */ ++ (nullable ADJConfig *)configWithAppToken:(nonnull NSString *)appToken + environment:(nonnull NSString *)environment + allowSuppressLogLevel:(BOOL)allowSuppressLogLevel; + +- (nullable id)initWithAppToken:(nonnull NSString *)appToken + environment:(nonnull NSString *)environment + allowSuppressLogLevel:(BOOL)allowSuppressLogLevel; + +/** + * @brief Check if adjust configuration object is valid. + * + * @return Boolean indicating whether adjust config object is valid or not. + */ +- (BOOL)isValid; + +/** + * @brief Enable COPPA (Children's Online Privacy Protection Act) compliant for the application. + */ +@property (nonatomic, assign) BOOL coppaCompliantEnabled; + +@end diff --git a/Adjust/iOS/ADJConfig.h.meta b/Adjust/iOS/ADJConfig.h.meta new file mode 100644 index 0000000..62c3751 --- /dev/null +++ b/Adjust/iOS/ADJConfig.h.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: 0c958f3cabffd44b6a58b8e0621ee82e +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJEvent.h b/Adjust/iOS/ADJEvent.h new file mode 100644 index 0000000..a95e7d4 --- /dev/null +++ b/Adjust/iOS/ADJEvent.h @@ -0,0 +1,159 @@ +// +// ADJEvent.h +// adjust +// +// Created by Pedro Filipe on 15/10/14. +// Copyright (c) 2014 adjust GmbH. All rights reserved. +// + +#import + +/** + * @brief Adjust event class. + */ +@interface ADJEvent : NSObject + +/** + * @brief Revenue attached to the event. + */ +@property (nonatomic, copy, readonly, nonnull) NSNumber *revenue; + +/** + * @brief Event token. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *eventToken; + +/** + * @brief IAP transaction ID. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *transactionId; + +/** + * @brief Custom user defined event ID. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *callbackId; + +/** + * @brief Currency value. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *currency; + +/** + * @brief IAP receipt. + */ +@property (nonatomic, copy, readonly, nonnull) NSData *receipt; + +/** + * @brief List of partner parameters. + */ +@property (nonatomic, readonly, nonnull) NSDictionary *partnerParameters; + +/** + * @brief List of callback parameters. + */ +@property (nonatomic, readonly, nonnull) NSDictionary *callbackParameters; + +/** + * @brief Is the given receipt empty. + */ +@property (nonatomic, assign, readonly) BOOL emptyReceipt; + +/** + * @brief IAP product ID. + */ +@property (nonatomic, copy, readonly, nonnull) NSString *productId; + +/** + * @brief Create Event object with event token. + * + * @param eventToken Event token that is created in the dashboard + * at http://adjust.com and should be six characters long. + */ ++ (nullable ADJEvent *)eventWithEventToken:(nonnull NSString *)eventToken; + +- (nullable id)initWithEventToken:(nonnull NSString *)eventToken; + +/** + * @brief Add a key-pair to a callback URL. + * + * @param key String key in the callback URL. + * @param value String value of the key in the Callback URL. + * + * @note In your dashboard at http://adjust.com you can assign a callback URL to each + * event type. That URL will get called every time the event is triggered. On + * top of that you can add callback parameters to the following method that + * will be forwarded to these callbacks. + */ +- (void)addCallbackParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +/** + * @brief Add a key-pair to be fowarded to a partner. + * + * @param key String key to be fowarded to the partner. + * @param value String value of the key to be fowarded to the partner. + */ +- (void)addPartnerParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +/** + * @brief Set the revenue and associated currency of the event. + * + * @param amount The amount in units (example: for 1.50 EUR is 1.5). + * @param currency String of the currency with ISO 4217 format. + * It should be 3 characters long (example: for 1.50 EUR is @"EUR"). + * + * @note The event can contain some revenue. The amount revenue is measured in units. + * It must include a currency in the ISO 4217 format. + */ +- (void)setRevenue:(double)amount currency:(nonnull NSString *)currency; + +/** + * @brief Set the transaction ID of a In-App Purchases to avoid revenue duplications. + * + * @note A transaction ID can be used to avoid duplicate revenue events. The last ten + * transaction identifiers are remembered. + * + * @param transactionId The identifier used to avoid duplicate revenue events. + */ +- (void)setTransactionId:(nonnull NSString *)transactionId; + +/** + * @brief Set the custom user defined ID for the event which will be reported in + * success/failure callbacks. + * + * @param callbackId Custom user defined identifier for the event + */ +- (void)setCallbackId:(nonnull NSString *)callbackId; + +/** + * @brief Set the product ID of a In-App Purchases to perform IAP verification. + * + * @param productId The product ID of the purchased item. + */ +- (void)setProductId:(NSString * _Nonnull)productId; + +/** + * @brief Set the receipt of a In-App Purchases to perform IAP verification. + * + * @param receipt The receipt obtained after successful IAP. + */ +- (void)setReceipt:(NSData * _Nonnull)receipt; + +/** + * @brief Check if created adjust event object is valid. + * + * @return Boolean indicating whether the adjust event object is valid or not. + */ +- (BOOL)isValid; + +/** + * @brief Validate a in-app-purchase receipt. + * + * @param receipt The receipt to validate. + * @param transactionId The identifier used to validate the receipt and to avoid duplicate revenue events. + * + * @note This method is obsolete and should not be used. + * For more information, visit: https://github.com/adjust/ios_purchase_sdk + */ +- (void)setReceipt:(nonnull NSData *)receipt transactionId:(nonnull NSString *)transactionId; + +@end diff --git a/Adjust/iOS/ADJEvent.h.meta b/Adjust/iOS/ADJEvent.h.meta new file mode 100644 index 0000000..9191a16 --- /dev/null +++ b/Adjust/iOS/ADJEvent.h.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: 426362cccd2154c908b504e138832851 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJEventFailure.h b/Adjust/iOS/ADJEventFailure.h new file mode 100644 index 0000000..ff272bb --- /dev/null +++ b/Adjust/iOS/ADJEventFailure.h @@ -0,0 +1,55 @@ +// +// ADJEventFailure.h +// adjust +// +// Created by Pedro Filipe on 17/02/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJEventFailure : NSObject + +/** + * @brief Message from the adjust backend. + */ +@property (nonatomic, copy) NSString * message; + +/** + * @brief Timestamp from the adjust backend. + */ +@property (nonatomic, copy) NSString * timeStamp; + +/** + * @brief Adjust identifier of the device. + */ +@property (nonatomic, copy) NSString * adid; + +/** + * @brief Event token value. + */ +@property (nonatomic, copy) NSString * eventToken; + +/** + * @brief Event callback ID. + */ +@property (nonatomic, copy) NSString *callbackId; + +/** + * @brief Information whether sending of the package will be retried or not. + */ +@property (nonatomic, assign) BOOL willRetry; + +/** + * @brief Backend response in JSON format. + */ +@property (nonatomic, strong) NSDictionary *jsonResponse; + +/** + * @brief Initialisation method. + * + * @return ADJEventFailure instance. + */ ++ (ADJEventFailure *)eventFailureResponseData; + +@end diff --git a/Adjust/iOS/ADJEventFailure.h.meta b/Adjust/iOS/ADJEventFailure.h.meta new file mode 100644 index 0000000..f495998 --- /dev/null +++ b/Adjust/iOS/ADJEventFailure.h.meta @@ -0,0 +1,147 @@ +fileFormatVersion: 2 +guid: b274a5403f60c4e7ca731709d03d1ee8 +timeCreated: 1458122523 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJEventSuccess.h b/Adjust/iOS/ADJEventSuccess.h new file mode 100644 index 0000000..34214e2 --- /dev/null +++ b/Adjust/iOS/ADJEventSuccess.h @@ -0,0 +1,50 @@ +// +// ADJEventSuccess.h +// adjust +// +// Created by Pedro Filipe on 17/02/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJEventSuccess : NSObject + +/** + * @brief Message from the adjust backend. + */ +@property (nonatomic, copy) NSString *message; + +/** + * @brief Timestamp from the adjust backend. + */ +@property (nonatomic, copy) NSString *timeStamp; + +/** + * @brief Adjust identifier of the device. + */ +@property (nonatomic, copy) NSString *adid; + +/** + * @brief Event token value. + */ +@property (nonatomic, copy) NSString *eventToken; + +/** + * @brief Event callback ID. + */ +@property (nonatomic, copy) NSString *callbackId; + +/** + * @brief Backend response in JSON format. + */ +@property (nonatomic, strong) NSDictionary *jsonResponse; + +/** + * @brief Initialisation method. + * + * @return ADJEventSuccess instance. + */ ++ (ADJEventSuccess *)eventSuccessResponseData; + +@end diff --git a/Adjust/iOS/ADJEventSuccess.h.meta b/Adjust/iOS/ADJEventSuccess.h.meta new file mode 100644 index 0000000..01ed5f3 --- /dev/null +++ b/Adjust/iOS/ADJEventSuccess.h.meta @@ -0,0 +1,147 @@ +fileFormatVersion: 2 +guid: 65ff11a24f3b043759b70623a745a004 +timeCreated: 1458122523 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJLinkResolution.h b/Adjust/iOS/ADJLinkResolution.h new file mode 100644 index 0000000..469b258 --- /dev/null +++ b/Adjust/iOS/ADJLinkResolution.h @@ -0,0 +1,17 @@ +// +// ADJLinkResolution.h +// Adjust +// +// Created by Pedro S. on 26.04.21. +// Copyright © 2021 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJLinkResolution : NSObject + ++ (void)resolveLinkWithUrl:(nonnull NSURL *)url + resolveUrlSuffixArray:(nullable NSArray *)resolveUrlSuffixArray + callback:(nonnull void (^)(NSURL *_Nullable resolvedLink))callback; + +@end diff --git a/Adjust/iOS/ADJLinkResolution.h.meta b/Adjust/iOS/ADJLinkResolution.h.meta new file mode 100644 index 0000000..882981c --- /dev/null +++ b/Adjust/iOS/ADJLinkResolution.h.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: c6eb7389a3c5c4df6ba3506c8fd4ad2c +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJLogger.h b/Adjust/iOS/ADJLogger.h new file mode 100644 index 0000000..95bb743 --- /dev/null +++ b/Adjust/iOS/ADJLogger.h @@ -0,0 +1,84 @@ +// +// ADJLogger.h +// Adjust +// +// Created by Christian Wellenbrock on 2012-11-15. +// Copyright (c) 2012-2014 adjust GmbH. All rights reserved. +// +#import + +typedef enum { + ADJLogLevelVerbose = 1, + ADJLogLevelDebug = 2, + ADJLogLevelInfo = 3, + ADJLogLevelWarn = 4, + ADJLogLevelError = 5, + ADJLogLevelAssert = 6, + ADJLogLevelSuppress = 7 +} ADJLogLevel; + +/** + * @brief Adjust logger protocol. + */ +@protocol ADJLogger + +/** + * @brief Set the log level of the SDK. + * + * @param logLevel Level of the logs to be displayed. + */ +- (void)setLogLevel:(ADJLogLevel)logLevel isProductionEnvironment:(BOOL)isProductionEnvironment; + +/** + * @brief Prevent log level changes. + */ +- (void)lockLogLevel; + +/** + * @brief Print verbose logs. + */ +- (void)verbose:(nonnull NSString *)message, ...; + +/** + * @brief Print debug logs. + */ +- (void)debug:(nonnull NSString *)message, ...; + +/** + * @brief Print info logs. + */ +- (void)info:(nonnull NSString *)message, ...; + +/** + * @brief Print warn logs. + */ +- (void)warn:(nonnull NSString *)message, ...; +- (void)warnInProduction:(nonnull NSString *)message, ...; + +/** + * @brief Print error logs. + */ +- (void)error:(nonnull NSString *)message, ...; + +/** + * @brief Print assert logs. + */ +- (void)assert:(nonnull NSString *)message, ...; + +@end + +/** + * @brief Adjust logger class. + */ +@interface ADJLogger : NSObject + +/** + * @brief Convert log level string to ADJLogLevel enumeration. + * + * @param logLevelString Log level as string. + * + * @return Log level as ADJLogLevel enumeration. + */ ++ (ADJLogLevel)logLevelFromString:(nonnull NSString *)logLevelString; + +@end diff --git a/Adjust/iOS/ADJLogger.h.meta b/Adjust/iOS/ADJLogger.h.meta new file mode 100644 index 0000000..71c2cd1 --- /dev/null +++ b/Adjust/iOS/ADJLogger.h.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: 79bead718d24d4562b045c8fb25619ab +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJPurchase.h b/Adjust/iOS/ADJPurchase.h new file mode 100644 index 0000000..f1b54c9 --- /dev/null +++ b/Adjust/iOS/ADJPurchase.h @@ -0,0 +1,27 @@ +// +// ADJPurchase.h +// Adjust +// +// Created by Uglješa Erceg (@uerceg) on May 25th 2023. +// Copyright © 2023 Adjust. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface ADJPurchase : NSObject + +@property (nonatomic, copy, readonly, nonnull) NSString *transactionId; + +@property (nonatomic, copy, readonly, nonnull) NSData *receipt; + +@property (nonatomic, copy, readonly, nonnull) NSString *productId; + +- (nullable id)initWithTransactionId:(nonnull NSString *)transactionId + productId:(nonnull NSString *)productId + andReceipt:(nonnull NSData *)receipt; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Adjust/iOS/ADJPurchase.h.meta b/Adjust/iOS/ADJPurchase.h.meta new file mode 100644 index 0000000..4564a82 --- /dev/null +++ b/Adjust/iOS/ADJPurchase.h.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: ff1d54f5d01f3401a91bed3817d0dc25 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJPurchaseVerificationResult.h b/Adjust/iOS/ADJPurchaseVerificationResult.h new file mode 100644 index 0000000..3e8f404 --- /dev/null +++ b/Adjust/iOS/ADJPurchaseVerificationResult.h @@ -0,0 +1,38 @@ +// +// ADJPurchaseVerificationResult.h +// Adjust +// +// Created by Uglješa Erceg (@uerceg) on May 25th 2023. +// Copyright © 2023 Adjust. All rights reserved. +// + +#import + +NS_ASSUME_NONNULL_BEGIN + +@interface ADJPurchaseVerificationResult : NSObject + +/** + * @property message + * + * @brief Text message about current state of receipt verification. + */ +@property (nonatomic, copy) NSString *message; + +/** + * @property code + * + * @brief Response code returned from Adjust backend server. + */ +@property (nonatomic, assign) int code; + +/** + * @property verificationStatus + * + * @brief State of verification (success / failure / unknown / not verified) + */ +@property (nonatomic, copy) NSString *verificationStatus; + +@end + +NS_ASSUME_NONNULL_END diff --git a/Adjust/iOS/ADJPurchaseVerificationResult.h.meta b/Adjust/iOS/ADJPurchaseVerificationResult.h.meta new file mode 100644 index 0000000..673ca9b --- /dev/null +++ b/Adjust/iOS/ADJPurchaseVerificationResult.h.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: 534a8868e882b4b99b1a9b98440bfedb +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJSessionFailure.h b/Adjust/iOS/ADJSessionFailure.h new file mode 100644 index 0000000..2ad9f20 --- /dev/null +++ b/Adjust/iOS/ADJSessionFailure.h @@ -0,0 +1,45 @@ +// +// ADJFailureResponseData.h +// adjust +// +// Created by Pedro Filipe on 05/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJSessionFailure : NSObject + +/** + * @brief Message from the adjust backend. + */ +@property (nonatomic, copy, nullable) NSString *message; + +/** + * @brief Timestamp from the adjust backend. + */ +@property (nonatomic, copy, nullable) NSString *timeStamp; + +/** + * @brief Adjust identifier of the device. + */ +@property (nonatomic, copy, nullable) NSString *adid; + +/** + * @brief Information whether sending of the package will be retried or not. + */ +@property (nonatomic, assign) BOOL willRetry; + +/** + * @brief Backend response in JSON format. + */ +@property (nonatomic, strong, nullable) NSDictionary *jsonResponse; + +/** + * @brief Initialisation method. + * + * @return ADJSessionFailure instance. + */ ++ (nullable ADJSessionFailure *)sessionFailureResponseData; + +@end diff --git a/Adjust/iOS/ADJSessionFailure.h.meta b/Adjust/iOS/ADJSessionFailure.h.meta new file mode 100644 index 0000000..d2bdd33 --- /dev/null +++ b/Adjust/iOS/ADJSessionFailure.h.meta @@ -0,0 +1,147 @@ +fileFormatVersion: 2 +guid: cb5e6ddbbcae24783900c75db92ead71 +timeCreated: 1458122523 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJSessionSuccess.h b/Adjust/iOS/ADJSessionSuccess.h new file mode 100644 index 0000000..8d6a04c --- /dev/null +++ b/Adjust/iOS/ADJSessionSuccess.h @@ -0,0 +1,40 @@ +// +// ADJSuccessResponseData.h +// adjust +// +// Created by Pedro Filipe on 05/01/16. +// Copyright © 2016 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJSessionSuccess : NSObject + +/** + * @brief Message from the adjust backend. + */ +@property (nonatomic, copy, nullable) NSString *message; + +/** + * @brief Timestamp from the adjust backend. + */ +@property (nonatomic, copy, nullable) NSString *timeStamp; + +/** + * @brief Adjust identifier of the device. + */ +@property (nonatomic, copy, nullable) NSString *adid; + +/** + * @brief Backend response in JSON format. + */ +@property (nonatomic, strong, nullable) NSDictionary *jsonResponse; + +/** + * @brief Initialisation method. + * + * @return ADJSessionSuccess instance. + */ ++ (nullable ADJSessionSuccess *)sessionSuccessResponseData; + +@end diff --git a/Adjust/iOS/ADJSessionSuccess.h.meta b/Adjust/iOS/ADJSessionSuccess.h.meta new file mode 100644 index 0000000..9b169a3 --- /dev/null +++ b/Adjust/iOS/ADJSessionSuccess.h.meta @@ -0,0 +1,147 @@ +fileFormatVersion: 2 +guid: 65455f64c4f194d6fb1e959ad638f311 +timeCreated: 1458122523 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJSubscription.h b/Adjust/iOS/ADJSubscription.h new file mode 100644 index 0000000..92f5395 --- /dev/null +++ b/Adjust/iOS/ADJSubscription.h @@ -0,0 +1,44 @@ +// +// ADJSubscription.h +// Adjust +// +// Created by Uglješa Erceg on 16.04.20. +// Copyright © 2020 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJSubscription : NSObject + +@property (nonatomic, copy, readonly, nonnull) NSDecimalNumber *price; // [M] revenue + +@property (nonatomic, copy, readonly, nonnull) NSString *currency; // [M] currency + +@property (nonatomic, copy, readonly, nonnull) NSString *transactionId; // [M] transaction_id + +@property (nonatomic, copy, readonly, nonnull) NSData *receipt; // [M] receipt + +@property (nonatomic, copy, readonly, nonnull) NSString *billingStore; // [M] billing_store + +@property (nonatomic, copy, readonly, nonnull) NSDate *transactionDate; // [O] transaction_date + +@property (nonatomic, copy, readonly, nonnull) NSString *salesRegion; // [O] sales_region + +@property (nonatomic, copy, readonly, nonnull) NSDictionary *callbackParameters; // [O] callback_params + +@property (nonatomic, copy, readonly, nonnull) NSDictionary *partnerParameters; // [O] partner_params + +- (nullable id)initWithPrice:(nonnull NSDecimalNumber *)price + currency:(nonnull NSString *)currency + transactionId:(nonnull NSString *)transactionId + andReceipt:(nonnull NSData *)receipt; + +- (void)setTransactionDate:(nonnull NSDate *)transactionDate; + +- (void)setSalesRegion:(nonnull NSString *)salesRegion; + +- (void)addCallbackParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +- (void)addPartnerParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +@end diff --git a/Adjust/iOS/ADJSubscription.h.meta b/Adjust/iOS/ADJSubscription.h.meta new file mode 100644 index 0000000..6738562 --- /dev/null +++ b/Adjust/iOS/ADJSubscription.h.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: 15bc7056a22f34382aea2497343c3509 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/ADJThirdPartySharing.h b/Adjust/iOS/ADJThirdPartySharing.h new file mode 100644 index 0000000..29bceff --- /dev/null +++ b/Adjust/iOS/ADJThirdPartySharing.h @@ -0,0 +1,28 @@ +// +// ADJThirdPartySharing.h +// AdjustSdk +// +// Created by Pedro S. on 02.12.20. +// Copyright © 2020 adjust GmbH. All rights reserved. +// + +#import + +@interface ADJThirdPartySharing : NSObject + +@property (nonatomic, nullable, readonly, strong) NSNumber *enabled; +@property (nonatomic, nonnull, readonly, strong) NSMutableDictionary *granularOptions; +@property (nonatomic, nonnull, readonly, strong) NSMutableDictionary *partnerSharingSettings; + +- (nullable id)initWithIsEnabledNumberBool:(nullable NSNumber *)isEnabledNumberBool; + +- (void)addGranularOption:(nonnull NSString *)partnerName + key:(nonnull NSString *)key + value:(nonnull NSString *)value; + +- (void)addPartnerSharingSetting:(nonnull NSString *)partnerName + key:(nonnull NSString *)key + value:(BOOL)value; + +@end + diff --git a/Adjust/iOS/ADJThirdPartySharing.h.meta b/Adjust/iOS/ADJThirdPartySharing.h.meta new file mode 100644 index 0000000..b524801 --- /dev/null +++ b/Adjust/iOS/ADJThirdPartySharing.h.meta @@ -0,0 +1,24 @@ +fileFormatVersion: 2 +guid: e34005ea3283c4e88bf3dc78e9e845e4 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/Adjust.h b/Adjust/iOS/Adjust.h new file mode 100644 index 0000000..361cd83 --- /dev/null +++ b/Adjust/iOS/Adjust.h @@ -0,0 +1,483 @@ +// +// Adjust.h +// Adjust SDK +// +// V4.36.0 +// Created by Christian Wellenbrock (@wellle) on 23rd July 2013. +// Copyright (c) 2012-2021 Adjust GmbH. All rights reserved. +// + +#import "ADJEvent.h" +#import "ADJConfig.h" +#import "ADJAttribution.h" +#import "ADJSubscription.h" +#import "ADJThirdPartySharing.h" +#import "ADJAdRevenue.h" +#import "ADJLinkResolution.h" +#import "ADJPurchase.h" +#import "ADJPurchaseVerificationResult.h" + +@interface AdjustTestOptions : NSObject + +@property (nonatomic, copy, nullable) NSString *baseUrl; +@property (nonatomic, copy, nullable) NSString *gdprUrl; +@property (nonatomic, copy, nullable) NSString *subscriptionUrl; +@property (nonatomic, copy, nullable) NSString *purchaseVerificationUrl; +@property (nonatomic, copy, nullable) NSString *extraPath; +@property (nonatomic, copy, nullable) NSNumber *timerIntervalInMilliseconds; +@property (nonatomic, copy, nullable) NSNumber *timerStartInMilliseconds; +@property (nonatomic, copy, nullable) NSNumber *sessionIntervalInMilliseconds; +@property (nonatomic, copy, nullable) NSNumber *subsessionIntervalInMilliseconds; +@property (nonatomic, assign) BOOL teardown; +@property (nonatomic, assign) BOOL deleteState; +@property (nonatomic, assign) BOOL noBackoffWait; +@property (nonatomic, assign) BOOL adServicesFrameworkEnabled; +@property (nonatomic, assign) BOOL enableSigning; +@property (nonatomic, assign) BOOL disableSigning; + +@end + +/** + * Constants for our supported tracking environments. + */ +extern NSString * __nonnull const ADJEnvironmentSandbox; +extern NSString * __nonnull const ADJEnvironmentProduction; + +/** + * Constants for supported ad revenue sources. + */ +extern NSString * __nonnull const ADJAdRevenueSourceAppLovinMAX; +extern NSString * __nonnull const ADJAdRevenueSourceMopub; +extern NSString * __nonnull const ADJAdRevenueSourceAdMob; +extern NSString * __nonnull const ADJAdRevenueSourceIronSource; +extern NSString * __nonnull const ADJAdRevenueSourceAdMost; +extern NSString * __nonnull const ADJAdRevenueSourceUnity; +extern NSString * __nonnull const ADJAdRevenueSourceHeliumChartboost; +extern NSString * __nonnull const ADJAdRevenueSourcePublisher; +extern NSString * __nonnull const ADJAdRevenueSourceTopOn; +extern NSString * __nonnull const ADJAdRevenueSourceADX; + +/** + * Constants for country app's URL strategies. + */ +extern NSString * __nonnull const ADJUrlStrategyIndia; +extern NSString * __nonnull const ADJUrlStrategyChina; +extern NSString * __nonnull const ADJUrlStrategyCn; +extern NSString * __nonnull const ADJUrlStrategyCnOnly; +extern NSString * __nonnull const ADJDataResidencyEU; +extern NSString * __nonnull const ADJDataResidencyTR; +extern NSString * __nonnull const ADJDataResidencyUS; + +/** + * @brief The main interface to Adjust. + * + * @note Use the methods of this class to tell Adjust about the usage of your app. + * See the README for details. + */ +@interface Adjust : NSObject + +/** + * @brief Tell Adjust that the application did launch. + * This is required to initialize Adjust. Call this in the didFinishLaunching + * method of your AppDelegate. + * + * @note See ADJConfig.h for more configuration options + * + * @param adjustConfig The configuration object that includes the environment + * and the App Token of your app. This unique identifier can + * be found it in your dashboard at http://adjust.com and should always + * be 12 characters long. + */ ++ (void)appDidLaunch:(nullable ADJConfig *)adjustConfig; + +/** + * @brief Tell Adjust that a particular event has happened. + * + * @note See ADJEvent.h for more event options. + * + * @param event The Event object for this kind of event. It needs a event token + * that is created in the dashboard at http://adjust.com and should be six + * characters long. + */ ++ (void)trackEvent:(nullable ADJEvent *)event; + +/** + * @brief Tell adjust that the application resumed. + * + * @note Only necessary if the native notifications can't be used + * or if they will happen before call to appDidLaunch: is made. + */ ++ (void)trackSubsessionStart; + +/** + * @brief Tell adjust that the application paused. + * + * @note Only necessary if the native notifications can't be used. + */ ++ (void)trackSubsessionEnd; + +/** + * @brief Enable or disable the adjust SDK. This setting is saved for future sessions. + * + * @param enabled The flag to enable or disable the adjust SDK. + */ ++ (void)setEnabled:(BOOL)enabled; + +/** + * @brief Check if the SDK is enabled or disabled. + * + * return Boolean indicating whether SDK is enabled or not. + */ ++ (BOOL)isEnabled; + +/** + * @brief Read the URL that opened the application to search for an adjust deep link. + * + * @param url URL object which contains info about adjust deep link. + */ ++ (void)appWillOpenUrl:(nonnull NSURL *)url; + +/** + * @brief Set the device token used by push notifications. + * + * @param deviceToken Apple push notification token for iOS device as NSData. + */ ++ (void)setDeviceToken:(nonnull NSData *)deviceToken; + +/** + * @brief Set the device token used by push notifications. + * This method is only used by Adjust non native SDKs. Don't use it anywhere else. + * + * @param pushToken Apple push notification token for iOS device as NSString. + */ ++ (void)setPushToken:(nonnull NSString *)pushToken; + +/** + * @brief Enable or disable offline mode. Activities won't be sent but they are saved when + * offline mode is disabled. This feature is not saved for future sessions. + * + * @param enabled The flag to enable or disable offline mode. + */ ++ (void)setOfflineMode:(BOOL)enabled; + +/** + * @brief Retrieve iOS device IDFA value. + * + * @return Device IDFA value. + */ ++ (nullable NSString *)idfa; + +/** + * @brief Retrieve iOS device IDFV value. + * + * @return Device IDFV value. + */ ++ (nullable NSString *)idfv; + + +/** + * @brief Get current adjust identifier for the user. + * + * @note Adjust identifier is available only after installation has been successfully tracked. + * + * @return Current adjust identifier value for the user. + */ ++ (nullable NSString *)adid; + +/** + * @brief Get current attribution for the user. + * + * @note Attribution information is available only after installation has been successfully tracked + * and attribution information arrived after that from the backend. + * + * @return Current attribution value for the user. + */ ++ (nullable ADJAttribution *)attribution; + +/** + * @brief Get current Adjust SDK version string. + * + * @return Adjust SDK version string (iosX.Y.Z). + */ ++ (nullable NSString *)sdkVersion; + +/** + * @brief Convert a universal link style URL to a deeplink style URL with the corresponding scheme. + * + * @param url URL object which contains info about adjust deep link. + * @param scheme Desired scheme to which you want your resulting URL object to be prefixed with. + * + * @return URL object in custom URL scheme style prefixed with given scheme name. + */ ++ (nullable NSURL *)convertUniversalLink:(nonnull NSURL *)url scheme:(nonnull NSString *)scheme; + +/** + * @brief Tell the adjust SDK to stop waiting for delayed initialisation timer to complete but rather to start + * upon this call. This should be called if you have obtained needed callback/partner parameters which you + * wanted to put as default ones before the delayedStart value you have set on ADJConfig has expired. + */ ++ (void)sendFirstPackages; + +/** + * @brief Tell adjust to send the request to Google and check if the installation + * belongs to Google AdWords campaign. + * + * @note Deprecated method, should not be used. + */ ++ (void)sendAdWordsRequest; + +/** + * @brief Add default callback parameter key-value pair which is going to be sent with each tracked session and event. + * + * @param key Default callback parameter key. + * @param value Default callback parameter value. + */ ++ (void)addSessionCallbackParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +/** + * @brief Add default partner parameter key-value pair which is going to be sent with each tracked session. + * + * @param key Default partner parameter key. + * @param value Default partner parameter value. + */ ++ (void)addSessionPartnerParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +/** + * @brief Remove default callback parameter from the session packages. + * + * @param key Default callback parameter key. + */ ++ (void)removeSessionCallbackParameter:(nonnull NSString *)key; + +/** + * @brief Remove default partner parameter from the session packages. + * + * @param key Default partner parameter key. + */ ++ (void)removeSessionPartnerParameter:(nonnull NSString *)key; + +/** + * @brief Remove all default callback parameters from the session packages. + */ ++ (void)resetSessionCallbackParameters; + +/** + * @brief Remove all default partner parameters from the session packages. + */ ++ (void)resetSessionPartnerParameters; + +/** + * @brief Give right user to be forgotten in accordance with GDPR law. + */ ++ (void)gdprForgetMe; + +/** + * @brief Track ad revenue for given source. + * + * @param source Ad revenue source. + * @param payload Ad revenue payload. + */ ++ (void)trackAdRevenue:(nonnull NSString *)source payload:(nonnull NSData *)payload; + +/** + * @brief Give right user to disable sharing data to any third-party. + */ ++ (void)disableThirdPartySharing; + +/** + * @brief Track third paty sharing with possibility to allow or disallow it. + * + * @param thirdPartySharing Third party sharing choice. + */ ++ (void)trackThirdPartySharing:(nonnull ADJThirdPartySharing *)thirdPartySharing; + +/** + * @brief Track measurement consent. + * + * @param enabled Value of the consent. + */ ++ (void)trackMeasurementConsent:(BOOL)enabled; + +/** + * @brief Track ad revenue. + * + * @param adRevenue Ad revenue object instance containing all the relevant ad revenue tracking data. + */ ++ (void)trackAdRevenue:(nonnull ADJAdRevenue *)adRevenue; + +/** + * @brief Track subscription. + * + * @param subscription Subscription object. + */ ++ (void)trackSubscription:(nonnull ADJSubscription *)subscription; + +/** + * @brief Adjust wrapper for requestTrackingAuthorizationWithCompletionHandler: method. + * + * @param completion Block which value of tracking authorization status will be delivered to. + */ ++ (void)requestTrackingAuthorizationWithCompletionHandler:(void (^_Nullable)(NSUInteger status))completion; + +/** + * @brief Getter for app tracking authorization status. + * + * @return Value of app tracking authorization status. + */ ++ (int)appTrackingAuthorizationStatus; + +/** + * @brief Adjust wrapper for SKAdNetwork's updateConversionValue: method. + * + * @param conversionValue Conversion value you would like SDK to set for given user. + */ ++ (void)updateConversionValue:(NSInteger)conversionValue; + +/** + * @brief Adjust wrapper for SKAdNetwork's updatePostbackConversionValue:completionHandler: method. + * + * @param conversionValue Conversion value you would like SDK to set for given user. + * @param completion Completion handler you can provide to catch and handle any errors. + */ ++ (void)updatePostbackConversionValue:(NSInteger)conversionValue + completionHandler:(void (^_Nullable)(NSError *_Nullable error))completion; + +/** + * @brief Adjust wrapper for SKAdNetwork's updatePostbackConversionValue:coarseValue:completionHandler: method. + * + * @param fineValue Conversion value you would like SDK to set for given user. + * @param coarseValue One of the possible SKAdNetworkCoarseConversionValue values. + * @param completion Completion handler you can provide to catch and handle any errors. + */ ++ (void)updatePostbackConversionValue:(NSInteger)fineValue + coarseValue:(nonnull NSString *)coarseValue + completionHandler:(void (^_Nullable)(NSError *_Nullable error))completion; + +/** + * @brief Adjust wrapper for SKAdNetwork's updatePostbackConversionValue:coarseValue:lockWindow:completionHandler: method. + * + * @param fineValue Conversion value you would like SDK to set for given user. + * @param coarseValue One of the possible SKAdNetworkCoarseConversionValue values. + * @param lockWindow A Boolean value that indicates whether to send the postback before the conversion window ends. + * @param completion Completion handler you can provide to catch and handle any errors. + */ ++ (void)updatePostbackConversionValue:(NSInteger)fineValue + coarseValue:(nonnull NSString *)coarseValue + lockWindow:(BOOL)lockWindow + completionHandler:(void (^_Nullable)(NSError *_Nullable error))completion; + +/** + * @brief Instruct to Adjust SDK to check current state of att_status. + */ ++ (void)checkForNewAttStatus; + +/** + * @brief Get the last deep link which has opened the app. + * + * @return Last deep link which has opened the app. + */ ++ (nullable NSURL *)lastDeeplink; + +/** + * @brief Verify in-app-purchase. + * + * @param purchase Purchase object. + * @param completionHandler Callback where verification result will be repoted. + */ ++ (void)verifyPurchase:(nonnull ADJPurchase *)purchase + completionHandler:(void (^_Nonnull)(ADJPurchaseVerificationResult * _Nonnull verificationResult))completionHandler; + +/** + * @brief Method used for internal testing only. Don't use it in production. + */ ++ (void)setTestOptions:(nullable AdjustTestOptions *)testOptions; + +/** + * Obtain singleton Adjust object. + */ ++ (nullable instancetype)getInstance; + +- (void)appDidLaunch:(nullable ADJConfig *)adjustConfig; + +- (void)trackEvent:(nullable ADJEvent *)event; + +- (void)setEnabled:(BOOL)enabled; + +- (void)teardown; + +- (void)appWillOpenUrl:(nonnull NSURL *)url; + +- (void)setOfflineMode:(BOOL)enabled; + +- (void)setDeviceToken:(nonnull NSData *)deviceToken; + +- (void)setPushToken:(nonnull NSString *)pushToken; + +- (void)sendFirstPackages; + +- (void)trackSubsessionEnd; + +- (void)trackSubsessionStart; + +- (void)resetSessionPartnerParameters; + +- (void)resetSessionCallbackParameters; + +- (void)removeSessionPartnerParameter:(nonnull NSString *)key; + +- (void)removeSessionCallbackParameter:(nonnull NSString *)key; + +- (void)addSessionPartnerParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +- (void)addSessionCallbackParameter:(nonnull NSString *)key value:(nonnull NSString *)value; + +- (void)gdprForgetMe; + +- (void)trackAdRevenue:(nonnull NSString *)source payload:(nonnull NSData *)payload; + +- (void)trackSubscription:(nonnull ADJSubscription *)subscription; + +- (BOOL)isEnabled; + +- (nullable NSString *)adid; + +- (nullable NSString *)idfa; + +- (nullable NSString *)sdkVersion; + +- (nullable ADJAttribution *)attribution; + +- (nullable NSURL *)convertUniversalLink:(nonnull NSURL *)url scheme:(nonnull NSString *)scheme; + +- (void)requestTrackingAuthorizationWithCompletionHandler:(void (^_Nullable)(NSUInteger status))completion; + +- (int)appTrackingAuthorizationStatus; + +- (void)updateConversionValue:(NSInteger)conversionValue; + +- (void)updatePostbackConversionValue:(NSInteger)conversionValue + completionHandler:(void (^_Nullable)(NSError *_Nullable error))completion; + +- (void)updatePostbackConversionValue:(NSInteger)fineValue + coarseValue:(nonnull NSString *)coarseValue + completionHandler:(void (^_Nullable)(NSError *_Nullable error))completion; + +- (void)updatePostbackConversionValue:(NSInteger)fineValue + coarseValue:(nonnull NSString *)coarseValue + lockWindow:(BOOL)lockWindow + completionHandler:(void (^_Nullable)(NSError *_Nullable error))completion; + +- (void)trackThirdPartySharing:(nonnull ADJThirdPartySharing *)thirdPartySharing; + +- (void)trackMeasurementConsent:(BOOL)enabled; + +- (void)trackAdRevenue:(nonnull ADJAdRevenue *)adRevenue; + +- (void)checkForNewAttStatus; + +- (nullable NSURL *)lastDeeplink; + +- (void)verifyPurchase:(nonnull ADJPurchase *)purchase + completionHandler:(void (^_Nonnull)(ADJPurchaseVerificationResult * _Nonnull verificationResult))completionHandler; + +@end diff --git a/Adjust/iOS/Adjust.h.meta b/Adjust/iOS/Adjust.h.meta new file mode 100644 index 0000000..4fd2266 --- /dev/null +++ b/Adjust/iOS/Adjust.h.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: 78f041701c2d94787bdb278a5bff4fae +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/AdjustSdk.a b/Adjust/iOS/AdjustSdk.a new file mode 100644 index 0000000..fca3d71 Binary files /dev/null and b/Adjust/iOS/AdjustSdk.a differ diff --git a/Adjust/iOS/AdjustSdk.a.meta b/Adjust/iOS/AdjustSdk.a.meta new file mode 100644 index 0000000..bb65f59 --- /dev/null +++ b/Adjust/iOS/AdjustSdk.a.meta @@ -0,0 +1,147 @@ +fileFormatVersion: 2 +guid: 7ecd19f430df2475dad6b1f0cc22114c +timeCreated: 1460026500 +licenseType: Free +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/AdjustUnity.h b/Adjust/iOS/AdjustUnity.h new file mode 100644 index 0000000..ae8e8c2 --- /dev/null +++ b/Adjust/iOS/AdjustUnity.h @@ -0,0 +1,14 @@ +// +// AdjustUnity.h +// Adjust SDK +// +// Created by Pedro Silva (@nonelse) on 27th March 2014. +// Copyright © 2012-2018 Adjust GmbH. All rights reserved. +// + +/** + * @brief The main interface to Adjust Unity bridge. + */ +@interface AdjustUnity : NSObject + +@end diff --git a/Adjust/iOS/AdjustUnity.h.meta b/Adjust/iOS/AdjustUnity.h.meta new file mode 100644 index 0000000..3995095 --- /dev/null +++ b/Adjust/iOS/AdjustUnity.h.meta @@ -0,0 +1,21 @@ +fileFormatVersion: 2 +guid: 9ffff8839c6ab418b983add4c597fb87 +PluginImporter: + serializedVersion: 1 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + platformData: + Any: + enabled: 0 + settings: {} + Editor: + enabled: 0 + settings: + DefaultValueInitialized: true + iOS: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/AdjustUnity.mm b/Adjust/iOS/AdjustUnity.mm new file mode 100644 index 0000000..033c748 --- /dev/null +++ b/Adjust/iOS/AdjustUnity.mm @@ -0,0 +1,945 @@ +// +// AdjustUnity.mm +// Adjust SDK +// +// Created by Pedro Silva (@nonelse) on 27th March 2014. +// Copyright © 2012-2018 Adjust GmbH. All rights reserved. +// + +#import "Adjust.h" +#import "ADJEvent.h" +#import "ADJConfig.h" +#import "AdjustUnity.h" +#import "AdjustUnityAppDelegate.h" +#import "AdjustUnityDelegate.h" + +@implementation AdjustUnity + +#pragma mark - Object lifecycle methods + ++ (void)load { + // Swizzle AppDelegate on the load. It should be done as early as possible. + [AdjustUnityAppDelegate swizzleAppDelegateCallbacks]; +} + +@end + +#pragma mark - Helper C methods + +// Method for converting JSON stirng parameters into NSArray object. +NSArray* convertArrayParameters(const char* cStringJsonArrayParameters) { + if (cStringJsonArrayParameters == NULL) { + return nil; + } + + NSError *error = nil; + NSArray *arrayParameters = nil; + NSString *stringJsonArrayParameters = [NSString stringWithUTF8String:cStringJsonArrayParameters]; + + if (stringJsonArrayParameters != nil) { + NSData *dataJson = [stringJsonArrayParameters dataUsingEncoding:NSUTF8StringEncoding]; + arrayParameters = [NSJSONSerialization JSONObjectWithData:dataJson options:0 error:&error]; + } + if (error != nil) { + NSString *errorMessage = @"Failed to parse json parameters!"; + NSLog(@"%@", errorMessage); + } + + return arrayParameters; +} + +BOOL isStringValid(const char* cString) { + if (cString == NULL) { + return false; + } + + NSString *objcString = [NSString stringWithUTF8String:cString]; + if (objcString == nil) { + return false; + } + if ([objcString isEqualToString:@"ADJ_INVALID"]) { + return false; + } + + return true; +} + +void addValueOrEmpty(NSMutableDictionary *dictionary, NSString *key, NSObject *value) { + if (nil != value) { + if ([value isKindOfClass:[NSString class]]) { + [dictionary setObject:[NSString stringWithFormat:@"%@", value] forKey:key]; + } else if ([value isKindOfClass:[NSNumber class]]) { + [dictionary setObject:[NSString stringWithFormat:@"%@", [((NSNumber *)value) stringValue]] forKey:key]; + } else { + [dictionary setObject:@"" forKey:key]; + } + } else { + [dictionary setObject:@"" forKey:key]; + } +} + +#pragma mark - Publicly available C methods + +extern "C" +{ + void _AdjustLaunchApp(const char* appToken, + const char* environment, + const char* sdkPrefix, + const char* userAgent, + const char* defaultTracker, + const char* externalDeviceId, + const char* urlStrategy, + const char* sceneName, + int allowSuppressLogLevel, + int logLevel, + int isDeviceKnown, + int eventBuffering, + int sendInBackground, + int allowAdServicesInfoReading, + int allowIdfaReading, + int deactivateSkAdNetworkHandling, + int linkMeEnabled, + int needsCost, + int coppaCompliant, + int64_t secretId, + int64_t info1, + int64_t info2, + int64_t info3, + int64_t info4, + double delayStart, + int attConsentWaitingInterval, + int launchDeferredDeeplink, + int isAttributionCallbackImplemented, + int isEventSuccessCallbackImplemented, + int isEventFailureCallbackImplemented, + int isSessionSuccessCallbackImplemented, + int isSessionFailureCallbackImplemented, + int isDeferredDeeplinkCallbackImplemented, + int isConversionValueUpdatedCallbackImplemented, + int isSkad4ConversionValueUpdatedCallbackImplemented) { + NSString *stringAppToken = isStringValid(appToken) == true ? [NSString stringWithUTF8String:appToken] : nil; + NSString *stringEnvironment = isStringValid(environment) == true ? [NSString stringWithUTF8String:environment] : nil; + NSString *stringSdkPrefix = isStringValid(sdkPrefix) == true ? [NSString stringWithUTF8String:sdkPrefix] : nil; + NSString *stringUserAgent = isStringValid(userAgent) == true ? [NSString stringWithUTF8String:userAgent] : nil; + NSString *stringDefaultTracker = isStringValid(defaultTracker) == true ? [NSString stringWithUTF8String:defaultTracker] : nil; + NSString *stringExternalDeviceId = isStringValid(externalDeviceId) == true ? [NSString stringWithUTF8String:externalDeviceId] : nil; + NSString *stringUrlStrategy = isStringValid(urlStrategy) == true ? [NSString stringWithUTF8String:urlStrategy] : nil; + NSString *stringSceneName = isStringValid(sceneName) == true ? [NSString stringWithUTF8String:sceneName] : nil; + + ADJConfig *adjustConfig; + + if (allowSuppressLogLevel != -1) { + adjustConfig = [ADJConfig configWithAppToken:stringAppToken + environment:stringEnvironment + allowSuppressLogLevel:(BOOL)allowSuppressLogLevel]; + } else { + adjustConfig = [ADJConfig configWithAppToken:stringAppToken + environment:stringEnvironment]; + } + + // Set SDK prefix. + [adjustConfig setSdkPrefix:stringSdkPrefix]; + + // Check if user has selected to implement any of the callbacks. + if (isAttributionCallbackImplemented + || isEventSuccessCallbackImplemented + || isEventFailureCallbackImplemented + || isSessionSuccessCallbackImplemented + || isSessionFailureCallbackImplemented + || isDeferredDeeplinkCallbackImplemented + || isConversionValueUpdatedCallbackImplemented + || isSkad4ConversionValueUpdatedCallbackImplemented) { + [adjustConfig setDelegate: + [AdjustUnityDelegate getInstanceWithSwizzleOfAttributionCallback:isAttributionCallbackImplemented + eventSuccessCallback:isEventSuccessCallbackImplemented + eventFailureCallback:isEventFailureCallbackImplemented + sessionSuccessCallback:isSessionSuccessCallbackImplemented + sessionFailureCallback:isSessionFailureCallbackImplemented + deferredDeeplinkCallback:isDeferredDeeplinkCallbackImplemented + conversionValueUpdatedCallback:isConversionValueUpdatedCallbackImplemented + skad4ConversionValueUpdatedCallback:isSkad4ConversionValueUpdatedCallbackImplemented + shouldLaunchDeferredDeeplink:launchDeferredDeeplink + withAdjustUnitySceneName:stringSceneName]]; + } + + // Log level. + if (logLevel != -1) { + [adjustConfig setLogLevel:(ADJLogLevel)logLevel]; + } + + // Event buffering. + if (eventBuffering != -1) { + [adjustConfig setEventBufferingEnabled:(BOOL)eventBuffering]; + } + + // Send in background. + if (sendInBackground != -1) { + [adjustConfig setSendInBackground:(BOOL)sendInBackground]; + } + + // Allow AdServices info reading. + if (allowAdServicesInfoReading != -1) { + [adjustConfig setAllowAdServicesInfoReading:(BOOL)allowAdServicesInfoReading]; + } + + // Deactivate default SKAdNetwork handling. + if (deactivateSkAdNetworkHandling != -1) { + [adjustConfig deactivateSKAdNetworkHandling]; + } + + // Allow IDFA reading. + if (allowIdfaReading != -1) { + [adjustConfig setAllowIdfaReading:(BOOL)allowIdfaReading]; + } + + // Enable LinkMe feature. + if (linkMeEnabled != -1) { + [adjustConfig setLinkMeEnabled:(BOOL)linkMeEnabled]; + } + + // Device known. + if (isDeviceKnown != -1) { + [adjustConfig setIsDeviceKnown:(BOOL)isDeviceKnown]; + } + + // Delay start. + if (delayStart != -1) { + [adjustConfig setDelayStart:delayStart]; + } + + // ATT dialog delay. + if (attConsentWaitingInterval != -1) { + [adjustConfig setAttConsentWaitingInterval:attConsentWaitingInterval]; + } + + // Cost data in attribution callback. + if (needsCost != -1) { + [adjustConfig setNeedsCost:(BOOL)needsCost]; + } + + // COPPA compliance. + if (coppaCompliant != -1) { + [adjustConfig setCoppaCompliantEnabled:(BOOL)coppaCompliant]; + } + + // User agent. + if (stringUserAgent != nil) { + [adjustConfig setUserAgent:stringUserAgent]; + } + + // Default tracker. + if (stringDefaultTracker != nil) { + [adjustConfig setDefaultTracker:stringDefaultTracker]; + } + + // External device identifier. + if (stringExternalDeviceId != nil) { + [adjustConfig setExternalDeviceId:stringExternalDeviceId]; + } + + // URL strategy. + if (stringUrlStrategy != nil) { + if ([stringUrlStrategy isEqualToString:@"china"]) { + [adjustConfig setUrlStrategy:ADJUrlStrategyChina]; + } else if ([stringUrlStrategy isEqualToString:@"india"]) { + [adjustConfig setUrlStrategy:ADJUrlStrategyIndia]; + } else if ([stringUrlStrategy isEqualToString:@"cn"]) { + [adjustConfig setUrlStrategy:ADJUrlStrategyCn]; + } else if ([stringUrlStrategy isEqualToString:@"cn-only"]) { + [adjustConfig setUrlStrategy:ADJUrlStrategyCnOnly]; + } else if ([stringUrlStrategy isEqualToString:@"data-residency-eu"]) { + [adjustConfig setUrlStrategy:ADJDataResidencyEU]; + } else if ([stringUrlStrategy isEqualToString:@"data-residency-tr"]) { + [adjustConfig setUrlStrategy:ADJDataResidencyTR]; + } else if ([stringUrlStrategy isEqualToString:@"data-residency-us"]) { + [adjustConfig setUrlStrategy:ADJDataResidencyUS]; + } + } + + // App secret. + if (secretId != -1 && info1 != -1 && info2 != -1 && info3 != -1 && info4 != 1) { + [adjustConfig setAppSecret:secretId info1:info1 info2:info2 info3:info3 info4:info4]; + } + + // Start the SDK. + [Adjust appDidLaunch:adjustConfig]; + [Adjust trackSubsessionStart]; + } + + void _AdjustTrackEvent(const char* eventToken, + double revenue, + const char* currency, + const char* receipt, + const char* productId, + const char* transactionId, + const char* callbackId, + int isReceiptSet, + const char* jsonCallbackParameters, + const char* jsonPartnerParameters) { + NSString *stringEventToken = isStringValid(eventToken) == true ? [NSString stringWithUTF8String:eventToken] : nil; + ADJEvent *event = [ADJEvent eventWithEventToken:stringEventToken]; + + // Revenue and currency. + if (revenue != -1 && currency != NULL) { + NSString *stringCurrency = [NSString stringWithUTF8String:currency]; + [event setRevenue:revenue currency:stringCurrency]; + } + + // Callback parameters. + NSArray *arrayCallbackParameters = convertArrayParameters(jsonCallbackParameters); + if (arrayCallbackParameters != nil) { + NSUInteger count = [arrayCallbackParameters count]; + for (int i = 0; i < count;) { + NSString *key = arrayCallbackParameters[i++]; + NSString *value = arrayCallbackParameters[i++]; + [event addCallbackParameter:key value:value]; + } + } + + NSArray *arrayPartnerParameters = convertArrayParameters(jsonPartnerParameters); + if (arrayPartnerParameters != nil) { + NSUInteger count = [arrayPartnerParameters count]; + for (int i = 0; i < count;) { + NSString *key = arrayPartnerParameters[i++]; + NSString *value = arrayPartnerParameters[i++]; + [event addPartnerParameter:key value:value]; + } + } + + // Transaction ID. + if (transactionId != NULL) { + NSString *stringTransactionId = [NSString stringWithUTF8String:transactionId]; + [event setTransactionId:stringTransactionId]; + } + + // Product ID. + if (productId != NULL) { + NSString *stringProductId = [NSString stringWithUTF8String:productId]; + [event setProductId:stringProductId]; + } + + // Receipt. + if (receipt != NULL) { + NSString *stringReceipt = [NSString stringWithUTF8String:receipt]; + [event setReceipt:[stringReceipt dataUsingEncoding:NSUTF8StringEncoding]]; + } + + // Callback ID. + if (callbackId != NULL) { + NSString *stringCallbackId = [NSString stringWithUTF8String:callbackId]; + [event setCallbackId:stringCallbackId]; + } + + // Receipt (legacy). + // if ([[NSNumber numberWithInt:isReceiptSet] boolValue]) { + // NSString *stringReceipt = nil; + // NSString *stringTransactionId = nil; + + // if (receipt != NULL) { + // stringReceipt = [NSString stringWithUTF8String:receipt]; + // } + // if (transactionId != NULL) { + // stringTransactionId = [NSString stringWithUTF8String:transactionId]; + // } + + // [event setReceipt:[stringReceipt dataUsingEncoding:NSUTF8StringEncoding] transactionId:stringTransactionId]; + // } + + // Track event. + [Adjust trackEvent:event]; + } + + void _AdjustTrackSubsessionStart() { + [Adjust trackSubsessionStart]; + } + + void _AdjustTrackSubsessionEnd() { + [Adjust trackSubsessionEnd]; + } + + void _AdjustSetEnabled(int enabled) { + BOOL bEnabled = (BOOL)enabled; + [Adjust setEnabled:bEnabled]; + } + + int _AdjustIsEnabled() { + BOOL isEnabled = [Adjust isEnabled]; + int iIsEnabled = (int)isEnabled; + return iIsEnabled; + } + + void _AdjustSetOfflineMode(int enabled) { + BOOL bEnabled = (BOOL)enabled; + [Adjust setOfflineMode:bEnabled]; + } + + void _AdjustSetDeviceToken(const char* deviceToken) { + if (deviceToken != NULL) { + NSString *stringDeviceToken = [NSString stringWithUTF8String:deviceToken]; + [Adjust setPushToken:stringDeviceToken]; + } + } + + void _AdjustAppWillOpenUrl(const char* url) { + if (url != NULL) { + NSString *stringUrl = [NSString stringWithUTF8String:url]; + NSURL *nsUrl; + if ([NSString instancesRespondToSelector:@selector(stringByAddingPercentEncodingWithAllowedCharacters:)]) { + nsUrl = [NSURL URLWithString:[stringUrl stringByAddingPercentEncodingWithAllowedCharacters:[NSCharacterSet URLFragmentAllowedCharacterSet]]]; + } else { +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wdeprecated-declarations" + nsUrl = [NSURL URLWithString:[stringUrl stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; + } +#pragma clang diagnostic pop + + [Adjust appWillOpenUrl:nsUrl]; + } + } + + char* _AdjustGetIdfa() { + NSString *idfa = [Adjust idfa]; + if (nil == idfa) { + return NULL; + } + + const char* idfaCString = [idfa UTF8String]; + if (NULL == idfaCString) { + return NULL; + } + + char* idfaCStringCopy = strdup(idfaCString); + return idfaCStringCopy; + } + + char* _AdjustGetIdfv() { + NSString *idfv = [Adjust idfv]; + if (nil == idfv) { + return NULL; + } + + const char* idfvCString = [idfv UTF8String]; + if (NULL == idfvCString) { + return NULL; + } + + char* idfvCStringCopy = strdup(idfvCString); + return idfvCStringCopy; + } + + char* _AdjustGetAdid() { + NSString *adid = [Adjust adid]; + if (nil == adid) { + return NULL; + } + + const char* adidCString = [adid UTF8String]; + if (NULL == adidCString) { + return NULL; + } + + char* adidCStringCopy = strdup(adidCString); + return adidCStringCopy; + } + + char* _AdjustGetSdkVersion() { + NSString *sdkVersion = [Adjust sdkVersion]; + if (nil == sdkVersion) { + return NULL; + } + + const char* sdkVersionCString = [sdkVersion UTF8String]; + if (NULL == sdkVersionCString) { + return NULL; + } + + char* sdkVersionCStringCopy = strdup(sdkVersionCString); + return sdkVersionCStringCopy; + } + + char* _AdjustGetAttribution() { + ADJAttribution *attribution = [Adjust attribution]; + if (nil == attribution) { + return NULL; + } + + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + addValueOrEmpty(dictionary, @"trackerToken", attribution.trackerToken); + addValueOrEmpty(dictionary, @"trackerName", attribution.trackerName); + addValueOrEmpty(dictionary, @"network", attribution.network); + addValueOrEmpty(dictionary, @"campaign", attribution.campaign); + addValueOrEmpty(dictionary, @"creative", attribution.creative); + addValueOrEmpty(dictionary, @"adgroup", attribution.adgroup); + addValueOrEmpty(dictionary, @"clickLabel", attribution.clickLabel); + addValueOrEmpty(dictionary, @"adid", attribution.adid); + addValueOrEmpty(dictionary, @"costType", attribution.costType); + addValueOrEmpty(dictionary, @"costAmount", attribution.costAmount); + addValueOrEmpty(dictionary, @"costCurrency", attribution.costCurrency); + + NSData *dataAttribution = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; + NSString *stringAttribution = [[NSString alloc] initWithBytes:[dataAttribution bytes] + length:[dataAttribution length] + encoding:NSUTF8StringEncoding]; + const char* attributionCString = [stringAttribution UTF8String]; + char* attributionCStringCopy = strdup(attributionCString); + return attributionCStringCopy; + } + + void _AdjustSendFirstPackages() { + [Adjust sendFirstPackages]; + } + + void _AdjustGdprForgetMe() { + [Adjust gdprForgetMe]; + } + + void _AdjustDisableThirdPartySharing() { + [Adjust disableThirdPartySharing]; + } + + void _AdjustAddSessionPartnerParameter(const char* key, const char* value) { + if (key != NULL && value != NULL) { + NSString *stringKey = [NSString stringWithUTF8String:key]; + NSString *stringValue = [NSString stringWithUTF8String:value]; + [Adjust addSessionPartnerParameter:stringKey value:stringValue]; + } + } + + void _AdjustAddSessionCallbackParameter(const char* key, const char* value) { + if (key != NULL && value != NULL) { + NSString *stringKey = [NSString stringWithUTF8String:key]; + NSString *stringValue = [NSString stringWithUTF8String:value]; + [Adjust addSessionCallbackParameter:stringKey value:stringValue]; + } + } + + void _AdjustRemoveSessionPartnerParameter(const char* key) { + if (key != NULL) { + NSString *stringKey = [NSString stringWithUTF8String:key]; + [Adjust removeSessionPartnerParameter:stringKey]; + } + } + + void _AdjustRemoveSessionCallbackParameter(const char* key) { + if (key != NULL) { + NSString *stringKey = [NSString stringWithUTF8String:key]; + [Adjust removeSessionCallbackParameter:stringKey]; + } + } + + void _AdjustResetSessionPartnerParameters() { + [Adjust resetSessionPartnerParameters]; + } + + void _AdjustResetSessionCallbackParameters() { + [Adjust resetSessionCallbackParameters]; + } + + void _AdjustTrackAdRevenue(const char* source, const char* payload) { + if (source != NULL && payload != NULL) { + NSString *stringSource = [NSString stringWithUTF8String:source]; + NSString *stringPayload = [NSString stringWithUTF8String:payload]; + NSData *dataPayload = [stringPayload dataUsingEncoding:NSUTF8StringEncoding]; + [Adjust trackAdRevenue:stringSource payload:dataPayload]; + } + } + + void _AdjustTrackAdRevenueNew(const char* source, + double revenue, + const char* currency, + int adImpressionsCount, + const char* adRevenueNetwork, + const char* adRevenueUnit, + const char* adRevenuePlacement, + const char* jsonCallbackParameters, + const char* jsonPartnerParameters) { + NSString *stringSource = isStringValid(source) == true ? [NSString stringWithUTF8String:source] : nil; + ADJAdRevenue *adRevenue = [[ADJAdRevenue alloc] initWithSource:stringSource]; + + // Revenue and currency. + if (revenue != -1 && currency != NULL) { + NSString *stringCurrency = [NSString stringWithUTF8String:currency]; + [adRevenue setRevenue:revenue currency:stringCurrency]; + } + + // Ad impressions count. + if (adImpressionsCount != -1) { + [adRevenue setAdImpressionsCount:adImpressionsCount]; + } + + // Ad revenue network. + if (adRevenueNetwork != NULL) { + NSString *stringAdRevenueNetwork = [NSString stringWithUTF8String:adRevenueNetwork]; + [adRevenue setAdRevenueNetwork:stringAdRevenueNetwork]; + } + + // Ad revenue unit. + if (adRevenueUnit != NULL) { + NSString *stringAdRevenueUnit = [NSString stringWithUTF8String:adRevenueUnit]; + [adRevenue setAdRevenueUnit:stringAdRevenueUnit]; + } + + // Ad revenue placement. + if (adRevenuePlacement != NULL) { + NSString *stringAdRevenuePlacement = [NSString stringWithUTF8String:adRevenuePlacement]; + [adRevenue setAdRevenuePlacement:stringAdRevenuePlacement]; + } + + // Callback parameters. + NSArray *arrayCallbackParameters = convertArrayParameters(jsonCallbackParameters); + if (arrayCallbackParameters != nil) { + NSUInteger count = [arrayCallbackParameters count]; + for (int i = 0; i < count;) { + NSString *key = arrayCallbackParameters[i++]; + NSString *value = arrayCallbackParameters[i++]; + [adRevenue addCallbackParameter:key value:value]; + } + } + + NSArray *arrayPartnerParameters = convertArrayParameters(jsonPartnerParameters); + if (arrayPartnerParameters != nil) { + NSUInteger count = [arrayPartnerParameters count]; + for (int i = 0; i < count;) { + NSString *key = arrayPartnerParameters[i++]; + NSString *value = arrayPartnerParameters[i++]; + [adRevenue addPartnerParameter:key value:value]; + } + } + + // Track ad revenue. + [Adjust trackAdRevenue:adRevenue]; + } + + void _AdjustTrackAppStoreSubscription(const char* price, + const char* currency, + const char* transactionId, + const char* receipt, + const char* billingStore, + const char* transactionDate, + const char* salesRegion, + const char* jsonCallbackParameters, + const char* jsonPartnerParameters) { + // Mandatory fields. + NSDecimalNumber *mPrice; + NSString *mCurrency; + NSString *mTransactionId; + NSData *mReceipt; + NSString *mBillingStore; + + // Price. + if (price != NULL) { + mPrice = [NSDecimalNumber decimalNumberWithString:[NSString stringWithUTF8String:price]]; + } + + // Currency. + if (currency != NULL) { + mCurrency = [NSString stringWithUTF8String:currency]; + } + + // Transaction ID. + if (transactionId != NULL) { + mTransactionId = [NSString stringWithUTF8String:transactionId]; + } + + // Receipt. + if (receipt != NULL) { + mReceipt = [[NSString stringWithUTF8String:receipt] dataUsingEncoding:NSUTF8StringEncoding]; + } + + // Billing store (not used ATM, maybe in the future). + if (billingStore != NULL) { + mBillingStore = [NSString stringWithUTF8String:billingStore]; + } + + ADJSubscription *subscription = [[ADJSubscription alloc] initWithPrice:mPrice + currency:mCurrency + transactionId:mTransactionId + andReceipt:mReceipt]; + + // Optional fields. + + // Transaction date. + if (transactionDate != NULL) { + NSTimeInterval transactionDateInterval = [[NSString stringWithUTF8String:transactionDate] doubleValue] / 1000.0; + NSDate *oTransactionDate = [NSDate dateWithTimeIntervalSince1970:transactionDateInterval]; + [subscription setTransactionDate:oTransactionDate]; + } + + // Sales region. + if (salesRegion != NULL) { + NSString *oSalesRegion = [NSString stringWithUTF8String:salesRegion]; + [subscription setSalesRegion:oSalesRegion]; + } + + // Callback parameters. + NSArray *arrayCallbackParameters = convertArrayParameters(jsonCallbackParameters); + if (arrayCallbackParameters != nil) { + NSUInteger count = [arrayCallbackParameters count]; + for (int i = 0; i < count;) { + NSString *key = arrayCallbackParameters[i++]; + NSString *value = arrayCallbackParameters[i++]; + [subscription addCallbackParameter:key value:value]; + } + } + + // Partner parameters. + NSArray *arrayPartnerParameters = convertArrayParameters(jsonPartnerParameters); + if (arrayPartnerParameters != nil) { + NSUInteger count = [arrayPartnerParameters count]; + for (int i = 0; i < count;) { + NSString *key = arrayPartnerParameters[i++]; + NSString *value = arrayPartnerParameters[i++]; + [subscription addPartnerParameter:key value:value]; + } + } + + // Track subscription. + [Adjust trackSubscription:subscription]; + } + + void _AdjustTrackThirdPartySharing(int enabled, const char* jsonGranularOptions, const char* jsonPartnerSharingSettings) { + NSNumber *nEnabled = enabled >= 0 ? [NSNumber numberWithInt:enabled] : nil; + ADJThirdPartySharing *adjustThirdPartySharing = [[ADJThirdPartySharing alloc] initWithIsEnabledNumberBool:nEnabled]; + + NSArray *arrayGranularOptions = convertArrayParameters(jsonGranularOptions); + if (arrayGranularOptions != nil) { + NSUInteger count = [arrayGranularOptions count]; + for (int i = 0; i < count;) { + NSString *partnerName = arrayGranularOptions[i++]; + NSString *granularOptions = arrayGranularOptions[i++]; + // granularOptions is now NSString which pretty much contains array of partner key-value pairs + if (granularOptions != nil) { + NSData *dataJson = [granularOptions dataUsingEncoding:NSUTF8StringEncoding]; + NSArray *partnerGranularOptions = [NSJSONSerialization JSONObjectWithData:dataJson options:0 error:nil]; + if (partnerGranularOptions != nil) { + // in here we have partner and key-value pair for it + for (int j = 0; j < [partnerGranularOptions count];) { + [adjustThirdPartySharing addGranularOption:partnerName + key:partnerGranularOptions[j++] + value:partnerGranularOptions[j++]]; + } + } + } + } + } + NSArray *arrayPartnerSharingSettings = convertArrayParameters(jsonPartnerSharingSettings); + if (arrayPartnerSharingSettings != nil) { + NSUInteger count = [arrayPartnerSharingSettings count]; + for (int i = 0; i < count;) { + NSString *partnerName = arrayPartnerSharingSettings[i++]; + NSString *sharingSettings = arrayPartnerSharingSettings[i++]; + // sharingSettings is now NSString which pretty much contains array of partner key-value pairs + if (sharingSettings != nil) { + NSData *dataJson = [sharingSettings dataUsingEncoding:NSUTF8StringEncoding]; + NSArray *partnerSharingSettings = [NSJSONSerialization JSONObjectWithData:dataJson options:0 error:nil]; + if (partnerSharingSettings != nil) { + // in here we have partner and key-value pair for it + for (int j = 0; j < [partnerSharingSettings count];) { + [adjustThirdPartySharing addPartnerSharingSetting:partnerName + key:partnerSharingSettings[j++] + value:[partnerSharingSettings[j++] boolValue]]; + } + } + } + } + } + + [Adjust trackThirdPartySharing:adjustThirdPartySharing]; + } + + void _AdjustTrackMeasurementConsent(int enabled) { + BOOL bEnabled = (BOOL)enabled; + [Adjust trackMeasurementConsent:bEnabled]; + } + + void _AdjustRequestTrackingAuthorizationWithCompletionHandler(const char* sceneName) { + NSString *stringSceneName = isStringValid(sceneName) == true ? [NSString stringWithUTF8String:sceneName] : nil; + if (stringSceneName == nil) { + return; + } + + [Adjust requestTrackingAuthorizationWithCompletionHandler:^(NSUInteger status) { + NSString *stringStatus = [NSString stringWithFormat:@"%tu", status]; + const char* charStatus = [stringStatus UTF8String]; + UnitySendMessage([stringSceneName UTF8String], "GetAuthorizationStatus", charStatus); + }]; + } + + void _AdjustUpdateConversionValue(int conversionValue) { + [Adjust updateConversionValue:conversionValue]; + } + + void _AdjustUpdateConversionValueWithCallback(int conversionValue, const char* sceneName) { + NSString *stringSceneName = isStringValid(sceneName) == true ? [NSString stringWithUTF8String:sceneName] : nil; + [Adjust updatePostbackConversionValue:conversionValue completionHandler:^(NSError * _Nullable error) { + if (stringSceneName == nil) { + return; + } + NSString *errorString = [error description]; + const char* errorChar = [errorString UTF8String]; + UnitySendMessage([stringSceneName UTF8String], "GetNativeSkadCompletionDelegate", errorChar); + }]; + } + + void _AdjustUpdateConversionValueWithCallbackSkad4(int conversionValue, const char* coarseValue, int lockWindow, const char* sceneName) { + NSString *stringSceneName = isStringValid(sceneName) == true ? [NSString stringWithUTF8String:sceneName] : nil; + if (coarseValue != NULL) { + NSString *stringCoarseValue = [NSString stringWithUTF8String:coarseValue]; + BOOL bLockWindow = (BOOL)lockWindow; + [Adjust updatePostbackConversionValue:conversionValue + coarseValue:stringCoarseValue + lockWindow:bLockWindow + completionHandler:^(NSError * _Nullable error) { + if (stringSceneName == nil) { + return; + } + NSString *errorString = [error description]; + const char* errorChar = [errorString UTF8String]; + UnitySendMessage([stringSceneName UTF8String], "GetNativeSkad4CompletionDelegate", errorChar); + }]; + } + } + + void _AdjustCheckForNewAttStatus() { + [Adjust checkForNewAttStatus]; + } + + int _AdjustGetAppTrackingAuthorizationStatus() { + return [Adjust appTrackingAuthorizationStatus]; + } + + char* _AdjustGetLastDeeplink() { + NSURL *lastDeeplink = [Adjust lastDeeplink]; + if (nil == lastDeeplink) { + return NULL; + } + NSString *lastDeeplinkString = [lastDeeplink absoluteString]; + if (nil == lastDeeplinkString) { + return NULL; + } + const char* lastDeeplinkCString = [lastDeeplinkString UTF8String]; + if (NULL == lastDeeplinkCString) { + return NULL; + } + + char* lastDeeplinkCStringCopy = strdup(lastDeeplinkCString); + return lastDeeplinkCStringCopy; + } + + void _AdjustVerifyAppStorePurchase(const char* transactionId, + const char* productId, + const char* receipt, + const char* sceneName) { + // Mandatory fields. + NSString *strTransactionId; + NSString *strProductId; + NSData *dataReceipt; + NSString *strSceneName; + + // Transaction ID. + if (transactionId != NULL) { + strTransactionId = [NSString stringWithUTF8String:transactionId]; + } + + // Product ID. + if (productId != NULL) { + strProductId = [NSString stringWithUTF8String:productId]; + } + + // Receipt. + if (receipt != NULL) { + dataReceipt = [[NSString stringWithUTF8String:receipt] dataUsingEncoding:NSUTF8StringEncoding]; + } + + // Scene name. + strSceneName = isStringValid(sceneName) == true ? [NSString stringWithUTF8String:sceneName] : nil; + + // Verify the purchase. + ADJPurchase *purchase = [[ADJPurchase alloc] initWithTransactionId:strTransactionId + productId:strProductId + andReceipt:dataReceipt]; + [Adjust verifyPurchase:purchase + completionHandler:^(ADJPurchaseVerificationResult * _Nonnull verificationResult) { + if (strSceneName == nil) { + return; + } + if (verificationResult == nil) { + return; + } + + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + addValueOrEmpty(dictionary, @"verificationStatus", verificationResult.verificationStatus); + addValueOrEmpty(dictionary, @"code", [NSString stringWithFormat:@"%d", verificationResult.code]); + addValueOrEmpty(dictionary, @"message", verificationResult.message); + + NSData *dataVerificationInfo = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; + NSString *strVerificationInfo = [[NSString alloc] initWithBytes:[dataVerificationInfo bytes] + length:[dataVerificationInfo length] + encoding:NSUTF8StringEncoding]; + const char* verificationInfoCString = [strVerificationInfo UTF8String]; + UnitySendMessage([strSceneName UTF8String], "GetNativeVerificationInfo", verificationInfoCString); + }]; + } + + void _AdjustSetTestOptions(const char* baseUrl, + const char* gdprUrl, + const char* subscriptionUrl, + const char* purchaseVerificationUrl, + const char* extraPath, + long timerIntervalInMilliseconds, + long timerStartInMilliseconds, + long sessionIntervalInMilliseconds, + long subsessionIntervalInMilliseconds, + int teardown, + int deleteState, + int noBackoffWait, + int adServicesFrameworkEnabled) { + AdjustTestOptions *testOptions = [[AdjustTestOptions alloc] init]; + + NSString *stringBaseUrl = isStringValid(baseUrl) == true ? [NSString stringWithUTF8String:baseUrl] : nil; + if (stringBaseUrl != nil) { + [testOptions setBaseUrl:stringBaseUrl]; + } + + NSString *stringGdprUrl = isStringValid(baseUrl) == true ? [NSString stringWithUTF8String:gdprUrl] : nil; + if (stringGdprUrl != nil) { + [testOptions setGdprUrl:stringGdprUrl]; + } + + NSString *stringSubscriptionUrl = isStringValid(baseUrl) == true ? [NSString stringWithUTF8String:subscriptionUrl] : nil; + if (stringSubscriptionUrl != nil) { + [testOptions setSubscriptionUrl:stringSubscriptionUrl]; + } + + NSString *stringPurchaseVerificationUrl = isStringValid(baseUrl) == true ? [NSString stringWithUTF8String:purchaseVerificationUrl] : nil; + if (stringPurchaseVerificationUrl != nil) { + [testOptions setPurchaseVerificationUrl:stringPurchaseVerificationUrl]; + } + + NSString *stringExtraPath = isStringValid(extraPath) == true ? [NSString stringWithUTF8String:extraPath] : nil; + if (stringExtraPath != nil && [stringExtraPath length] > 0) { + [testOptions setExtraPath:stringExtraPath]; + } + + testOptions.timerIntervalInMilliseconds = [NSNumber numberWithLong:timerIntervalInMilliseconds]; + testOptions.timerStartInMilliseconds = [NSNumber numberWithLong:timerStartInMilliseconds]; + testOptions.sessionIntervalInMilliseconds = [NSNumber numberWithLong:sessionIntervalInMilliseconds]; + testOptions.subsessionIntervalInMilliseconds = [NSNumber numberWithLong:subsessionIntervalInMilliseconds]; + + if (teardown != -1) { + [AdjustUnityDelegate teardown]; + [testOptions setTeardown:(BOOL)teardown]; + } + if (deleteState != -1) { + [testOptions setDeleteState:(BOOL)deleteState]; + } + if (noBackoffWait != -1) { + [testOptions setNoBackoffWait:(BOOL)noBackoffWait]; + } + if (adServicesFrameworkEnabled != -1) { + [testOptions setAdServicesFrameworkEnabled:(BOOL)adServicesFrameworkEnabled]; + } + + [Adjust setTestOptions:testOptions]; + } +} diff --git a/Adjust/iOS/AdjustUnity.mm.meta b/Adjust/iOS/AdjustUnity.mm.meta new file mode 100644 index 0000000..2b85fff --- /dev/null +++ b/Adjust/iOS/AdjustUnity.mm.meta @@ -0,0 +1,131 @@ +fileFormatVersion: 2 +guid: 3e17e20d987e4449489d9e3accbd8602 +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/AdjustUnityAppDelegate.h b/Adjust/iOS/AdjustUnityAppDelegate.h new file mode 100644 index 0000000..25d1c2a --- /dev/null +++ b/Adjust/iOS/AdjustUnityAppDelegate.h @@ -0,0 +1,18 @@ +// +// AdjustUnityAppDelegate.h +// Adjust SDK +// +// Copyright © 2012-2021 Adjust GmbH. All rights reserved. +// + +/** + * @brief The interface to Adjust App Delegate. Used to do callback methods swizzling for deep linking. + */ +@interface AdjustUnityAppDelegate : NSObject + +/** + * @brief Swizzle AppDelegate deep linking callbacks. + */ ++ (void)swizzleAppDelegateCallbacks; + +@end diff --git a/Adjust/iOS/AdjustUnityAppDelegate.h.meta b/Adjust/iOS/AdjustUnityAppDelegate.h.meta new file mode 100644 index 0000000..1b4f2bd --- /dev/null +++ b/Adjust/iOS/AdjustUnityAppDelegate.h.meta @@ -0,0 +1,27 @@ +fileFormatVersion: 2 +guid: ac4b0b80967dd499b94e6bd430ac6662 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 1 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/AdjustUnityAppDelegate.m b/Adjust/iOS/AdjustUnityAppDelegate.m new file mode 100644 index 0000000..989a3b0 --- /dev/null +++ b/Adjust/iOS/AdjustUnityAppDelegate.m @@ -0,0 +1,73 @@ +// +// AdjustUnityAppDelegate.mm +// Adjust SDK +// +// Copyright © 2012-2021 Adjust GmbH. All rights reserved. +// + +#import +#import "Adjust.h" +#import "AdjustUnityAppDelegate.h" + +typedef BOOL (*openURL_t)(id, SEL, UIApplication *, NSURL *, NSDictionary *); +typedef BOOL (*continueUserActivity_t)(id, SEL, UIApplication *, NSUserActivity *, void (^)(NSArray *restorableObjects)); +static openURL_t original_openURL = NULL; +static continueUserActivity_t original_continueUserActivity = NULL; + +@implementation AdjustUnityAppDelegate + ++ (void)swizzleAppDelegateCallbacks { + NSLog(@"[Adjust] Swizzling AppDelegate callbacks..."); + static dispatch_once_t onceToken; + dispatch_once(&onceToken, ^{ + original_openURL = (openURL_t)[self swizzleOriginalSelector:@selector(application:openURL:options:) + withSelector:@selector(adjust_application:openURL:options:)]; + original_continueUserActivity = (continueUserActivity_t)[self swizzleOriginalSelector:@selector(application:continueUserActivity:restorationHandler:) + withSelector:@selector(adjust_application:continueUserActivity:restorationHandler:)]; + }); +} + ++ (IMP)swizzleOriginalSelector:(SEL)originalSelector + withSelector:(SEL)swizzledSelector { + // The Unity base app controller class name. + extern const char* AppControllerClassName; + Class originalClass = NSClassFromString([NSString stringWithUTF8String:AppControllerClassName]); + Class swizzledClass = [self class]; + IMP originalImp = NULL; + IMP swizzledImp = class_getMethodImplementation(swizzledClass, swizzledSelector); + + // Replace original implementation by the custom one. + Method originalMethod = class_getInstanceMethod(originalClass, originalSelector); + if (originalMethod) { + originalImp = method_setImplementation(originalMethod, swizzledImp); + } else if (![originalClass instancesRespondToSelector:originalSelector]) { + // Add the method to the original class if it doesn't implement the selector. + Method swizzledMethod = class_getInstanceMethod(swizzledClass, swizzledSelector); + BOOL methodAdded = class_addMethod(originalClass, originalSelector, swizzledImp, method_getTypeEncoding(swizzledMethod)); + if (!methodAdded) { + NSLog(@"[Adjust] Cannot swizzle selector '%@' of class '%@'.", NSStringFromSelector(originalSelector), originalClass); + return NULL; + } + } + NSLog(@"[Adjust] Selector '%@' of class '%@' is swizzled.", NSStringFromSelector(originalSelector), originalClass); + return originalImp; +} + +- (BOOL)adjust_application:(UIApplication *)application + openURL:(NSURL *)url + options:(NSDictionary *)options { + [Adjust appWillOpenUrl:url]; + return original_openURL ? original_openURL(self, _cmd, application, url, options) : YES; +} + +- (BOOL)adjust_application:(UIApplication *)application + continueUserActivity:(NSUserActivity *)userActivity + restorationHandler:(void (^)(NSArray *restorableObjects))restorationHandler { + if ([[userActivity activityType] isEqualToString:NSUserActivityTypeBrowsingWeb]) { + NSURL *url = [userActivity webpageURL]; + [Adjust appWillOpenUrl:url]; + } + return original_continueUserActivity ? original_continueUserActivity(self, _cmd, application, userActivity, restorationHandler) : YES; +} + +@end diff --git a/Adjust/iOS/AdjustUnityAppDelegate.m.meta b/Adjust/iOS/AdjustUnityAppDelegate.m.meta new file mode 100644 index 0000000..d1b99f2 --- /dev/null +++ b/Adjust/iOS/AdjustUnityAppDelegate.m.meta @@ -0,0 +1,37 @@ +fileFormatVersion: 2 +guid: ea1bc374f78b747f8a81fcc82cd77d96 +PluginImporter: + externalObjects: {} + serializedVersion: 2 + iconMap: {} + executionOrder: {} + defineConstraints: [] + isPreloaded: 0 + isOverridable: 0 + isExplicitlyReferenced: 0 + validateReferences: 1 + platformData: + - first: + Any: + second: + enabled: 0 + settings: {} + - first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + - first: + iPhone: iOS + second: + enabled: 1 + settings: {} + - first: + tvOS: tvOS + second: + enabled: 1 + settings: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/AdjustUnityDelegate.h b/Adjust/iOS/AdjustUnityDelegate.h new file mode 100644 index 0000000..0e45f0f --- /dev/null +++ b/Adjust/iOS/AdjustUnityDelegate.h @@ -0,0 +1,59 @@ +// +// AdjustUnityDelegate.h +// Adjust SDK +// +// Created by Uglješa Erceg (@uerceg) on 5th December 2016. +// Copyright © 2012-2018 Adjust GmbH. All rights reserved. +// + +#import "Adjust.h" + +/** + * @brief The main interface to Adjust Unity delegate. Used to do callback methods swizzling where needed. + */ +@interface AdjustUnityDelegate : NSObject + +/** + * @brief Boolean indicating whether deferred deep link should be launched by SDK or not. + */ +@property (nonatomic) BOOL shouldLaunchDeferredDeeplink; + +/** + * @brief Name of the Unity scene that loads Adjust SDK. + */ +@property (nonatomic, copy) NSString *adjustUnitySceneName; + +/** + * @brief Get instance of the AdjustUnityDelegate with properly swizzled callback methods. + * + * @param swizzleAttributionCallback Indicator whether attribution callback should be swizzled or not. + * @param swizzleEventSuccessCallback Indicator whether event success callback should be swizzled or not. + * @param swizzleEventFailureCallback Indicator whether event failure callback should be swizzled or not. + * @param swizzleSessionSuccessCallback Indicator whether session success callback should be swizzled or not. + * @param swizzleSessionFailureCallback Indicator whether session failure callback should be swizzled or not. + * @param swizzleDeferredDeeplinkCallback Indicator whether deferred deep link callback should be swizzled or not. + * @param swizzleConversionValueUpdatedCallback Indicator whether SKAD conversion value update callback should be swizzled or not. + * @param swizzleSkad4ConversionValueUpdatedCallback Indicator whether SKAD4 conversion value update callback should be swizzled or not. + * @param shouldLaunchDeferredDeeplink Indicator whether SDK should launch deferred deep link by default or not. + * @param adjustUnitySceneName Name of the Unity scene that loads Adjust SDK. + * + * @return AdjustUnityDelegate object instance with properly swizzled callback methods. + */ ++ (id)getInstanceWithSwizzleOfAttributionCallback:(BOOL)swizzleAttributionCallback + eventSuccessCallback:(BOOL)swizzleEventSuccessCallback + eventFailureCallback:(BOOL)swizzleEventFailureCallback + sessionSuccessCallback:(BOOL)swizzleSessionSuccessCallback + sessionFailureCallback:(BOOL)swizzleSessionFailureCallback + deferredDeeplinkCallback:(BOOL)swizzleDeferredDeeplinkCallback + conversionValueUpdatedCallback:(BOOL)swizzleConversionValueUpdatedCallback + skad4ConversionValueUpdatedCallback:(BOOL)swizzleSkad4ConversionValueUpdatedCallback + shouldLaunchDeferredDeeplink:(BOOL)shouldLaunchDeferredDeeplink + withAdjustUnitySceneName:(NSString *)adjustUnitySceneName; + +/** + * @brief Teardown method used to reset static AdjustUnityDelegate instance. + * Used for testing purposes only. + */ ++ (void)teardown; + +@end diff --git a/Adjust/iOS/AdjustUnityDelegate.h.meta b/Adjust/iOS/AdjustUnityDelegate.h.meta new file mode 100644 index 0000000..5c1040a --- /dev/null +++ b/Adjust/iOS/AdjustUnityDelegate.h.meta @@ -0,0 +1,147 @@ +fileFormatVersion: 2 +guid: 5d2beef19c617f74fbca612cc97e3c60 +timeCreated: 1489655216 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: LinuxUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXUniversal + second: + enabled: 0 + settings: + CPU: None + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/AdjustUnityDelegate.mm b/Adjust/iOS/AdjustUnityDelegate.mm new file mode 100644 index 0000000..587235b --- /dev/null +++ b/Adjust/iOS/AdjustUnityDelegate.mm @@ -0,0 +1,270 @@ +// +// AdjustUnityDelegate.mm +// Adjust SDK +// +// Created by Uglješa Erceg (@uerceg) on 5th December 2016. +// Copyright © 2012-2018 Adjust GmbH. All rights reserved. +// + +#import +#import "AdjustUnityDelegate.h" + +static dispatch_once_t onceToken; +static AdjustUnityDelegate *defaultInstance = nil; + +@implementation AdjustUnityDelegate + +#pragma mark - Object lifecycle methods + +- (id)init { + self = [super init]; + if (nil == self) { + return nil; + } + return self; +} + +#pragma mark - Public methods + ++ (id)getInstanceWithSwizzleOfAttributionCallback:(BOOL)swizzleAttributionCallback + eventSuccessCallback:(BOOL)swizzleEventSuccessCallback + eventFailureCallback:(BOOL)swizzleEventFailureCallback + sessionSuccessCallback:(BOOL)swizzleSessionSuccessCallback + sessionFailureCallback:(BOOL)swizzleSessionFailureCallback + deferredDeeplinkCallback:(BOOL)swizzleDeferredDeeplinkCallback + conversionValueUpdatedCallback:(BOOL)swizzleConversionValueUpdatedCallback + skad4ConversionValueUpdatedCallback:(BOOL)swizzleSkad4ConversionValueUpdatedCallback + shouldLaunchDeferredDeeplink:(BOOL)shouldLaunchDeferredDeeplink + withAdjustUnitySceneName:(NSString *)adjustUnitySceneName { + dispatch_once(&onceToken, ^{ + defaultInstance = [[AdjustUnityDelegate alloc] init]; + + // Do the swizzling where and if needed. + if (swizzleAttributionCallback) { + [defaultInstance swizzleOriginalSelector:@selector(adjustAttributionChanged:) + withSelector:@selector(adjustAttributionChangedWannabe:)]; + } + if (swizzleEventSuccessCallback) { + [defaultInstance swizzleOriginalSelector:@selector(adjustEventTrackingSucceeded:) + withSelector:@selector(adjustEventTrackingSucceededWannabe:)]; + } + if (swizzleEventFailureCallback) { + [defaultInstance swizzleOriginalSelector:@selector(adjustEventTrackingFailed:) + withSelector:@selector(adjustEventTrackingFailedWannabe:)]; + } + if (swizzleSessionSuccessCallback) { + [defaultInstance swizzleOriginalSelector:@selector(adjustSessionTrackingSucceeded:) + withSelector:@selector(adjustSessionTrackingSucceededWannabe:)]; + } + if (swizzleSessionFailureCallback) { + [defaultInstance swizzleOriginalSelector:@selector(adjustSessionTrackingFailed:) + withSelector:@selector(adjustSessionTrackingFailedWannabe:)]; + } + if (swizzleDeferredDeeplinkCallback) { + [defaultInstance swizzleOriginalSelector:@selector(adjustDeeplinkResponse:) + withSelector:@selector(adjustDeeplinkResponseWannabe:)]; + } + if (swizzleConversionValueUpdatedCallback) { + [defaultInstance swizzleOriginalSelector:@selector(adjustConversionValueUpdated:) + withSelector:@selector(adjustConversionValueUpdatedWannabe:)]; + } + if (swizzleSkad4ConversionValueUpdatedCallback) { + [defaultInstance swizzleOriginalSelector:@selector(adjustConversionValueUpdated:coarseValue:lockWindow:) + withSelector:@selector(adjustConversionValueUpdatedWannabe:coarseValue:lockWindow:)]; + } + + [defaultInstance setShouldLaunchDeferredDeeplink:shouldLaunchDeferredDeeplink]; + [defaultInstance setAdjustUnitySceneName:adjustUnitySceneName]; + }); + + return defaultInstance; +} + ++ (void)teardown { + defaultInstance = nil; + onceToken = 0; +} + +#pragma mark - Private & helper methods + +- (void)adjustAttributionChangedWannabe:(ADJAttribution *)attribution { + if (attribution == nil) { + return; + } + + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + [self addValueOrEmpty:attribution.trackerToken forKey:@"trackerToken" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.trackerName forKey:@"trackerName" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.network forKey:@"network" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.campaign forKey:@"campaign" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.creative forKey:@"creative" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.adgroup forKey:@"adgroup" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.clickLabel forKey:@"clickLabel" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.adid forKey:@"adid" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.costType forKey:@"costType" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.costAmount forKey:@"costAmount" toDictionary:dictionary]; + [self addValueOrEmpty:attribution.costCurrency forKey:@"costCurrency" toDictionary:dictionary]; + + NSData *dataAttribution = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; + NSString *stringAttribution = [[NSString alloc] initWithBytes:[dataAttribution bytes] + length:[dataAttribution length] + encoding:NSUTF8StringEncoding]; + const char* charArrayAttribution = [stringAttribution UTF8String]; + UnitySendMessage([self.adjustUnitySceneName UTF8String], "GetNativeAttribution", charArrayAttribution); +} + +- (void)adjustEventTrackingSucceededWannabe:(ADJEventSuccess *)eventSuccessResponseData { + if (nil == eventSuccessResponseData) { + return; + } + + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + [self addValueOrEmpty:eventSuccessResponseData.message forKey:@"message" toDictionary:dictionary]; + [self addValueOrEmpty:eventSuccessResponseData.timeStamp forKey:@"timestamp" toDictionary:dictionary]; + [self addValueOrEmpty:eventSuccessResponseData.adid forKey:@"adid" toDictionary:dictionary]; + [self addValueOrEmpty:eventSuccessResponseData.eventToken forKey:@"eventToken" toDictionary:dictionary]; + [self addValueOrEmpty:eventSuccessResponseData.callbackId forKey:@"callbackId" toDictionary:dictionary]; + if (eventSuccessResponseData.jsonResponse != nil) { + [dictionary setObject:eventSuccessResponseData.jsonResponse forKey:@"jsonResponse"]; + } + + NSData *dataEventSuccess = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; + NSString *stringEventSuccess = [[NSString alloc] initWithBytes:[dataEventSuccess bytes] + length:[dataEventSuccess length] + encoding:NSUTF8StringEncoding]; + const char* charArrayEventSuccess = [stringEventSuccess UTF8String]; + UnitySendMessage([self.adjustUnitySceneName UTF8String], "GetNativeEventSuccess", charArrayEventSuccess); +} + +- (void)adjustEventTrackingFailedWannabe:(ADJEventFailure *)eventFailureResponseData { + if (nil == eventFailureResponseData) { + return; + } + + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + [self addValueOrEmpty:eventFailureResponseData.message forKey:@"message" toDictionary:dictionary]; + [self addValueOrEmpty:eventFailureResponseData.timeStamp forKey:@"timestamp" toDictionary:dictionary]; + [self addValueOrEmpty:eventFailureResponseData.adid forKey:@"adid" toDictionary:dictionary]; + [self addValueOrEmpty:eventFailureResponseData.eventToken forKey:@"eventToken" toDictionary:dictionary]; + [self addValueOrEmpty:eventFailureResponseData.callbackId forKey:@"callbackId" toDictionary:dictionary]; + [dictionary setObject:(eventFailureResponseData.willRetry ? @"true" : @"false") forKey:@"willRetry"]; + if (eventFailureResponseData.jsonResponse != nil) { + [dictionary setObject:eventFailureResponseData.jsonResponse forKey:@"jsonResponse"]; + } + + NSData *dataEventFailure = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; + NSString *stringEventFailure = [[NSString alloc] initWithBytes:[dataEventFailure bytes] + length:[dataEventFailure length] + encoding:NSUTF8StringEncoding]; + const char* charArrayEventFailure = [stringEventFailure UTF8String]; + UnitySendMessage([self.adjustUnitySceneName UTF8String], "GetNativeEventFailure", charArrayEventFailure); +} + +- (void)adjustSessionTrackingSucceededWannabe:(ADJSessionSuccess *)sessionSuccessResponseData { + if (nil == sessionSuccessResponseData) { + return; + } + + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + [self addValueOrEmpty:sessionSuccessResponseData.message forKey:@"message" toDictionary:dictionary]; + [self addValueOrEmpty:sessionSuccessResponseData.timeStamp forKey:@"timestamp" toDictionary:dictionary]; + [self addValueOrEmpty:sessionSuccessResponseData.adid forKey:@"adid" toDictionary:dictionary]; + if (sessionSuccessResponseData.jsonResponse != nil) { + [dictionary setObject:sessionSuccessResponseData.jsonResponse forKey:@"jsonResponse"]; + } + + NSData *dataSessionSuccess = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; + NSString *stringSessionSuccess = [[NSString alloc] initWithBytes:[dataSessionSuccess bytes] + length:[dataSessionSuccess length] + encoding:NSUTF8StringEncoding]; + const char* charArraySessionSuccess = [stringSessionSuccess UTF8String]; + UnitySendMessage([self.adjustUnitySceneName UTF8String], "GetNativeSessionSuccess", charArraySessionSuccess); +} + +- (void)adjustSessionTrackingFailedWannabe:(ADJSessionFailure *)sessionFailureResponseData { + if (nil == sessionFailureResponseData) { + return; + } + + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + [self addValueOrEmpty:sessionFailureResponseData.message forKey:@"message" toDictionary:dictionary]; + [self addValueOrEmpty:sessionFailureResponseData.timeStamp forKey:@"timestamp" toDictionary:dictionary]; + [self addValueOrEmpty:sessionFailureResponseData.adid forKey:@"adid" toDictionary:dictionary]; + [dictionary setObject:(sessionFailureResponseData.willRetry ? @"true" : @"false") forKey:@"willRetry"]; + if (sessionFailureResponseData.jsonResponse != nil) { + [dictionary setObject:sessionFailureResponseData.jsonResponse forKey:@"jsonResponse"]; + } + + NSData *dataSessionFailure = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; + NSString *stringSessionFailure = [[NSString alloc] initWithBytes:[dataSessionFailure bytes] + length:[dataSessionFailure length] + encoding:NSUTF8StringEncoding]; + const char* charArraySessionFailure = [stringSessionFailure UTF8String]; + UnitySendMessage([self.adjustUnitySceneName UTF8String], "GetNativeSessionFailure", charArraySessionFailure); +} + +- (BOOL)adjustDeeplinkResponseWannabe:(NSURL *)deeplink { + NSString *stringDeeplink = [deeplink absoluteString]; + const char* charDeeplink = [stringDeeplink UTF8String]; + UnitySendMessage([self.adjustUnitySceneName UTF8String], "GetNativeDeferredDeeplink", charDeeplink); + return _shouldLaunchDeferredDeeplink; +} + +- (void)adjustConversionValueUpdatedWannabe:(NSNumber *)conversionValue { + NSString *stringConversionValue = [conversionValue stringValue]; + const char* charConversionValue = [stringConversionValue UTF8String]; + UnitySendMessage([self.adjustUnitySceneName UTF8String], "GetNativeConversionValueUpdated", charConversionValue); +} + +- (void)adjustConversionValueUpdatedWannabe:(nullable NSNumber *)fineValue + coarseValue:(nullable NSString *)coarseValue + lockWindow:(nullable NSNumber *)lockWindow { + NSMutableDictionary *dictionary = [NSMutableDictionary dictionary]; + [self addValueOrEmpty:fineValue forKey:@"fineValue" toDictionary:dictionary]; + [self addValueOrEmpty:coarseValue forKey:@"coarseValue" toDictionary:dictionary]; + [self addValueOrEmpty:lockWindow forKey:@"lockWindow" toDictionary:dictionary]; + NSData *dataConversionValueUpdate = [NSJSONSerialization dataWithJSONObject:dictionary options:0 error:nil]; + NSString *stringConversionValueUpdate = [[NSString alloc] initWithBytes:[dataConversionValueUpdate bytes] + length:[dataConversionValueUpdate length] + encoding:NSUTF8StringEncoding]; + const char* charConversionValueUpdate = [stringConversionValueUpdate UTF8String]; + UnitySendMessage([self.adjustUnitySceneName UTF8String], "GetNativeSkad4ConversionValueUpdated", charConversionValueUpdate); +} + +- (void)swizzleOriginalSelector:(SEL)originalSelector + withSelector:(SEL)swizzledSelector { + Class className = [self class]; + Method originalMethod = class_getInstanceMethod(className, originalSelector); + Method swizzledMethod = class_getInstanceMethod(className, swizzledSelector); + + BOOL didAddMethod = class_addMethod(className, + originalSelector, + method_getImplementation(swizzledMethod), + method_getTypeEncoding(swizzledMethod)); + if (didAddMethod) { + class_replaceMethod(className, + swizzledSelector, + method_getImplementation(originalMethod), + method_getTypeEncoding(originalMethod)); + } else { + method_exchangeImplementations(originalMethod, swizzledMethod); + } +} + +- (void)addValueOrEmpty:(NSObject *)value + forKey:(NSString *)key + toDictionary:(NSMutableDictionary *)dictionary { + if (nil != value) { + if ([value isKindOfClass:[NSString class]]) { + [dictionary setObject:[NSString stringWithFormat:@"%@", value] forKey:key]; + } else if ([value isKindOfClass:[NSNumber class]]) { + [dictionary setObject:[NSString stringWithFormat:@"%@", [((NSNumber *)value) stringValue]] forKey:key]; + } else { + [dictionary setObject:@"" forKey:key]; + } + } else { + [dictionary setObject:@"" forKey:key]; + } +} + +@end diff --git a/Adjust/iOS/AdjustUnityDelegate.mm.meta b/Adjust/iOS/AdjustUnityDelegate.mm.meta new file mode 100644 index 0000000..553d0cd --- /dev/null +++ b/Adjust/iOS/AdjustUnityDelegate.mm.meta @@ -0,0 +1,133 @@ +fileFormatVersion: 2 +guid: 81438eed05b2e4b489f13efc94d5476a +timeCreated: 1489655217 +licenseType: Pro +PluginImporter: + serializedVersion: 2 + iconMap: {} + executionOrder: {} + isPreloaded: 0 + isOverridable: 0 + platformData: + data: + first: + '': Any + second: + enabled: 0 + settings: + Exclude Android: 1 + Exclude Editor: 1 + Exclude Linux: 1 + Exclude Linux64: 1 + Exclude LinuxUniversal: 1 + Exclude OSXIntel: 1 + Exclude OSXIntel64: 1 + Exclude OSXUniversal: 1 + Exclude WebGL: 1 + Exclude Win: 1 + Exclude Win64: 1 + Exclude iOS: 0 + Exclude tvOS: 1 + data: + first: + '': Editor + second: + enabled: 0 + settings: + CPU: AnyCPU + OS: AnyOS + data: + first: + Android: Android + second: + enabled: 0 + settings: + CPU: ARMv7 + data: + first: + Any: + second: + enabled: 0 + settings: {} + data: + first: + Editor: Editor + second: + enabled: 0 + settings: + DefaultValueInitialized: true + data: + first: + Facebook: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Facebook: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Linux + second: + enabled: 0 + settings: + CPU: x86 + data: + first: + Standalone: Linux64 + second: + enabled: 0 + settings: + CPU: x86_64 + data: + first: + Standalone: OSXIntel + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: OSXIntel64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + Standalone: Win64 + second: + enabled: 0 + settings: + CPU: AnyCPU + data: + first: + iPhone: iOS + second: + enabled: 1 + settings: + CompileFlags: + FrameworkDependencies: + data: + first: + tvOS: tvOS + second: + enabled: 0 + settings: + CompileFlags: + FrameworkDependencies: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Adjust/iOS/AdjustiOS.cs b/Adjust/iOS/AdjustiOS.cs new file mode 100644 index 0000000..17fe644 --- /dev/null +++ b/Adjust/iOS/AdjustiOS.cs @@ -0,0 +1,612 @@ +using System; +using System.Collections.Generic; +using System.Runtime.InteropServices; +using UnityEngine; + +namespace com.adjust.sdk +{ +#if UNITY_IOS + public class AdjustiOS + { + private const string sdkPrefix = "unity4.36.0"; + + [DllImport("__Internal")] + private static extern void _AdjustLaunchApp( + string appToken, + string environment, + string sdkPrefix, + string userAgent, + string defaultTracker, + string extenralDeviceId, + string urlStrategy, + string sceneName, + int allowSuppressLogLevel, + int logLevel, + int isDeviceKnown, + int eventBuffering, + int sendInBackground, + int allowAdServicesInfoReading, + int allowIdfaReading, + int deactivateSkAdNetworkHandling, + int linkMeEnabled, + int needsCost, + int coppaCompliant, + long secretId, + long info1, + long info2, + long info3, + long info4, + double delayStart, + int attConsentWaitingInterval, + int launchDeferredDeeplink, + int isAttributionCallbackImplemented, + int isEventSuccessCallbackImplemented, + int isEventFailureCallbackImplemented, + int isSessionSuccessCallbackImplemented, + int isSessionFailureCallbackImplemented, + int isDeferredDeeplinkCallbackImplemented, + int isConversionValueUpdatedCallbackImplemented, + int isSkad4ConversionValueUpdatedCallbackImplemented); + + [DllImport("__Internal")] + private static extern void _AdjustTrackEvent( + string eventToken, + double revenue, + string currency, + string receipt, + string productId, + string transactionId, + string callbackId, + int isReceiptSet, + string jsonCallbackParameters, + string jsonPartnerParameters); + + [DllImport("__Internal")] + private static extern void _AdjustSetEnabled(int enabled); + + [DllImport("__Internal")] + private static extern int _AdjustIsEnabled(); + + [DllImport("__Internal")] + private static extern void _AdjustSetOfflineMode(int enabled); + + [DllImport("__Internal")] + private static extern void _AdjustSetDeviceToken(string deviceToken); + + [DllImport("__Internal")] + private static extern void _AdjustAppWillOpenUrl(string url); + + [DllImport("__Internal")] + private static extern string _AdjustGetIdfa(); + + [DllImport("__Internal")] + private static extern string _AdjustGetIdfv(); + + [DllImport("__Internal")] + private static extern string _AdjustGetAdid(); + + [DllImport("__Internal")] + private static extern string _AdjustGetSdkVersion(); + + [DllImport("__Internal")] + private static extern void _AdjustGdprForgetMe(); + + [DllImport("__Internal")] + private static extern void _AdjustDisableThirdPartySharing(); + + [DllImport("__Internal")] + private static extern string _AdjustGetAttribution(); + + [DllImport("__Internal")] + private static extern void _AdjustSendFirstPackages(); + + [DllImport("__Internal")] + private static extern void _AdjustAddSessionPartnerParameter(string key, string value); + + [DllImport("__Internal")] + private static extern void _AdjustAddSessionCallbackParameter(string key, string value); + + [DllImport("__Internal")] + private static extern void _AdjustRemoveSessionPartnerParameter(string key); + + [DllImport("__Internal")] + private static extern void _AdjustRemoveSessionCallbackParameter(string key); + + [DllImport("__Internal")] + private static extern void _AdjustResetSessionPartnerParameters(); + + [DllImport("__Internal")] + private static extern void _AdjustResetSessionCallbackParameters(); + + [DllImport("__Internal")] + private static extern void _AdjustTrackAdRevenue(string source, string payload); + + [DllImport("__Internal")] + private static extern void _AdjustTrackAdRevenueNew( + string source, + double revenue, + string currency, + int adImpressionsCount, + string adRevenueNetwork, + string adRevenueUnit, + string adRevenuePlacement, + string jsonCallbackParameters, + string jsonPartnerParameters); + + [DllImport("__Internal")] + private static extern void _AdjustTrackAppStoreSubscription( + string price, + string currency, + string transactionId, + string receipt, + string billingStore, + string transactionDate, + string salesRegion, + string jsonCallbackParameters, + string jsonPartnerParameters); + + [DllImport("__Internal")] + private static extern void _AdjustTrackThirdPartySharing(int enabled, string jsonGranularOptions, string jsonPartnerSharingSettings); + + [DllImport("__Internal")] + private static extern void _AdjustTrackMeasurementConsent(int enabled); + + [DllImport("__Internal")] + private static extern void _AdjustSetTestOptions( + string baseUrl, + string gdprUrl, + string subscriptionUrl, + string purchaseVerificationUrl, + string extraPath, + long timerIntervalInMilliseconds, + long timerStartInMilliseconds, + long sessionIntervalInMilliseconds, + long subsessionIntervalInMilliseconds, + int teardown, + int deleteState, + int noBackoffWait, + int adServicesFrameworkEnabled); + + [DllImport("__Internal")] + private static extern void _AdjustRequestTrackingAuthorizationWithCompletionHandler(string sceneName); + + [DllImport("__Internal")] + private static extern void _AdjustUpdateConversionValue(int conversionValue); + + [DllImport("__Internal")] + private static extern void _AdjustUpdateConversionValueWithCallback(int conversionValue, string sceneName); + + [DllImport("__Internal")] + private static extern void _AdjustUpdateConversionValueWithCallbackSkad4(int conversionValue, string coarseValue, int lockedWindow, string sceneName); + + [DllImport("__Internal")] + private static extern void _AdjustCheckForNewAttStatus(); + + [DllImport("__Internal")] + private static extern int _AdjustGetAppTrackingAuthorizationStatus(); + + [DllImport("__Internal")] + private static extern void _AdjustTrackSubsessionStart(); + + [DllImport("__Internal")] + private static extern void _AdjustTrackSubsessionEnd(); + + [DllImport("__Internal")] + private static extern string _AdjustGetLastDeeplink(); + + [DllImport("__Internal")] + private static extern void _AdjustVerifyAppStorePurchase( + string transactionId, + string productId, + string receipt, + string sceneName); + + public AdjustiOS() {} + + public static void Start(AdjustConfig adjustConfig) + { + string appToken = adjustConfig.appToken != null ? adjustConfig.appToken : "ADJ_INVALID"; + string sceneName = adjustConfig.sceneName != null ? adjustConfig.sceneName : "ADJ_INVALID"; + string userAgent = adjustConfig.userAgent != null ? adjustConfig.userAgent : "ADJ_INVALID"; + string defaultTracker = adjustConfig.defaultTracker != null ? adjustConfig.defaultTracker : "ADJ_INVALID"; + string externalDeviceId = adjustConfig.externalDeviceId != null ? adjustConfig.externalDeviceId : "ADJ_INVALID"; + string urlStrategy = adjustConfig.urlStrategy != null ? adjustConfig.urlStrategy : "ADJ_INVALID"; + string environment = adjustConfig.environment.ToLowercaseString(); + long info1 = AdjustUtils.ConvertLong(adjustConfig.info1); + long info2 = AdjustUtils.ConvertLong(adjustConfig.info2); + long info3 = AdjustUtils.ConvertLong(adjustConfig.info3); + long info4 = AdjustUtils.ConvertLong(adjustConfig.info4); + long secretId = AdjustUtils.ConvertLong(adjustConfig.secretId); + double delayStart = AdjustUtils.ConvertDouble(adjustConfig.delayStart); + int attConsentWaitingInterval = AdjustUtils.ConvertInt(adjustConfig.attConsentWaitingInterval); + int logLevel = AdjustUtils.ConvertLogLevel(adjustConfig.logLevel); + int isDeviceKnown = AdjustUtils.ConvertBool(adjustConfig.isDeviceKnown); + int sendInBackground = AdjustUtils.ConvertBool(adjustConfig.sendInBackground); + int eventBufferingEnabled = AdjustUtils.ConvertBool(adjustConfig.eventBufferingEnabled); + int allowAdServicesInfoReading = AdjustUtils.ConvertBool(adjustConfig.allowAdServicesInfoReading); + int allowIdfaReading = AdjustUtils.ConvertBool(adjustConfig.allowIdfaReading); + int allowSuppressLogLevel = AdjustUtils.ConvertBool(adjustConfig.allowSuppressLogLevel); + int launchDeferredDeeplink = AdjustUtils.ConvertBool(adjustConfig.launchDeferredDeeplink); + int deactivateSkAdNetworkHandling = AdjustUtils.ConvertBool(adjustConfig.skAdNetworkHandling); + int linkMeEnabled = AdjustUtils.ConvertBool(adjustConfig.linkMeEnabled); + int needsCost = AdjustUtils.ConvertBool(adjustConfig.needsCost); + int coppaCompliant = AdjustUtils.ConvertBool(adjustConfig.coppaCompliantEnabled); + int isAttributionCallbackImplemented = AdjustUtils.ConvertBool(adjustConfig.getAttributionChangedDelegate() != null); + int isEventSuccessCallbackImplemented = AdjustUtils.ConvertBool(adjustConfig.getEventSuccessDelegate() != null); + int isEventFailureCallbackImplemented = AdjustUtils.ConvertBool(adjustConfig.getEventFailureDelegate() != null); + int isSessionSuccessCallbackImplemented = AdjustUtils.ConvertBool(adjustConfig.getSessionSuccessDelegate() != null); + int isSessionFailureCallbackImplemented = AdjustUtils.ConvertBool(adjustConfig.getSessionFailureDelegate() != null); + int isDeferredDeeplinkCallbackImplemented = AdjustUtils.ConvertBool(adjustConfig.getDeferredDeeplinkDelegate() != null); + int isConversionValueUpdatedCallbackImplemented = AdjustUtils.ConvertBool(adjustConfig.getConversionValueUpdatedDelegate() != null); + int isSkad4ConversionValueUpdatedCallbackImplemented = AdjustUtils.ConvertBool(adjustConfig.getSkad4ConversionValueUpdatedDelegate() != null); + + _AdjustLaunchApp( + appToken, + environment, + sdkPrefix, + userAgent, + defaultTracker, + externalDeviceId, + urlStrategy, + sceneName, + allowSuppressLogLevel, + logLevel, + isDeviceKnown, + eventBufferingEnabled, + sendInBackground, + allowAdServicesInfoReading, + allowIdfaReading, + deactivateSkAdNetworkHandling, + linkMeEnabled, + needsCost, + coppaCompliant, + secretId, + info1, + info2, + info3, + info4, + delayStart, + attConsentWaitingInterval, + launchDeferredDeeplink, + isAttributionCallbackImplemented, + isEventSuccessCallbackImplemented, + isEventFailureCallbackImplemented, + isSessionSuccessCallbackImplemented, + isSessionFailureCallbackImplemented, + isDeferredDeeplinkCallbackImplemented, + isConversionValueUpdatedCallbackImplemented, + isSkad4ConversionValueUpdatedCallbackImplemented); + } + + public static void TrackEvent(AdjustEvent adjustEvent) + { + int isReceiptSet = AdjustUtils.ConvertBool(adjustEvent.isReceiptSet); + double revenue = AdjustUtils.ConvertDouble(adjustEvent.revenue); + string eventToken = adjustEvent.eventToken; + string currency = adjustEvent.currency; + string receipt = adjustEvent.receipt; + string productId = adjustEvent.productId; + string transactionId = adjustEvent.transactionId; + string callbackId = adjustEvent.callbackId; + string stringJsonCallbackParameters = AdjustUtils.ConvertListToJson(adjustEvent.callbackList); + string stringJsonPartnerParameters = AdjustUtils.ConvertListToJson(adjustEvent.partnerList); + + _AdjustTrackEvent(eventToken, revenue, currency, receipt, productId, transactionId, callbackId, isReceiptSet, stringJsonCallbackParameters, stringJsonPartnerParameters); + } + + public static void SetEnabled(bool enabled) + { + _AdjustSetEnabled(AdjustUtils.ConvertBool(enabled)); + } + + public static bool IsEnabled() + { + var iIsEnabled = _AdjustIsEnabled(); + return Convert.ToBoolean(iIsEnabled); + } + + public static void SetOfflineMode(bool enabled) + { + _AdjustSetOfflineMode(AdjustUtils.ConvertBool(enabled)); + } + + public static void SendFirstPackages() + { + _AdjustSendFirstPackages(); + } + + public static void AppWillOpenUrl(string url) + { + _AdjustAppWillOpenUrl(url); + } + + public static void AddSessionPartnerParameter(string key, string value) + { + _AdjustAddSessionPartnerParameter(key, value); + } + + public static void AddSessionCallbackParameter(string key, string value) + { + _AdjustAddSessionCallbackParameter(key, value); + } + + public static void RemoveSessionPartnerParameter(string key) + { + _AdjustRemoveSessionPartnerParameter(key); + } + + public static void RemoveSessionCallbackParameter(string key) + { + _AdjustRemoveSessionCallbackParameter(key); + } + + public static void ResetSessionPartnerParameters() + { + _AdjustResetSessionPartnerParameters(); + } + + public static void ResetSessionCallbackParameters() + { + _AdjustResetSessionCallbackParameters(); + } + + public static void TrackAdRevenue(string source, string payload) + { + _AdjustTrackAdRevenue(source, payload); + } + + public static void TrackAdRevenue(AdjustAdRevenue adRevenue) + { + string source = adRevenue.source; + double revenue = AdjustUtils.ConvertDouble(adRevenue.revenue); + string currency = adRevenue.currency; + int adImpressionsCount = AdjustUtils.ConvertInt(adRevenue.adImpressionsCount); + string adRevenueNetwork = adRevenue.adRevenueNetwork; + string adRevenueUnit = adRevenue.adRevenueUnit; + string adRevenuePlacement = adRevenue.adRevenuePlacement; + string stringJsonCallbackParameters = AdjustUtils.ConvertListToJson(adRevenue.callbackList); + string stringJsonPartnerParameters = AdjustUtils.ConvertListToJson(adRevenue.partnerList); + + _AdjustTrackAdRevenueNew( + source, + revenue, + currency, + adImpressionsCount, + adRevenueNetwork, + adRevenueUnit, + adRevenuePlacement, + stringJsonCallbackParameters, + stringJsonPartnerParameters); + } + + public static void TrackAppStoreSubscription(AdjustAppStoreSubscription subscription) + { + string price = subscription.price; + string currency = subscription.currency; + string transactionId = subscription.transactionId; + string receipt = subscription.receipt; + string billingStore = subscription.billingStore; + string transactionDate = subscription.transactionDate; + string salesRegion = subscription.salesRegion; + string stringJsonCallbackParameters = AdjustUtils.ConvertListToJson(subscription.callbackList); + string stringJsonPartnerParameters = AdjustUtils.ConvertListToJson(subscription.partnerList); + + _AdjustTrackAppStoreSubscription( + price, + currency, + transactionId, + receipt, + billingStore, + transactionDate, + salesRegion, + stringJsonCallbackParameters, + stringJsonPartnerParameters); + } + + public static void TrackThirdPartySharing(AdjustThirdPartySharing thirdPartySharing) + { + int enabled = AdjustUtils.ConvertBool(thirdPartySharing.isEnabled); + List jsonGranularOptions = new List(); + foreach (KeyValuePair> entry in thirdPartySharing.granularOptions) + { + jsonGranularOptions.Add(entry.Key); + jsonGranularOptions.Add(AdjustUtils.ConvertListToJson(entry.Value)); + } + List jsonPartnerSharingSettings = new List(); + foreach (KeyValuePair> entry in thirdPartySharing.partnerSharingSettings) + { + jsonPartnerSharingSettings.Add(entry.Key); + jsonPartnerSharingSettings.Add(AdjustUtils.ConvertListToJson(entry.Value)); + } + + _AdjustTrackThirdPartySharing(enabled, AdjustUtils.ConvertListToJson(jsonGranularOptions), AdjustUtils.ConvertListToJson(jsonPartnerSharingSettings)); + } + + public static void TrackMeasurementConsent(bool enabled) + { + _AdjustTrackMeasurementConsent(AdjustUtils.ConvertBool(enabled)); + } + + public static void RequestTrackingAuthorizationWithCompletionHandler(string sceneName) + { + string cSceneName = sceneName != null ? sceneName : "ADJ_INVALID"; + _AdjustRequestTrackingAuthorizationWithCompletionHandler(cSceneName); + } + + public static void UpdateConversionValue(int conversionValue) + { + _AdjustUpdateConversionValue(conversionValue); + } + + public static void UpdateConversionValue(int conversionValue, string sceneName) + { + string cSceneName = sceneName != null ? sceneName : "ADJ_INVALID"; + _AdjustUpdateConversionValueWithCallback(conversionValue, cSceneName); + } + + public static void UpdateConversionValue(int conversionValue, string coarseValue, bool lockedWindow, string sceneName) + { + string cSceneName = sceneName != null ? sceneName : "ADJ_INVALID"; + _AdjustUpdateConversionValueWithCallbackSkad4(conversionValue, coarseValue, AdjustUtils.ConvertBool(lockedWindow), cSceneName); + } + + public static void CheckForNewAttStatus() + { + _AdjustCheckForNewAttStatus(); + } + + public static int GetAppTrackingAuthorizationStatus() + { + return _AdjustGetAppTrackingAuthorizationStatus(); + } + + public static void SetDeviceToken(string deviceToken) + { + _AdjustSetDeviceToken(deviceToken); + } + + public static string GetIdfa() + { + return _AdjustGetIdfa(); + } + + public static string GetIdfv() + { + return _AdjustGetIdfv(); + } + + public static string GetAdid() + { + return _AdjustGetAdid(); + } + + public static string GetSdkVersion() + { + return sdkPrefix + "@" + _AdjustGetSdkVersion(); + } + + public static void GdprForgetMe() + { + _AdjustGdprForgetMe(); + } + + public static void DisableThirdPartySharing() + { + _AdjustDisableThirdPartySharing(); + } + + public static AdjustAttribution GetAttribution() + { + string attributionString = _AdjustGetAttribution(); + if (null == attributionString) + { + return null; + } + + var attribution = new AdjustAttribution(attributionString); + return attribution; + } + + public static string GetLastDeeplink() + { + return _AdjustGetLastDeeplink(); + } + + public static void VerifyAppStorePurchase(AdjustAppStorePurchase purchase, string sceneName) + { + string transactionId = purchase.transactionId; + string productId = purchase.productId; + string receipt = purchase.receipt; + string cSceneName = sceneName != null ? sceneName : "ADJ_INVALID"; + + _AdjustVerifyAppStorePurchase( + transactionId, + productId, + receipt, + cSceneName); + } + + // Used for testing only. + public static void SetTestOptions(Dictionary testOptions) + { + string baseUrl = testOptions[AdjustUtils.KeyTestOptionsBaseUrl]; + string gdprUrl = testOptions[AdjustUtils.KeyTestOptionsGdprUrl]; + string subscriptionUrl = testOptions[AdjustUtils.KeyTestOptionsSubscriptionUrl]; + string purchaseVerificationUrl = testOptions[AdjustUtils.KeyTestOptionsPurchaseVerificationUrl]; + string extraPath = testOptions.ContainsKey(AdjustUtils.KeyTestOptionsExtraPath) ? testOptions[AdjustUtils.KeyTestOptionsExtraPath] : null; + long timerIntervalMilis = -1; + long timerStartMilis = -1; + long sessionIntMilis = -1; + long subsessionIntMilis = -1; + bool teardown = false; + bool deleteState = false; + bool noBackoffWait = false; + bool adServicesFrameworkEnabled = false; + + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsTimerIntervalInMilliseconds)) + { + timerIntervalMilis = long.Parse(testOptions[AdjustUtils.KeyTestOptionsTimerIntervalInMilliseconds]); + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsTimerStartInMilliseconds)) + { + timerStartMilis = long.Parse(testOptions[AdjustUtils.KeyTestOptionsTimerStartInMilliseconds]); + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsSessionIntervalInMilliseconds)) + { + sessionIntMilis = long.Parse(testOptions[AdjustUtils.KeyTestOptionsSessionIntervalInMilliseconds]); + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsSubsessionIntervalInMilliseconds)) + { + subsessionIntMilis = long.Parse(testOptions[AdjustUtils.KeyTestOptionsSubsessionIntervalInMilliseconds]); + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsTeardown)) + { + teardown = testOptions[AdjustUtils.KeyTestOptionsTeardown].ToLower() == "true"; + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsDeleteState)) + { + deleteState = testOptions[AdjustUtils.KeyTestOptionsDeleteState].ToLower() == "true"; + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsNoBackoffWait)) + { + noBackoffWait = testOptions[AdjustUtils.KeyTestOptionsNoBackoffWait].ToLower() == "true"; + } + if (testOptions.ContainsKey(AdjustUtils.KeyTestOptionsAdServicesFrameworkEnabled)) + { + adServicesFrameworkEnabled = testOptions[AdjustUtils.KeyTestOptionsAdServicesFrameworkEnabled].ToLower() == "true"; + } + + _AdjustSetTestOptions( + baseUrl, + gdprUrl, + subscriptionUrl, + purchaseVerificationUrl, + extraPath, + timerIntervalMilis, + timerStartMilis, + sessionIntMilis, + subsessionIntMilis, + AdjustUtils.ConvertBool(teardown), + AdjustUtils.ConvertBool(deleteState), + AdjustUtils.ConvertBool(noBackoffWait), + AdjustUtils.ConvertBool(adServicesFrameworkEnabled)); + } + + public static void TrackSubsessionStart(string testingArgument = null) + { + if (testingArgument == "test") + { + _AdjustTrackSubsessionStart(); + } + } + + public static void TrackSubsessionEnd(string testingArgument = null) + { + if (testingArgument == "test") + { + _AdjustTrackSubsessionEnd(); + } + } + } +#endif +} diff --git a/Adjust/iOS/AdjustiOS.cs.meta b/Adjust/iOS/AdjustiOS.cs.meta new file mode 100644 index 0000000..ab29d21 --- /dev/null +++ b/Adjust/iOS/AdjustiOS.cs.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: e0210f5940cff42e699945b0c5aa4c9b +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: diff --git a/Editor.meta b/Editor.meta new file mode 100644 index 0000000..fac8688 --- /dev/null +++ b/Editor.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b51771bcccf507e45b2db8213466a010 +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/CodeMods.meta b/Editor/CodeMods.meta new file mode 100644 index 0000000..a4f65b0 --- /dev/null +++ b/Editor/CodeMods.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 95d542c6d77304dbd9e324b9b964506b +folderAsset: yes +DefaultImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Editor/CodeMods/AdjustMod.cs b/Editor/CodeMods/AdjustMod.cs new file mode 100644 index 0000000..99765aa --- /dev/null +++ b/Editor/CodeMods/AdjustMod.cs @@ -0,0 +1,117 @@ +using System.IO; +using System.Linq; +using UnityEditor; +using UnityEditor.Compilation; +using UnityEngine; + +namespace Guru.Editor.Adjust +{ + public class AdjustMod + { + public static string Tag = "[MOD]"; + + private static string CodeReplaceSample = + "AssetDatabase.GUIDToAssetPath(guids[0]).Replace(\"AdjustSettings.cs\", \"AdjustSettings.asset\")"; + + + + + /// + /// 应用补丁 + /// + public static void Apply() + { + var mod = new AdjustMod(); + mod.FixSettingsInstancePath(); + } + + /// + /// 修复示例地址 + /// + private void FixSettingsInstancePath() + { + var guids = AssetDatabase.FindAssets($"{nameof(AdjustSettings)} t:Script"); + if (guids.Length > 0) + { + for (int i = 0; i < guids.Length; i++) + { + var p = AssetDatabase.GUIDToAssetPath(guids[i]); + if(p.Contains($"{nameof(AdjustSettings)}.cs")) + { + var path = Path.Combine(Application.dataPath, p.Replace("Assets/", "")); + if (File.Exists(path)) + { + InjectCodeAtPath(path); + return; + } + break; + } + + } + } + Debug.Log($"{Tag}--- Guru Adjust inject failed"); + } + + /// + /// 注入代码逻辑 + /// + /// + private void InjectCodeAtPath(string path) + { + // ---------- Inject Code ---------- + string indent = "\t\t\t\t"; + string Info = $"{indent}// ************ Auto fixed by Guru Adjust ************"; + + string buffer = $"{Info}"; + // buffer += $"\n{indent}if(System.IO.File.Exists(\"{GuruAdjustSdkAPI.AdjustSettingsPackagePath}\")) System.IO.File.Delete(\"{GuruAdjustSdkAPI.AdjustSettingsPackagePath}\");"; + buffer += $"\n{indent}if(!System.IO.Directory.Exists(\"{GuruAdjustSdkAPI.AdjustSettingsRootDir}\")) System.IO.Directory.CreateDirectory(\"{GuruAdjustSdkAPI.AdjustSettingsRootDir}\");"; + buffer += $"\n{indent}var assetPath = \"{GuruAdjustSdkAPI.AdjustSettingsAssetPath}\";"; + buffer += $"\n{Info}"; + + var lines = File.ReadLines(path).ToList(); + string line = ""; + bool isDirty = false; + for (int i = 0; i < lines.Count; i++) + { + line = lines[i]; + if (line.Contains(CodeReplaceSample) && !line.Contains("//")) + { + lines[i] = $"//{line}"; + lines.Insert(i+1, buffer); + isDirty = true; + break; + } + } + + if (isDirty) + { + File.WriteAllLines(path, lines.ToArray()); + Debug.Log($"{Tag}--- Guru Adjust inject success"); + CompilationPipeline.RequestScriptCompilation(); + } + } + + + + /// + /// 创建接口 + /// + /// + public static void CreateInstance (AdjustSettings instance) + { + // 删除旧文件 + if(File.Exists(GuruAdjustSdkAPI.AdjustSettingsPackagePath)) + File.Delete(GuruAdjustSdkAPI.AdjustSettingsPackagePath); + + // 创建新父目录 + if (!Directory.Exists(GuruAdjustSdkAPI.AdjustSettingsPackagePath)) + Directory.CreateDirectory(GuruAdjustSdkAPI.AdjustSettingsPackagePath); + + // 创建对象 + var assetPath = GuruAdjustSdkAPI.AdjustSettingsAssetPath; + AssetDatabase.CreateAsset(instance, assetPath); + AssetDatabase.SaveAssets(); + AssetDatabase.Refresh(); + } + } +} \ No newline at end of file diff --git a/Editor/CodeMods/AdjustMod.cs.meta b/Editor/CodeMods/AdjustMod.cs.meta new file mode 100644 index 0000000..b074945 --- /dev/null +++ b/Editor/CodeMods/AdjustMod.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 932478d33dd84acdbbc87adf508f00bd +timeCreated: 1701913353 \ No newline at end of file diff --git a/Editor/CodeMods/GuruAdjustCodeFixer.cs b/Editor/CodeMods/GuruAdjustCodeFixer.cs new file mode 100644 index 0000000..2077653 --- /dev/null +++ b/Editor/CodeMods/GuruAdjustCodeFixer.cs @@ -0,0 +1,38 @@ +using UnityEditor; + +namespace Guru.Editor.Adjust +{ + public class GuruAdjustCodeFixer + { + + + /// + /// 应用所有的补丁 + /// + public static void ApplyAllMods() + { + AdjustMod.Apply(); + } + + + + + +#if GURU_SDK_DEV + + //---------- 编辑器快捷菜单 ------------------- + + [MenuItem("Guru/Dev/Adjust/Apply All Mods")] + private static void DevInjectCodeFix() + { + ApplyAllMods(); + } + + +#endif + + + + } + +} \ No newline at end of file diff --git a/Editor/CodeMods/GuruAdjustCodeFixer.cs.meta b/Editor/CodeMods/GuruAdjustCodeFixer.cs.meta new file mode 100644 index 0000000..228bf03 --- /dev/null +++ b/Editor/CodeMods/GuruAdjustCodeFixer.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 616e0c20673b4687847e17a47f1ffa41 +timeCreated: 1701913321 \ No newline at end of file diff --git a/Editor/GuruEditorAdjust.asmdef b/Editor/GuruEditorAdjust.asmdef new file mode 100644 index 0000000..557aa41 --- /dev/null +++ b/Editor/GuruEditorAdjust.asmdef @@ -0,0 +1,18 @@ +{ + "name": "GuruEditorAdjust", + "rootNamespace": "Guru.Editor.Adjust", + "references": [ + "Adjust.Editor" + ], + "includePlatforms": [ + "Editor" + ], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Editor/GuruEditorAdjust.asmdef.meta b/Editor/GuruEditorAdjust.asmdef.meta new file mode 100644 index 0000000..66fbf29 --- /dev/null +++ b/Editor/GuruEditorAdjust.asmdef.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 969f2d3fc6114e86a337bfffefbcce69 +timeCreated: 1701912339 \ No newline at end of file diff --git a/Editor/GuruEditorAdjust.meta b/Editor/GuruEditorAdjust.meta new file mode 100644 index 0000000..830ac52 --- /dev/null +++ b/Editor/GuruEditorAdjust.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 074baa43b11e48c2a8e523a579e67467 +timeCreated: 1701912275 \ No newline at end of file diff --git a/Editor/GuruEditorAdjust/GuruAdjustMenuItems.cs b/Editor/GuruEditorAdjust/GuruAdjustMenuItems.cs new file mode 100644 index 0000000..c4af3a2 --- /dev/null +++ b/Editor/GuruEditorAdjust/GuruAdjustMenuItems.cs @@ -0,0 +1,13 @@ +namespace Guru.Editor.Adjust +{ + using UnityEditor; + using UnityEngine; + + public class GuruAdjustMenuItems + { + // TBD add Editor Menus +#if GURU_SDK_DEV + +#endif + } +} \ No newline at end of file diff --git a/Editor/GuruEditorAdjust/GuruAdjustMenuItems.cs.meta b/Editor/GuruEditorAdjust/GuruAdjustMenuItems.cs.meta new file mode 100644 index 0000000..fe793ab --- /dev/null +++ b/Editor/GuruEditorAdjust/GuruAdjustMenuItems.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: fa4c8214e3ee4e4ea8c31c3c6dc75f94 +timeCreated: 1701913194 \ No newline at end of file diff --git a/Editor/GuruEditorAdjust/GuruAdjustSdkAPI.cs b/Editor/GuruEditorAdjust/GuruAdjustSdkAPI.cs new file mode 100644 index 0000000..b052cb7 --- /dev/null +++ b/Editor/GuruEditorAdjust/GuruAdjustSdkAPI.cs @@ -0,0 +1,107 @@ +using System.IO; +using UnityEditor; +using UnityEngine; + +namespace Guru.Editor.Adjust +{ + + /// + /// 修改器API + /// + public static class GuruAdjustSdkAPI + { + // ------------ VERSION INFO ------------ + public const string Version = "0.1.0"; + public const string SdkVersion = "4.36.0"; + // ------------ VERSION INFO ------------ + + public const string PackageName = "com.guru.unity.adjust"; + public static readonly string AdjustSettingsRootDir = "Assets/Guru/Editor"; + public static string AdjustSettingsAssetPath = $"{AdjustSettingsRootDir}/AdjustSettings.asset"; + + public static string PackageEditorRoot + { + get + { +#if GURU_SDK_DEV + return $"__upm/{PackageName}/Adjust/Editor"; +#endif + return $"Packages/{PackageName}/Adjust/Editor"; + } + } + public static string AdjustSettingsPackagePath = $"{PackageEditorRoot}/AdjustSettings.asset"; + + #region AdjustSettings + + /// + /// 创建AdjustSettings + /// + /// + public static AdjustSettings LoadOrCreateAdjustSettings() + { + // 若原始文件存在 + if (File.Exists(Path.Combine(Application.dataPath.Replace("Assets", ""), AdjustSettingsAssetPath))) + { + return AssetDatabase.LoadAssetAtPath(AdjustSettingsAssetPath); + } + // 否则开始查找文件 + var guids = AssetDatabase.FindAssets($"{nameof(AdjustSettings)} t:ScriptableObject"); + int removed = 0; + if (guids.Length > 0) + { + foreach (var g in guids) + { + var path = AssetDatabase.GUIDToAssetPath(g); + + Debug.Log($"--- Found assets at path:{path}"); + + + if (!path.StartsWith(AdjustSettingsRootDir)) + { + AssetDatabase.DeleteAsset(path); + removed++; + } + } + } + + if (guids.Length == 0 || removed >= guids.Length) + { + return CreateDefaultAdjustSettings(); // 创建默认的AppLovin Settings 配置 + } + + return AssetDatabase.LoadAssetAtPath(AssetDatabase.GUIDToAssetPath(guids[0])); + } + + /// + /// 创建AppLovinSettings 配置默认路径 + /// + /// + private static AdjustSettings CreateDefaultAdjustSettings() + { + // Create Root dir + var expDir = + new DirectoryInfo(Path.Combine(Application.dataPath.Replace("Assets", ""), AdjustSettingsRootDir)); + if (!expDir.Exists) expDir.Create(); + + // Make a new one + var settings = ScriptableObject.CreateInstance(); + AssetDatabase.CreateAsset(settings, AdjustSettingsAssetPath); + AssetDatabase.SaveAssetIfDirty(settings); + AssetDatabase.Refresh(); + + Debug.Log($"[Guru] --- Create AdjustSettings at: \n{AdjustSettingsAssetPath}"); + + return settings; + } + + #endregion + + + public static void ApllyMods() + { + + } + + + } +} \ No newline at end of file diff --git a/Editor/GuruEditorAdjust/GuruAdjustSdkAPI.cs.meta b/Editor/GuruEditorAdjust/GuruAdjustSdkAPI.cs.meta new file mode 100644 index 0000000..00d834d --- /dev/null +++ b/Editor/GuruEditorAdjust/GuruAdjustSdkAPI.cs.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 1b59ffd8912f4484bea4c382de286fd2 +timeCreated: 1701912296 \ No newline at end of file diff --git a/README.md b/README.md new file mode 100644 index 0000000..d1b9221 --- /dev/null +++ b/README.md @@ -0,0 +1,40 @@ +# GURU Adjust + +### VERSION 0.1.0 + +## 插件介绍 + +### Adjust插件 + +版本依赖: +- Unity: `4.36.0` +- Android: `4.37.0` +- iOS: `4.36.0` +- Windows: `4.17.0` + + +本项目是基于[Adjust官方的Unity SDK插件](https://github.com/adjust/unity_sdk),进行了一定的封装. + +方便Unity开发者通过UPM使用 Adjust 相关的功能。 + + + + + +## 安装和接入 + + +### 插件引入 + +- 根据文档部署好本机配置后, 请在Unity内部配置如下参数 +- - 确保自己拥有该项目的访问权限 + - 确保自己的Github账户可以使用SSH或者UserToken的方式拉取代码. (用户名密码的方式已不被Github支持) + - 修改位于项目 `Packages/manifest.json` 文件,在`dependencies`中添加 + ``` + { + "dependencies": { + "com.guru.unity.adjust": "git@github.com:castbox/upm_guru_adjust.git#0.1.0", + ... + } + } + ``` \ No newline at end of file diff --git a/README.md.meta b/README.md.meta new file mode 100644 index 0000000..385637e --- /dev/null +++ b/README.md.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: e92fa5fb3e8e4dabab546676aafe2f43 +timeCreated: 1701844633 \ No newline at end of file diff --git a/package.json b/package.json new file mode 100644 index 0000000..0ede210 --- /dev/null +++ b/package.json @@ -0,0 +1,11 @@ +{ + "name": "com.guru.unity.adjust", + "displayName": "Guru Adjust", + "version": "0.1.0", + "description": "Guru 整合 Adjust 插件", + "unity": "2020.3", + "license": "MIT", + "category": "Game tool", + "dependencies": { + } +} \ No newline at end of file diff --git a/package.json.meta b/package.json.meta new file mode 100644 index 0000000..687477b --- /dev/null +++ b/package.json.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 9684cfc503ab4f2881acbce12c1e5f30 +timeCreated: 1701844637 \ No newline at end of file