Skip to content

Commit 6f5dc44

Browse files
committed
WP and WS unity
1 parent c154a84 commit 6f5dc44

File tree

6 files changed

+214
-3
lines changed

6 files changed

+214
-3
lines changed

Assets/Adjust/Adjust.cs

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ public static void start (AdjustConfig adjustConfig)
7575
Adjust.instance = new AdjustiOS ();
7676
#elif UNITY_ANDROID
7777
Adjust.instance = new AdjustAndroid ();
78+
#elif UNITY_WP8
79+
Adjust.instance = new AdjustWP8 ();
80+
#elif UNITY_METRO
81+
Adjust.instance = new AdjustMetro ();
7882
#else
7983
Adjust.instance = null;
8084
#endif
@@ -160,10 +164,10 @@ public static void setReferrer (string referrer)
160164

161165
public void getNativeMessage (string sAttributionData)
162166
{
163-
Adjust.runAttributionChangedDelegate (sAttributionData);
167+
Adjust.runAttributionChangedString (sAttributionData);
164168
}
165-
166-
public static void runAttributionChangedDelegate (string stringAttributionData)
169+
170+
public static void runAttributionChangedString (string stringAttributionData)
167171
{
168172
if (instance == null) {
169173
Debug.Log (Adjust.errorMessage);
@@ -179,6 +183,21 @@ public static void runAttributionChangedDelegate (string stringAttributionData)
179183
Adjust.attributionChangedDelegate (attribution);
180184
}
181185

186+
public static void runAttributionChangedDictionary (Dictionary<string, string> dicAttributionData)
187+
{
188+
if (instance == null) {
189+
Debug.Log (Adjust.errorMessage);
190+
return;
191+
}
192+
if (Adjust.attributionChangedDelegate == null) {
193+
Debug.Log ("adjust: Attribution changed delegate was not set.");
194+
return;
195+
}
196+
197+
var attribution = new AdjustAttribution (dicAttributionData);
198+
Adjust.attributionChangedDelegate (attribution);
199+
}
200+
182201
#endregion
183202

184203
#region Private & helper methods

Assets/Adjust/Metro/AdjustMetro.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#if UNITY_METRO
2+
using UnityEngine;
3+
using System.Collections;
4+
using AdjustUnityWS;
5+
using System;
6+
using System.Collections.Generic;
7+
8+
namespace com.adjust.sdk
9+
{
10+
public class AdjustMetro : IAdjust
11+
{
12+
private const string sdkPrefix = "unity4.0.2";
13+
14+
public bool isEnabled()
15+
{
16+
return AdjustWS.IsEnabled();
17+
}
18+
public void onPause ()
19+
{
20+
AdjustWS.ApplicationDeactivated ();
21+
}
22+
public void onResume()
23+
{
24+
AdjustWS.ApplicationActivated ();
25+
}
26+
public void setEnabled(bool enabled)
27+
{
28+
AdjustWS.SetEnabled (enabled);
29+
}
30+
public void setOfflineMode(bool offlineMode)
31+
{
32+
AdjustWS.SetOfflineMode (offlineMode);
33+
}
34+
public void start(AdjustConfig adjustConfig)
35+
{
36+
string logLevelString = null;
37+
if (adjustConfig.logLevel != null)
38+
{
39+
logLevelString = adjustConfig.logLevel.ToString();
40+
}
41+
42+
Action<Dictionary<string, string>> attributionChangedDictionary = null;
43+
if (adjustConfig.attributionChangedDelegate != null)
44+
{
45+
attributionChangedDictionary = (attributionDictionary) => Adjust.runAttributionChangedDictionary(attributionDictionary);
46+
}
47+
48+
AdjustWS.ApplicationLaunching (
49+
appToken: adjustConfig.appToken,
50+
logLevelString: logLevelString,
51+
environment: adjustConfig.environment.ToString ().ToLower (),
52+
defaultTracker: adjustConfig.defaultTracker,
53+
eventBufferingEnabled: adjustConfig.eventBufferingEnabled,
54+
sdkPrefix: sdkPrefix,
55+
attributionChangedDic: attributionChangedDictionary
56+
);
57+
}
58+
public void trackEvent (AdjustEvent adjustEvent)
59+
{
60+
AdjustWS.TrackEvent (
61+
eventToken: adjustEvent.eventToken,
62+
revenue: adjustEvent.revenue,
63+
currency: adjustEvent.currency,
64+
callbackList: adjustEvent.callbackList,
65+
partnerList: adjustEvent.partnerList
66+
);
67+
}
68+
// iOS specific methods
69+
public void setDeviceToken (string deviceToken) {}
70+
// Android specific methods
71+
public void setReferrer (string referrer) {}
72+
}
73+
}
74+
#endif

Assets/Adjust/Metro/AdjustMetro.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Assets/Adjust/Unity/AdjustAttribution.cs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,34 @@ public AdjustAttribution (string jsonString)
4141
clickLabel = getJsonString (jsonNode, "clickLabel");
4242
}
4343

