|
1 | 1 | using System;
|
| 2 | +using System.Text; |
2 | 3 | using System.Collections;
|
3 | 4 | using System.Runtime.InteropServices;
|
4 | 5 |
|
5 | 6 | using UnityEngine;
|
| 7 | +using UnityEngine.UI; |
| 8 | + |
6 | 9 | using com.adjust.sdk;
|
7 | 10 |
|
8 |
| -public class ExampleGUI : MonoBehaviour |
9 |
| -{ |
| 11 | +public class ExampleGUI : MonoBehaviour { |
| 12 | + |
10 | 13 | private int nr_buttons = 8;
|
11 | 14 |
|
12 | 15 | private static bool isEnabled;
|
13 | 16 | private bool showPopUp = false;
|
14 | 17 |
|
15 |
| - private string txtSetEnabled = "Disable SDK"; |
16 | 18 | private string txtManualLaunch = "Manual Launch";
|
17 | 19 | private string txtSetOfflineMode = "Turn Offline Mode ON";
|
| 20 | + private string txtSetEnabled = "Disable SDK"; |
18 | 21 |
|
19 | 22 | void OnGUI ()
|
20 | 23 | {
|
21 |
| - if (showPopUp) |
22 |
| - { |
23 |
| - GUI.Window(0, new Rect ((Screen.width / 2) - 150, (Screen.height / 2) - 65, 300, 130), showGUI, "Is SDK enabled?"); |
| 24 | + if (showPopUp) { |
| 25 | + GUI.Window(0, new Rect((Screen.width / 2) - 150, (Screen.height / 2) - 65, 300, 130), showGUI, "Is SDK enabled?"); |
24 | 26 | }
|
25 | 27 |
|
26 |
| - if (GUI.Button (new Rect (0, Screen.height * 0 / nr_buttons, Screen.width, Screen.height / nr_buttons), txtManualLaunch)) |
27 |
| - { |
28 |
| - if (!string.Equals (txtManualLaunch, "SDK Launched", StringComparison.OrdinalIgnoreCase)) |
29 |
| - { |
| 28 | + if (GUI.Button (new Rect (0, Screen.height * 0 / nr_buttons, Screen.width, Screen.height / nr_buttons), txtManualLaunch)) { |
| 29 | + if (!string.Equals(txtManualLaunch, "SDK Launched", StringComparison.OrdinalIgnoreCase)) { |
30 | 30 | AdjustConfig adjustConfig = new AdjustConfig ("{YourAppToken}", AdjustEnvironment.Sandbox);
|
31 | 31 | adjustConfig.setLogLevel (AdjustLogLevel.Verbose);
|
| 32 | + adjustConfig.setLogDelegate (msg => Debug.Log (msg)); |
| 33 | + adjustConfig.setSendInBackground (true); |
| 34 | + adjustConfig.setLaunchDeferredDeeplink (true); |
| 35 | + |
32 | 36 | adjustConfig.setEventSuccessDelegate (EventSuccessCallback);
|
33 |
| - adjustConfig.setEventFailureDelegate (EventFailureCallback); |
34 |
| - adjustConfig.setSessionSuccessDelegate (SessionSuccessCallback); |
35 |
| - adjustConfig.setSessionFailureDelegate (SessionFailureCallback); |
36 |
| - adjustConfig.setAttributionChangedDelegate (AttributionChangedCallback); |
37 |
| - |
| 37 | + adjustConfig.setEventFailureDelegate (EventFailureCallback); |
| 38 | + adjustConfig.setSessionSuccessDelegate (SessionSuccessCallback); |
| 39 | + adjustConfig.setSessionFailureDelegate (SessionFailureCallback); |
| 40 | + adjustConfig.setDeferredDeeplinkDelegate (DeferredDeeplinkCallback); |
| 41 | + adjustConfig.setAttributionChangedDelegate (AttributionChangedCallback); |
| 42 | + |
38 | 43 | Adjust.start (adjustConfig);
|
39 | 44 | isEnabled = true;
|
40 | 45 |
|
41 | 46 | txtManualLaunch = "SDK Launched";
|
42 | 47 | }
|
43 | 48 | }
|
44 | 49 |
|
45 |
| - if (GUI.Button (new Rect (0, Screen.height * 1 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Track Simple Event")) |
46 |
| - { |
| 50 | + if (GUI.Button (new Rect (0, Screen.height * 1 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Track Simple Event")) { |
47 | 51 | AdjustEvent adjustEvent = new AdjustEvent ("{YourEventToken}");
|
48 | 52 | Adjust.trackEvent (adjustEvent);
|
49 | 53 | }
|
50 | 54 |
|
51 |
| - if (GUI.Button (new Rect (0, Screen.height * 2 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Track Revenue Event")) |
52 |
| - { |
| 55 | + if (GUI.Button (new Rect (0, Screen.height * 2 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Track Revenue Event")) { |
53 | 56 | AdjustEvent adjustEvent = new AdjustEvent ("{YourEventToken}");
|
54 | 57 | adjustEvent.setRevenue (0.25, "EUR");
|
55 |
| - |
| 58 | + |
56 | 59 | Adjust.trackEvent (adjustEvent);
|
57 | 60 | }
|
58 | 61 |
|
59 |
| - if (GUI.Button (new Rect (0, Screen.height * 3 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Track Callback Event")) |
60 |
| - { |
| 62 | + if (GUI.Button (new Rect (0, Screen.height * 3 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Track Callback Event")) { |
61 | 63 | AdjustEvent adjustEvent = new AdjustEvent ("{YourEventToken}");
|
62 |
| - |
| 64 | + |
63 | 65 | adjustEvent.addCallbackParameter ("key", "value");
|
64 | 66 | adjustEvent.addCallbackParameter ("foo", "bar");
|
65 |
| - |
| 67 | + |
66 | 68 | Adjust.trackEvent (adjustEvent);
|
67 | 69 | }
|
68 | 70 |
|
69 |
| - if (GUI.Button (new Rect (0, Screen.height * 4 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Track Partner Event")) |
70 |
| - { |
| 71 | + if (GUI.Button (new Rect (0, Screen.height * 4 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Track Partner Event")) { |
71 | 72 | AdjustEvent adjustEvent = new AdjustEvent ("{YourEventToken}");
|
72 |
| - |
| 73 | + |
73 | 74 | adjustEvent.addPartnerParameter ("key", "value");
|
74 | 75 | adjustEvent.addPartnerParameter ("foo", "bar");
|
75 |
| - |
| 76 | + |
76 | 77 | Adjust.trackEvent (adjustEvent);
|
77 | 78 | }
|
78 | 79 |
|
79 |
| - if (GUI.Button (new Rect (0, Screen.height * 5 / nr_buttons, Screen.width, Screen.height / nr_buttons), txtSetOfflineMode)) |
80 |
| - { |
81 |
| - if (string.Equals (txtSetOfflineMode, "Turn Offline Mode ON", StringComparison.OrdinalIgnoreCase)) |
82 |
| - { |
83 |
| - Adjust.setOfflineMode (true); |
| 80 | + if (GUI.Button (new Rect (0, Screen.height * 5 / nr_buttons, Screen.width, Screen.height / nr_buttons), txtSetOfflineMode)) { |
| 81 | + if (string.Equals(txtSetOfflineMode, "Turn Offline Mode ON", StringComparison.OrdinalIgnoreCase)) { |
| 82 | + Adjust.setOfflineMode(true); |
| 83 | + |
84 | 84 | txtSetOfflineMode = "Turn Offline Mode OFF";
|
85 |
| - } |
86 |
| - else |
87 |
| - { |
88 |
| - Adjust.setOfflineMode (false); |
| 85 | + } else { |
| 86 | + Adjust.setOfflineMode(false); |
| 87 | + |
89 | 88 | txtSetOfflineMode = "Turn Offline Mode ON";
|
90 | 89 | }
|
91 | 90 | }
|
92 | 91 |
|
93 |
| - if (GUI.Button (new Rect (0, Screen.height * 6 / nr_buttons, Screen.width, Screen.height / nr_buttons), txtSetEnabled)) |
94 |
| - { |
95 |
| - if (string.Equals (txtSetEnabled, "Disable SDK", StringComparison.OrdinalIgnoreCase)) |
96 |
| - { |
97 |
| - Adjust.setEnabled (false); |
| 92 | + if (GUI.Button (new Rect (0, Screen.height * 6 / nr_buttons, Screen.width, Screen.height / nr_buttons), txtSetEnabled)) { |
| 93 | + if (string.Equals(txtSetEnabled, "Disable SDK", StringComparison.OrdinalIgnoreCase)) { |
| 94 | + Adjust.setEnabled(false); |
| 95 | + |
98 | 96 | txtSetEnabled = "Enable SDK";
|
99 |
| - } |
100 |
| - else |
101 |
| - { |
102 |
| - Adjust.setEnabled (true); |
| 97 | + } else { |
| 98 | + Adjust.setEnabled(true); |
| 99 | + |
103 | 100 | txtSetEnabled = "Disable SDK";
|
104 | 101 | }
|
105 | 102 | }
|
106 | 103 |
|
107 |
| - if (GUI.Button (new Rect (0, Screen.height * 7 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Is SDK Enabled?")) |
108 |
| - { |
109 |
| - isEnabled = Adjust.isEnabled (); |
| 104 | + if (GUI.Button (new Rect (0, Screen.height * 7 / nr_buttons, Screen.width, Screen.height / nr_buttons), "Is SDK Enabled?")) { |
| 105 | + isEnabled = Adjust.isEnabled(); |
| 106 | + |
110 | 107 | showPopUp = true;
|
111 | 108 | }
|
112 | 109 | }
|
113 | 110 |
|
114 |
| - void showGUI (int windowID) |
| 111 | + void showGUI(int windowID) |
115 | 112 | {
|
116 |
| - if (isEnabled) |
117 |
| - { |
118 |
| - GUI.Label (new Rect (65, 40, 200, 30), "Adjust SDK is ENABLED!"); |
119 |
| - } |
120 |
| - else |
121 |
| - { |
122 |
| - GUI.Label (new Rect (65, 40, 200, 30), "Adjust SDK is DISABLED!"); |
| 113 | + |
| 114 | + if (isEnabled) { |
| 115 | + GUI.Label(new Rect(65, 40, 200, 30), "Adjust SDK is ENABLED!"); |
| 116 | + } else { |
| 117 | + GUI.Label(new Rect(65, 40, 200, 30), "Adjust SDK is DISABLED!"); |
123 | 118 | }
|
124 | 119 |
|
125 |
| - if (GUI.Button (new Rect (90, 75, 120, 40), "OK")) |
126 |
| - { |
| 120 | + if (GUI.Button(new Rect(90, 75, 120, 40), "OK")) { |
127 | 121 | showPopUp = false;
|
128 | 122 | }
|
129 | 123 | }
|
| 124 | + |
| 125 | + public void handleGooglePlayId (String adId) |
| 126 | + { |
| 127 | + Debug.Log ("Google Play Ad ID = " + adId); |
| 128 | + } |
130 | 129 |
|
131 | 130 | public void AttributionChangedCallback (AdjustAttribution attributionData)
|
132 | 131 | {
|
@@ -281,4 +280,18 @@ public void SessionFailureCallback (AdjustSessionFailure sessionFailureData)
|
281 | 280 | Debug.Log ("JsonResponse: " + sessionFailureData.GetJsonResponse ());
|
282 | 281 | }
|
283 | 282 | }
|
| 283 | + |
| 284 | + private void DeferredDeeplinkCallback (string deeplinkURL) |
| 285 | + { |
| 286 | + Debug.Log ("Deferred deeplink reported!"); |
| 287 | + |
| 288 | + if (deeplinkURL != null) |
| 289 | + { |
| 290 | + Debug.Log ("Deeplink URL: " + deeplinkURL); |
| 291 | + } |
| 292 | + else |
| 293 | + { |
| 294 | + Debug.Log ("Deeplink URL is null!"); |
| 295 | + } |
| 296 | + } |
284 | 297 | }
|
0 commit comments