Skip to content

Commit 6c4e020

Browse files
author
Uglješa Erceg
committed
Merge pull request #48 from adjust/receipt_validation
Receipt validation
2 parents 893c653 + d659caa commit 6c4e020

24 files changed

+259
-60
lines changed

Assets/Adjust/Adjust.cs

Lines changed: 43 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,29 +25,31 @@ public class Adjust : MonoBehaviour
2525

2626
void Awake ()
2727
{
28+
DontDestroyOnLoad (transform.gameObject);
29+
2830
if (!this.startManually) {
2931
AdjustConfig adjustConfig = new AdjustConfig (this.appToken, this.environment);
3032
adjustConfig.setLogLevel (this.logLevel);
3133
adjustConfig.setEventBufferingEnabled (eventBuffering);
3234

3335
if (printAttribution) {
34-
adjustConfig.setAttributionChangedDelegate(responseDelegate);
36+
adjustConfig.setAttributionChangedDelegate (responseDelegate);
3537
}
3638

3739
Adjust.start (adjustConfig);
3840
}
3941
}
4042

41-
void OnApplicationPause(bool pauseStatus)
43+
void OnApplicationPause (bool pauseStatus)
4244
{
4345
if (Adjust.instance == null) {
4446
return;
4547
}
4648

4749
if (pauseStatus) {
48-
Adjust.instance.onPause();
50+
Adjust.instance.onPause ();
4951
} else {
50-
Adjust.instance.onResume();
52+
Adjust.instance.onResume ();
5153
}
5254
}
5355

@@ -70,9 +72,9 @@ public static void start (AdjustConfig adjustConfig)
7072
#if UNITY_EDITOR
7173
Adjust.instance = null;
7274
#elif UNITY_IOS
73-
Adjust.instance = new AdjustiOS();
75+
Adjust.instance = new AdjustiOS ();
7476
#elif UNITY_ANDROID
75-
Adjust.instance = new AdjustAndroid();
77+
Adjust.instance = new AdjustAndroid ();
7678
#else
7779
Adjust.instance = null;
7880
#endif
@@ -102,34 +104,54 @@ public static void trackEvent (AdjustEvent adjustEvent)
102104
Adjust.instance.trackEvent (adjustEvent);
103105
}
104106

105-
public static void setEnabled(bool enabled)
107+
public static void setEnabled (bool enabled)
106108
{
107109
if (Adjust.instance == null) {
108-
Debug.Log(Adjust.errorMessage);
110+
Debug.Log (Adjust.errorMessage);
109111
return;
110112
}
111113

112-
Adjust.instance.setEnabled(enabled);
114+
Adjust.instance.setEnabled (enabled);
113115
}
114116

115-
public static bool isEnabled()
117+
public static bool isEnabled ()
116118
{
117119
if (Adjust.instance == null) {
118-
Debug.Log(Adjust.errorMessage);
120+
Debug.Log (Adjust.errorMessage);
119121
return false;
120122
}
121123

122-
return Adjust.instance.isEnabled();
124+
return Adjust.instance.isEnabled ();
123125
}
124126

125-
public static void setOfflineMode(bool enabled)
127+
public static void setOfflineMode (bool enabled)
128+
{
129+
if (Adjust.instance == null) {
130+
Debug.Log (Adjust.errorMessage);
131+
return;
132+
}
133+
134+
Adjust.instance.setOfflineMode (enabled);
135+
}
136+
137+
public static void setDeviceToken (string deviceToken)
126138
{
127139
if (Adjust.instance == null) {
128-
Debug.Log(Adjust.errorMessage);
140+
Debug.Log (Adjust.errorMessage);
129141
return;
130142
}
131143

132-
Adjust.instance.setOfflineMode(enabled);
144+
Adjust.instance.setDeviceToken (deviceToken);
145+
}
146+
147+
public static void setReferrer (string referrer)
148+
{
149+
if (Adjust.instance == null) {
150+
Debug.Log (Adjust.errorMessage);
151+
return;
152+
}
153+
154+
Adjust.instance.setReferrer (referrer);
133155
}
134156