44+
45+
public AdjustAttribution (Dictionary<string, string> dicAttributionData)
46+
{
47+
if (dicAttributionData == null) {
48+
return;
49+
}
50+
51+
trackerName = TryGetValue (dicAttributionData, "trackerName");
52+
trackerToken = TryGetValue (dicAttributionData, "trackerToken");
53+
network = TryGetValue (dicAttributionData, "network");
54+
campaign = TryGetValue (dicAttributionData, "campaign");
55+
adgroup = TryGetValue (dicAttributionData, "adgroup");
56+
creative = TryGetValue (dicAttributionData, "creative");
57+
}
58+
59+
private static string TryGetValue(Dictionary<string, string> dic, string key)
60+
{
61+
string value;
62+
if (dic.TryGetValue(key, out value))
63+
{
64+
return value;
65+
}
66+
else
67+
{
68+
return null;
69+
}
70+
}
71+
4472
private String getJsonString (JSONNode node, string key)
4573
{
4674
var jsonValue = getJsonValue (node, key);

Assets/Adjust/WP8/AdjustWP8.cs

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#if UNITY_WP8
2+
using UnityEngine;
3+
using System.Collections;
4+
using AdjustUnityWP;
5+
using System;
6+
using System.Collections.Generic;
7+
8+
namespace com.adjust.sdk
9+
{
10+
public class AdjustWP8 : IAdjust
11+
{
12+
private const string sdkPrefix = "unity4.0.4";
13+
14+
public bool isEnabled()
15+
{
16+
return AdjustWP.IsEnabled();
17+
}
18+
public void onPause ()
19+
{
20+
AdjustWP.ApplicationDeactivated ();
21+
}
22+
public void onResume()
23+
{
24+
AdjustWP.ApplicationActivated ();
25+
}
26+
public void setEnabled(bool enabled)
27+
{
28+
AdjustWP.SetEnabled (enabled);
29+
}
30+
public void setOfflineMode(bool offlineMode)
31+
{
32+
AdjustWP.SetOfflineMode (offlineMode);
33+
}
34+
public void start(AdjustConfig adjustConfig)
35+
{
36+
string logLevelString = null;
37+
if (adjustConfig.logLevel != null)
38+
{
39+
logLevelString = adjustConfig.logLevel.ToString();
40+
}
41+
42+
Action<Dictionary<string, string>> attributionChangedDictionary = null;
43+
if (adjustConfig.attributionChangedDelegate != null)
44+
{
45+
attributionChangedDictionary = (attributionDictionary) => Adjust.runAttributionChangedDictionary(attributionDictionary);
46+
}
47+
48+
AdjustWP.ApplicationLaunching (
49+
appToken: adjustConfig.appToken,
50+
logLevelString: logLevelString,
51+
environment: adjustConfig.environment.ToString ().ToLower (),
52+
defaultTracker: adjustConfig.defaultTracker,
53+
eventBufferingEnabled: adjustConfig.eventBufferingEnabled,
54+
sdkPrefix: sdkPrefix,
55+
attributionChangedDic: attributionChangedDictionary
56+
);
57+
}
58+
public void trackEvent (AdjustEvent adjustEvent)
59+
{
60+
AdjustWP.TrackEvent (
61+
eventToken: adjustEvent.eventToken,
62+
revenue: adjustEvent.revenue,
63+
currency: adjustEvent.currency,
64+
callbackList: adjustEvent.callbackList,
65+
partnerList: adjustEvent.partnerList
66+
);
67+
}
68+
// iOS specific methods
69+
public void setDeviceToken(string deviceToken) { }
70+
// Android specific methods
71+
public void setReferrer(string referrer) { }
72+
}
73+
}
74+
#endif

Assets/Adjust/WP8/AdjustWP8.cs.meta

Lines changed: 8 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)