Skip to content

Commit 5c5beb9

Browse files
committed
Merge pull request #1 from adeven/newSDKs20131205
New sdks20131205
2 parents f9b76b7 + 3a41556 commit 5c5beb9

22 files changed

+448
-299
lines changed
-85.2 KB
Binary file not shown.
88.2 KB
Binary file not shown.

README.md

Lines changed: 164 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -3,56 +3,171 @@
33
This is the [Unity](http://unity3d.com/) SDK of AdjustIo. You can read more about AdjustIo at
44
[adjust.io](http://adjust.io).
55

6-
Use of the Plugin
7-
-----------------------------
8-
1. Import all files into your project.
9-
2. Read this file completely.
10-
3. Add the prefab Assets/AdjustIo/AdjustIo.prefab to the first scene of the app (only to the first scene!).
11-
4. Change the app token on the AdjustIo object in your hierachy. You can find your app token on the AdjustIo dashboard.
12-
5. Change the log level, environment and buffering settings to the desired settings. For more info on these settings, go to https://github.com/adeven/adjust_android_sdk/ or https://github.com/adeven/adjust_ios_sdk/ .
13-
6. If you already have an AndroidManifest.xml file in your project, please adapt the manifest according to instructions found on https://github.com/adeven/adjust_android_sdk/ .
14-
7. Add the desired tracking functions to your code.
15-
- Warning: AdjustIo is started in the Awake event. This means that all functions below may not work when called in the Awake event of the first scene.
16-
- Below you can find a list of all availabe functions (these are all static functions in the AdjustIo class):
17-
- AdjustIo.TrackEvent(string eventToken);
18-
- AdjustIo.TrackEvent(string eventToken, Dictionary<string,string> parameters);
19-
- AdjustIo.TrackRevenue(double cents);
20-
- AdjustIo.TrackRevenue(double cents, string eventToken);
21-
- AdjustIo.TrackRevenue(double cents, string eventToken, Dictionary<string,string> parameters);
22-
23-
Use of Example Scene
24-
--------------------------------
25-
1. Open the scene Assets/AdjustIo/Example/ExampleScene.
26-
2. You will see the AdjustIo object in the Hiearchy tab. Change the app token parameter of this object to your app token. You can find your app token on the AdjustIo dashboard.
27-
3. In the Hierarchy tab you will also find the ExampleUI object. Change the event token parameter of this object to an event token of an event you have created for this app. This information can be found on the AdjustIo dashboard. The example will use this event token when tracking events or when tracking revenue.
28-
4. You can now run the example in the editor. You should see some buttons which will send events. While running in the Unity Editor the events will not be sent to the AdjustIo server (see below for more information).
29-
5. Build the example scene to an Android or iOS device so you can test if you receive any events on the dashboard. Be sure read the build instructions below first.
30-
31-
Notes on Running the App in the Unity Editor
32-
--------------------------------------------------------
33-
The AdjustIo will not throw any errors when testing the app in the Editor. However most of the
34-
code will not be called while testing in the Editor. This means that the AdjustIo server will
35-
not receive any messages while testing in the Unity Editor.
36-
37-
38-
Android Build Instructions
39-
--------------------------------------
40-
1. Open the scene containing the AdjustIo object.
41-
2. Check the app token, log level, environment and buffering settings.
42-
3. Go to the menu and select AdjustIo > Check AndroidManifest.xml This will update the AndroidManifest to use the app token, log level, environment and buffering settings chosen on the AdjustIo object.
43-
4. You are now ready to build using the 'Build' or 'Build And Run' options from the 'Build Settings' menu.
44-
45-
iOS Build Instructions
46-
--------------------------------------
47-
1. Open the scene containing the AdjustIo object.
48-
2. Check the app token, log level, environment and buffering settings.
49-
3. You are now ready to build using the Build or Build And Run from the Build Settings menu.
50-
- Warning: when you use File > Build and Run, the plugin may not be included correctly.
51-
4. When you notice that the plugin is not added to the Xcode project, be sure to check the file permissions on the file Assets/AdjustIo/Data/PostBuildScripts/PostBuildAdjustIoScript. You should have the execute permission on this file.
52-
53-
License notes
54-
-------------
6+
## Basic Installation
7+
8+
### 1. Get the SDK
9+
10+
Download the latest version from our [releases page][releases]. Extract the
11+
archive in a folder of your choice.
12+
13+
### 2. Add it to your project
14+
15+
Open your project in the Unity Editor and navigate to Assets, Import Package. Click on Custom Package and locate the AdjustIoPlugin_..._.unityPackage file. Don't download the AndroidManifest.xml file if you already have it in your project.
16+
17+
![][import]
18+
19+
### 3. Integrate AdjustIo into your app
20+
21+
1. Add the prefab Assets/AdjustIo/AdjustIo.prefab to the first scene of the app (only to the first scene!).
22+
23+
2. Change the app token on the AdjustIo object in your hierachy. You can find your app token on your [dashboard].
24+
25+
3. Change the log level, environment and buffering settings to the desired settings. For more info on these settings, go to https://github.com/adeven/adjust_android_sdk/ or https://github.com/adeven/adjust_ios_sdk/ . On Android the log level is defined in AndroidManifest.xml file.
26+
27+
![][settings]
28+
29+
### 4. Adjust Android manifest
30+
31+
Ignore this step if you imported the AndroidManifest.xml file from this package.
32+
33+
1. Add or uncomment the ```<uses-permission>``` tags for ```INTERNET``` and ```ACCESS_WIFI_STATE``` if they aren't present already:
34+
35+
![][permissions]
36+
37+
2. Add broadcast receiver:
38+
39+
![][receiver]
40+
41+
3. Add AdjustIo settings
42+
43+
Still in the `AndroidManifest.xml`, add the following `meta-data` tags inside
44+
the `application` tag.
45+
46+
```xml
47+
<meta-data android:name="AdjustIoLogLevel" android:value="info" />
48+
```
49+
50+
![][metadata]
51+
52+
You can increase or decrease the amount of logs you see by changing the value
53+
of `AdjustIoLogLevel` to one of the following:
54+
55+
- `verbose` - enable all logging
56+
- `debug` - enable more logging
57+
- `info` - the default
58+
- `warn` - disable info logging
59+
- `error` - disable warnings as well
60+
- `assert` - disable errors as well
61+
62+
## Additional features
63+
64+
Once you integrated the AdjustIo SDK into your project, you can take advantage
65+
of the following features.
66+
67+
### Add tracking of custom events.
68+
69+
You can tell AdjustIo about every event you want. Suppose you want to track
70+
every tap on a button. You would have to create a new Event Token in your
71+
[dashboard]. Let's say that Event Token is `abc123`. In your button's
72+
click handler method you could then add the following line to track the click:
73+
74+
```actionscript
75+
AdjustIo.TrackEvent("abc123");
76+
```
77+
78+
You can also register a callback URL for that event in your [dashboard] and we
79+
will send a GET request to that URL whenever the event gets tracked. In that
80+
case you can also put some key-value-pairs in an object and pass it to the
81+
`trackEvent` method. We will then append these named parameters to your
82+
callback URL.
83+
84+
For example, suppose you have registered the URL
85+
`http://www.adeven.com/callback` for your event with Event Token `abc123` and
86+
execute the following lines:
87+
88+
<pre><code>
89+
Dictionary<string,string> parameters = new Dictionary<string, string>();
90+
parameters.Add("key","value");
91+
parameters.Add("foo","bar");
92+
93+
AdjustIo.TrackEvent("abc123", parameters);
94+
</code></pre>
95+
96+
In that case we would track the event and send a request to:
97+
98+
http://www.adeven.com/callback?key=value&foo=bar
99+
100+
It should be mentioned that we support a variety of placeholders like `{idfa}`
101+
that can be used as parameter values. In the resulting callback this
102+
placeholder would be replaced with the ID for Advertisers of the current
103+
device. Also note that we don't store any of your custom parameters, but only
104+
append them to your callbacks. If you haven't registered a callback for an
105+
event, these parameters won't even be read.
106+
107+
### Add tracking of revenue
108+
109+
If your users can generate revenue by clicking on advertisements or making
110+
in-app purchases you can track those revenues. If, for example, a click is
111+
worth one cent, you could make the following call to track that revenue:
112+
113+
```actionscript
114+
AdjustIo.TrackRevenue(1.0);
115+
```
116+
117+
The parameter is supposed to be in cents and will get rounded to one decimal
118+
point. If you want to differentiate between different kinds of revenue you can
119+
get different Event Tokens for each kind. Again, you need to create those Event
120+
Tokens in your [dashboard]. In that case you would make a call like this:
121+
122+
```actionscript
123+
AdjustIo.TrackRevenue(1.0, "abc123");
124+
```
125+
126+
Again, you can register a callback and provide a dictionary of named
127+
parameters, just like it worked with normal events.
128+
129+
<pre><code>
130+
Dictionary<string,string> parameters = new Dictionary<string, string>();
131+
parameters.Add("key","value");
132+
parameters.Add("foo","bar");
133+
134+
AdjustIo.TrackRevenue(1.0, "abc123", parameters);
135+
</code></pre>
136+
137+
[import]: https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/UnityImport.png
138+
[settings]: https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/AdjustIoSettings.png
139+
[adjust.io]: http://adjust.io
140+
[dashboard]: http://adjust.io
141+
[releases]: https://github.com/adeven/adjust_unity_sdk/releases
142+
[permissions]: https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/UnityPermissions.png
143+
[receiver]: https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/UnityReceiver.png
144+
[metadata] : https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/UnityMetaData.png
145+
146+
## License
55147

56148
The file mod_pbxproj.py is licensed under the Apache License, Version 2.0 (the "License");
57149
you may not use this file except in compliance with the License.
58150
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
151+
152+
The adjust-sdk is licensed under the MIT License.
153+
154+
Copyright (c) 2012-2013 adeven GmbH,
155+
http://www.adeven.com
156+
157+
Permission is hereby granted, free of charge, to any person obtaining a copy of
158+
this software and associated documentation files (the "Software"), to deal in
159+
the Software without restriction, including without limitation the rights to
160+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
161+
of the Software, and to permit persons to whom the Software is furnished to do
162+
so, subject to the following conditions:
163+
164+
The above copyright notice and this permission notice shall be included in all
165+
copies or substantial portions of the Software.
166+
167+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
168+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
169+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
170+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
171+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
172+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
173+
SOFTWARE.

src/Assets/AdjustIo/Data/SDK/iOS/AdjustIo/AIActivityHandler.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515

1616
+ (AIActivityHandler *)handlerWithAppToken:(NSString *)appToken;
1717
- (id)initWithAppToken:(NSString *)appToken;
18+
- (void)setSdkPrefix:(NSString *)sdkPrefix;
1819

1920
- (void)trackSubsessionStart;
2021
- (void)trackSubsessionEnd;

src/Assets/AdjustIo/Data/SDK/iOS/AdjustIo/AIActivityHandler.m

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ - (id)initWithAppToken:(NSString *)yourAppToken {
6060
[self addNotificationObserver];
6161
self.internalQueue = dispatch_queue_create(kInternalQueueName, DISPATCH_QUEUE_SERIAL);
6262
self.environment = @"unknown"; // default value
63+
self.clientSdk = AIUtil.clientSdk;
6364

6465
dispatch_async(self.internalQueue, ^{
6566
[self initInternal:yourAppToken];
@@ -68,6 +69,10 @@ - (id)initWithAppToken:(NSString *)yourAppToken {
6869
return self;
6970
}
7071

72+
- (void)setSdkPrefix:(NSString *)sdkPrefix {
73+
self.clientSdk = [NSString stringWithFormat:@"%@@%@", sdkPrefix, self.clientSdk];
74+
}
75+
7176
- (void)trackSubsessionStart {
7277
dispatch_async(self.internalQueue, ^{
7378
[self startInternal];
@@ -112,7 +117,6 @@ - (void)initInternal:(NSString *)yourAppToken {
112117
self.idForAdvertisers = UIDevice.currentDevice.aiIdForAdvertisers;
113118
self.fbAttributionId = UIDevice.currentDevice.aiFbAttributionId;
114119
self.userAgent = AIUtil.userAgent;
115-
self.clientSdk = AIUtil.clientSdk;
116120

117121
self.packageHandler = [[AIPackageHandler alloc] init];
118122
[self readActivityState];
@@ -299,6 +303,7 @@ - (void)writeActivityState {
299303
NSString *filename = [self activityStateFilename];
300304
BOOL result = [NSKeyedArchiver archiveRootObject:self.activityState toFile:filename];
301305
if (result == YES) {
306+
[AIUtil excludeFromBackup:filename];
302307
[AILogger verbose:@"Wrote activity state: %@", self.activityState];
303308
} else {
304309
[AILogger error:@"Failed to write activity state"];

src/Assets/AdjustIo/Data/SDK/iOS/AdjustIo/AIAdditions/NSMutableDictionary+AIAdditions.h

Lines changed: 0 additions & 17 deletions
This file was deleted.

src/Assets/AdjustIo/Data/SDK/iOS/AdjustIo/AIAdditions/NSMutableDictionary+AIAdditions.h.meta

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/Assets/AdjustIo/Data/SDK/iOS/AdjustIo/AIAdditions/NSMutableDictionary+AIAdditions.m

Lines changed: 0 additions & 29 deletions
This file was deleted.

src/Assets/AdjustIo/Data/SDK/iOS/AdjustIo/AIAdditions/NSMutableDictionary+AIAdditions.m.meta

Lines changed: 0 additions & 2 deletions
This file was deleted.

src/Assets/AdjustIo/Data/SDK/iOS/AdjustIo/AIAdditions/NSString+AIAdditions.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,5 @@
1515
- (NSString *)aiSha1;
1616
- (NSString *)aiUrlEncode;
1717
- (NSString *)aiRemoveColons;
18-
- (NSData *)aiDecodeBase64;
1918

2019
@end

0 commit comments

Comments
 (0)