-
Notifications
You must be signed in to change notification settings - Fork 71
Commit
Unity upgrade
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[submodule "Assets/Plugins/iOS/src/Adjust"] | ||
path = Assets/Plugins/iOS/src/Adjust | ||
url = [email protected]:adjust/ios_sdk.git | ||
[submodule "Assets/Plugins/Android/src/Adjust"] | ||
path = Assets/Plugins/Android/src/Adjust | ||
[submodule "ext/Android/sdk"] | ||
path = ext/Android/sdk | ||
url = [email protected]:adjust/android_sdk.git | ||
[submodule "ext/iOS/sdk"] | ||
path = ext/iOS/sdk | ||
url = [email protected]:adjust/ios_sdk.git |
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,193 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
using UnityEngine; | ||
|
||
namespace com.adjust.sdk | ||
{ | ||
public class Adjust : MonoBehaviour | ||
{ | ||
private const string sdkPrefix = "unity4.0.0"; | ||
private const string errorMessage = "adjust: SDK not started. Start it manually using the 'appDidLaunch' method."; | ||
|
||
private static IAdjust instance = null; | ||
private static Action<AdjustAttribution> attributionChangedDelegate = null; | ||
|
||
public bool startManually = false; | ||
public bool eventBuffering = false; | ||
public bool printAttribution = false; | ||
|
||
public string appToken = "{Your App Token}"; | ||
|
||
public AdjustLogLevel logLevel = AdjustLogLevel.Info; | ||
public AdjustEnvironment environment = AdjustEnvironment.Sandbox; | ||
|
||
#region Unity lifecycle methods | ||
|
||
void Awake () | ||
{ | ||
if (!this.startManually) { | ||
AdjustConfig adjustConfig = new AdjustConfig (this.appToken, this.environment); | ||
adjustConfig.setLogLevel (this.logLevel); | ||
adjustConfig.setEventBufferingEnabled (eventBuffering); | ||
|
||
if (printAttribution) { | ||
adjustConfig.setAttributionChangedDelegate(responseDelegate); | ||
} | ||
|
||
Adjust.start (adjustConfig); | ||
} | ||
} | ||
|
||
void OnApplicationPause(bool pauseStatus) { | ||
if (Adjust.instance == null) { | ||
return; | ||
} | ||
|
||
if (pauseStatus) { | ||
Adjust.instance.onPause(); | ||
} else { | ||
Adjust.instance.onResume(); | ||
} | ||
} | ||
|
||
#endregion | ||
|
||
#region Adjust methods | ||
|
||
public static void start (AdjustConfig adjustConfig) | ||
{ | ||
if (Adjust.instance != null) { | ||
Debug.Log ("adjust: Error, SDK already started."); | ||
return; | ||
} | ||
|
||
if (adjustConfig == null) { | ||
Debug.Log ("adjust: Missing config to start."); | ||
return; | ||
} | ||
|
||
#if UNITY_EDITOR | ||
Adjust.instance = null; | ||
#elif UNITY_IOS | ||
Adjust.instance = new AdjustiOS(); | ||
#elif UNITY_ANDROID | ||
Adjust.instance = new AdjustAndroid(); | ||
#else | ||
Adjust.instance = null; | ||
#endif | ||
|
||
if (Adjust.instance == null) { | ||
Debug.Log ("adjust: SDK can only be used in Android, iOS, Windows Phone 8 or Windows Store apps."); | ||
return; | ||
} | ||
|
||
adjustConfig.setSdkPrefix(Adjust.sdkPrefix); | ||
Adjust.attributionChangedDelegate = adjustConfig.getAttributionChangedDelegate (); | ||
|
||
Adjust.instance.start (adjustConfig); | ||
} | ||
|
||
public static void trackEvent (AdjustEvent adjustEvent) | ||
{ | ||
if (Adjust.instance == null) { | ||
Debug.Log (Adjust.errorMessage); | ||
return; | ||
} | ||
|
||
if (adjustEvent == null) { | ||
Debug.Log ("adjust: Missing event to track."); | ||
return; | ||
} | ||
|
||
Adjust.instance.trackEvent (adjustEvent); | ||
} | ||
|
||
public static void setEnabled(bool enabled) { | ||
if (Adjust.instance == null) { | ||
Debug.Log(Adjust.errorMessage); | ||
return; | ||
} | ||
|
||
Adjust.instance.setEnabled(enabled); | ||
} | ||
|
||
public static bool isEnabled() { | ||
if (Adjust.instance == null) { | ||
Debug.Log(Adjust.errorMessage); | ||
return false; | ||
} | ||
|
||
return Adjust.instance.isEnabled(); | ||
} | ||
|
||
public static void setOfflineMode(bool enabled) { | ||
if (Adjust.instance == null) { | ||
Debug.Log(Adjust.errorMessage); | ||
return; | ||
} | ||
|
||
Adjust.instance.setOfflineMode(enabled); | ||
} | ||
|
||
#endregion | ||
|
||
#region Attribution callback | ||
|
||
public void getNativeMessage (string sAttributionData) | ||
{ | ||
Adjust.runAttributionChangedDelegate (sAttributionData); | ||
} | ||
|
||
public static void runAttributionChangedDelegate (string stringAttributionData) | ||
{ | ||
if (instance == null) { | ||
Debug.Log (Adjust.errorMessage); | ||
return; | ||
} | ||
if (Adjust.attributionChangedDelegate == null) { | ||
Debug.Log ("adjust: Attribution changed delegate was not set."); | ||
return; | ||
} | ||
|
||
var attribution = new AdjustAttribution (stringAttributionData); | ||
Adjust.attributionChangedDelegate (attribution); | ||
} | ||
|
||
#endregion | ||
|
||
#region Private & helper methods | ||
|
||
// Our delegate for detecting attribution changes if choosen not to start manually. | ||
private void responseDelegate(AdjustAttribution responseData) | ||
{ | ||
Debug.Log ("Attribution changed!"); | ||
|
||
if (responseData.trackerName != null) { | ||
Debug.Log ("trackerName " + responseData.trackerName); | ||
} | ||
|
||
if (responseData.trackerToken != null) { | ||
Debug.Log ("trackerToken " + responseData.trackerToken); | ||
} | ||
|
||
if (responseData.network != null) { | ||
Debug.Log ("network " + responseData.network); | ||
} | ||
|
||
if (responseData.campaign != null) { | ||
Debug.Log ("campaign " + responseData.campaign); | ||
} | ||
|
||
if (responseData.adgroup != null) { | ||
Debug.Log ("adgroup " + responseData.adgroup); | ||
} | ||
|
||
if (responseData.creative != null) { | ||
Debug.Log ("creative " + responseData.creative); | ||
} | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.