135157
#endregion
@@ -147,6 +169,7 @@ public static void runAttributionChangedDelegate (string stringAttributionData)
147169
Debug.Log (Adjust.errorMessage);
148170
return;
149171
}
172+
150173
if (Adjust.attributionChangedDelegate == null) {
151174
Debug.Log ("adjust: Attribution changed delegate was not set.");
152175
return;
@@ -161,7 +184,7 @@ public static void runAttributionChangedDelegate (string stringAttributionData)
161184
#region Private & helper methods
162185

163186
// Our delegate for detecting attribution changes if choosen not to start manually.
164-
private void responseDelegate(AdjustAttribution responseData)
187+
private void responseDelegate (AdjustAttribution responseData)
165188
{
166189
Debug.Log ("Attribution changed!");
167190

@@ -188,6 +211,10 @@ private void responseDelegate(AdjustAttribution responseData)
188211
if (responseData.creative != null) {
189212
Debug.Log ("creative " + responseData.creative);
190213
}
214+
215+
if (responseData.clickLabel != null) {
216+
Debug.Log ("clickLabel" + responseData.clickLabel);
217+
}
191218
}
192219

193220
#endregion

Assets/Adjust/Android/AdjustAndroid.cs

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ namespace com.adjust.sdk
1010
#if UNITY_ANDROID
1111
public class AdjustAndroid : IAdjust
1212
{
13-
private const string sdkPrefix = "unity4.0.2";
13+
private const string sdkPrefix = "unity4.0.3";
1414
private AndroidJavaClass ajcAdjust;
1515
private AndroidJavaObject ajoCurrentActivity;
1616
private AttributionChangeListener onAttributionChangedListener;
@@ -34,6 +34,7 @@ public void onAttributionChanged (AndroidJavaObject attribution)
3434
adjustAttribution.campaign = attribution.Get<string> ("campaign");
3535
adjustAttribution.adgroup = attribution.Get<string> ("adgroup");
3636
adjustAttribution.creative = attribution.Get<string> ("creative");
37+
adjustAttribution.clickLabel = attribution.Get<string> ("clickLabel");
3738

3839
if (callback != null) {
3940
callback (adjustAttribution);
@@ -134,6 +135,16 @@ public void setOfflineMode (bool enabled)
134135
ajcAdjust.CallStatic ("setOfflineMode", enabled);
135136
}
136137

138+
public void setReferrer(string referrer)
139+
{
140+
ajcAdjust.CallStatic ("setReferrer", referrer);
141+
}
142+
143+
public void setDeviceToken(string deviceToken)
144+
{
145+
146+
}
147+
137148
#endregion
138149
}
139150
#endif
-1 Bytes
Binary file not shown.

Assets/Adjust/Android/adjust-android.jar.meta

Lines changed: 9 additions & 2 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: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ public class AdjustAttribution
1818

1919
public string creative { get; set; }
2020

21+
public string clickLabel { get; set; }
22+
2123
public AdjustAttribution ()
2224
{
2325
}
@@ -36,6 +38,7 @@ public AdjustAttribution (string jsonString)
3638
campaign = getJsonString (jsonNode, "campaign");
3739
adgroup = getJsonString (jsonNode, "adgroup");
3840
creative = getJsonString (jsonNode, "creative");
41+
clickLabel = getJsonString (jsonNode, "clickLabel");
3942
}
4043

4144
private String getJsonString (JSONNode node, string key)

Assets/Adjust/Unity/AdjustConfig.cs

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,20 @@ public class AdjustConfig
1515
internal AdjustEnvironment environment;
1616
internal Action<AdjustAttribution> attributionChangedDelegate;
1717

18+
// iOS specific members
19+
internal bool macMd5TrackingEnabled;
20+
21+
// Android specific members
22+
internal string processName;
23+
1824
public AdjustConfig (string appToken, AdjustEnvironment environment)
1925
{
2026
this.sceneName = "";
2127
this.appToken = appToken;
2228
this.environment = environment;
2329
this.startAutomatically = false;
30+
this.macMd5TrackingEnabled = false;
31+
this.processName = "";
2432
}
2533

2634
public void setLogLevel (AdjustLogLevel logLevel)
@@ -43,15 +51,27 @@ public void setEventBufferingEnabled (bool eventBufferingEnabled)
4351
this.eventBufferingEnabled = eventBufferingEnabled;
4452
}
4553

46-
public void setAttributionChangedDelegate(Action<AdjustAttribution> attributionChangedDelegate, string sceneName = "Adjust")
54+
public void setAttributionChangedDelegate (Action<AdjustAttribution> attributionChangedDelegate, string sceneName = "Adjust")
4755
{
4856
this.attributionChangedDelegate = attributionChangedDelegate;
4957
this.sceneName = sceneName;
5058
}
5159

52-
public Action<AdjustAttribution> getAttributionChangedDelegate()
60+
public Action<AdjustAttribution> getAttributionChangedDelegate ()
5361
{
5462
return this.attributionChangedDelegate;
5563
}
64+
65+
// iOS specific methods
66+
public void setMacMd5TrackingEnabled (bool macMd5TrackingEnabled)
67+
{
68+
this.macMd5TrackingEnabled = macMd5TrackingEnabled;
69+
}
70+
71+
// Android specific methods
72+
public void setProcessName (string processName)
73+
{
74+
this.processName = processName;
75+
}
5676
}
5777
}

Assets/Adjust/Unity/AdjustEvent.cs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,17 @@ public class AdjustEvent
1313
internal List<string> partnerList;
1414
internal List<string> callbackList;
1515

16+
// iOS specific members
17+
internal string receipt;
18+
internal string transactionId;
19+
20+
internal bool isReceiptSet;
21+
1622
public AdjustEvent(string eventToken)
1723
{
1824
this.eventToken = eventToken;
25+
26+
this.isReceiptSet = false;
1927
}
2028

2129
public void setRevenue(double amount, string currency)
@@ -43,5 +51,18 @@ public void addPartnerParameter(string key, string value)
4351
partnerList.Add(key);
4452
partnerList.Add(value);
4553
}
54+
55+
// iOS specific methods
56+
public void setTransactionId(string transactionId)
57+
{
58+
this.transactionId = transactionId;
59+
}
60+
61+
public void setReceipt(string receipt, string transactionId)
62+
{
63+
this.receipt = receipt;
64+
this.transactionId = transactionId;
65+
this.isReceiptSet = true;
66+
}
4667
}
4768
}

Assets/Adjust/Unity/IAdjust.cs

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,16 @@ public interface IAdjust
88
bool isEnabled();
99

1010
void onPause ();
11-
void onResume();
12-
void setEnabled(bool enabled);
13-
void setOfflineMode(bool enabled);
14-
void start(AdjustConfig adjustConfig);
11+
void onResume ();
12+
void setEnabled (bool enabled);
13+
void setOfflineMode (bool enabled);
14+
void start (AdjustConfig adjustConfig);
1515
void trackEvent (AdjustEvent adjustEvent);
16+
17+
// iOS specific methods
18+
void setDeviceToken (string deviceToken);
19+
20+
// Android specific methods
21+
void setReferrer (string referrer);
1622
}
1723
}

Assets/Adjust/iOS/ADJConfig.h

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
@interface ADJConfig : NSObject<NSCopying>
2929

3030
@property (nonatomic, copy, readonly) NSString *appToken;
31-
@property (nonatomic, assign) ADJLogLevel logLevel;
3231
@property (nonatomic, copy, readonly) NSString *environment;
3332
@property (nonatomic, copy) NSString *sdkPrefix;
3433
@property (nonatomic, copy) NSString *defaultTracker;
@@ -47,6 +46,23 @@
4746
+ (ADJConfig*)configWithAppToken:(NSString *)appToken environment:(NSString *)environment;
4847
- (id)initWithAppToken:(NSString *)appToken environment:(NSString *)environment;
4948

49+
/**
50+
* Change the verbosity of Adjust's logs.
51+
*
52+
* You can increase or reduce the amount of logs from Adjust by passing
53+
* one of the following parameters. Use Log.ASSERT to disable all logging.
54+
*
55+
* @param logLevel The desired minimum log level (default: info)
56+
* Must be one of the following:
57+
* - ADJLogLevelVerbose (enable all logging)
58+
* - ADJLogLevelDebug (enable more logging)
59+
* - ADJLogLevelInfo (the default)
60+
* - ADJLogLevelWarn (disable info logging)
61+
* - ADJLogLevelError (disable warnings as well)
62+
* - ADJLogLevelAssert (disable errors as well)
63+
*/
64+
@property (nonatomic, assign) ADJLogLevel logLevel;
65+
5066
/**
5167
* Enable event buffering if your app triggers a lot of events.
5268
* When enabled, events get buffered and only get tracked each

Assets/Adjust/iOS/Adjust.a

9.91 KB
Binary file not shown.

0 commit comments

Comments
 (0)