Skip to content

Commit

Permalink
Merge pull request #1 from adeven/newSDKs20131205
Browse files Browse the repository at this point in the history
New sdks20131205
  • Loading branch information
elmacnifico committed Dec 6, 2013
2 parents f9b76b7 + 3a41556 commit 5c5beb9
Show file tree
Hide file tree
Showing 22 changed files with 448 additions and 299 deletions.
Binary file removed AdjustIoPlugin_11_08_2013.unitypackage
Binary file not shown.
Binary file added AdjustIoPlugin_12_05_2013.unitypackage
Binary file not shown.
213 changes: 164 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,56 +3,171 @@
This is the [Unity](http://unity3d.com/) SDK of AdjustIo. You can read more about AdjustIo at
[adjust.io](http://adjust.io).

Use of the Plugin
-----------------------------
1. Import all files into your project.
2. Read this file completely.
3. Add the prefab Assets/AdjustIo/AdjustIo.prefab to the first scene of the app (only to the first scene!).
4. Change the app token on the AdjustIo object in your hierachy. You can find your app token on the AdjustIo dashboard.
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/ .
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/ .
7. Add the desired tracking functions to your code.
- 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.
- Below you can find a list of all availabe functions (these are all static functions in the AdjustIo class):
- AdjustIo.TrackEvent(string eventToken);
- AdjustIo.TrackEvent(string eventToken, Dictionary<string,string> parameters);
- AdjustIo.TrackRevenue(double cents);
- AdjustIo.TrackRevenue(double cents, string eventToken);
- AdjustIo.TrackRevenue(double cents, string eventToken, Dictionary<string,string> parameters);

Use of Example Scene
--------------------------------
1. Open the scene Assets/AdjustIo/Example/ExampleScene.
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.
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.
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).
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.

Notes on Running the App in the Unity Editor
--------------------------------------------------------
The AdjustIo will not throw any errors when testing the app in the Editor. However most of the
code will not be called while testing in the Editor. This means that the AdjustIo server will
not receive any messages while testing in the Unity Editor.


Android Build Instructions
--------------------------------------
1. Open the scene containing the AdjustIo object.
2. Check the app token, log level, environment and buffering settings.
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.
4. You are now ready to build using the 'Build' or 'Build And Run' options from the 'Build Settings' menu.

iOS Build Instructions
--------------------------------------
1. Open the scene containing the AdjustIo object.
2. Check the app token, log level, environment and buffering settings.
3. You are now ready to build using the Build or Build And Run from the Build Settings menu.
- Warning: when you use File > Build and Run, the plugin may not be included correctly.
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.

License notes
-------------
## Basic Installation

### 1. Get the SDK

Download the latest version from our [releases page][releases]. Extract the
archive in a folder of your choice.

### 2. Add it to your project

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.

![][import]

### 3. Integrate AdjustIo into your app

1. Add the prefab Assets/AdjustIo/AdjustIo.prefab to the first scene of the app (only to the first scene!).

2. Change the app token on the AdjustIo object in your hierachy. You can find your app token on your [dashboard].

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.

![][settings]

### 4. Adjust Android manifest

Ignore this step if you imported the AndroidManifest.xml file from this package.

1. Add or uncomment the ```<uses-permission>``` tags for ```INTERNET``` and ```ACCESS_WIFI_STATE``` if they aren't present already:

![][permissions]

2. Add broadcast receiver:

![][receiver]

3. Add AdjustIo settings

Still in the `AndroidManifest.xml`, add the following `meta-data` tags inside
the `application` tag.

```xml
<meta-data android:name="AdjustIoLogLevel" android:value="info" />
```

![][metadata]

You can increase or decrease the amount of logs you see by changing the value
of `AdjustIoLogLevel` to one of the following:

- `verbose` - enable all logging
- `debug` - enable more logging
- `info` - the default
- `warn` - disable info logging
- `error` - disable warnings as well
- `assert` - disable errors as well

## Additional features

Once you integrated the AdjustIo SDK into your project, you can take advantage
of the following features.

### Add tracking of custom events.

You can tell AdjustIo about every event you want. Suppose you want to track
every tap on a button. You would have to create a new Event Token in your
[dashboard]. Let's say that Event Token is `abc123`. In your button's
click handler method you could then add the following line to track the click:

```actionscript
AdjustIo.TrackEvent("abc123");
```

You can also register a callback URL for that event in your [dashboard] and we
will send a GET request to that URL whenever the event gets tracked. In that
case you can also put some key-value-pairs in an object and pass it to the
`trackEvent` method. We will then append these named parameters to your
callback URL.

For example, suppose you have registered the URL
`http://www.adeven.com/callback` for your event with Event Token `abc123` and
execute the following lines:

<pre><code>
Dictionary<string,string> parameters = new Dictionary<string, string>();
parameters.Add("key","value");
parameters.Add("foo","bar");

AdjustIo.TrackEvent("abc123", parameters);
</code></pre>

In that case we would track the event and send a request to:

http://www.adeven.com/callback?key=value&foo=bar

It should be mentioned that we support a variety of placeholders like `{idfa}`
that can be used as parameter values. In the resulting callback this
placeholder would be replaced with the ID for Advertisers of the current
device. Also note that we don't store any of your custom parameters, but only
append them to your callbacks. If you haven't registered a callback for an
event, these parameters won't even be read.

### Add tracking of revenue

If your users can generate revenue by clicking on advertisements or making
in-app purchases you can track those revenues. If, for example, a click is
worth one cent, you could make the following call to track that revenue:

```actionscript
AdjustIo.TrackRevenue(1.0);
```

The parameter is supposed to be in cents and will get rounded to one decimal
point. If you want to differentiate between different kinds of revenue you can
get different Event Tokens for each kind. Again, you need to create those Event
Tokens in your [dashboard]. In that case you would make a call like this:

```actionscript
AdjustIo.TrackRevenue(1.0, "abc123");
```

Again, you can register a callback and provide a dictionary of named
parameters, just like it worked with normal events.

<pre><code>
Dictionary<string,string> parameters = new Dictionary<string, string>();
parameters.Add("key","value");
parameters.Add("foo","bar");

AdjustIo.TrackRevenue(1.0, "abc123", parameters);
</code></pre>

[import]: https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/UnityImport.png
[settings]: https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/AdjustIoSettings.png
[adjust.io]: http://adjust.io
[dashboard]: http://adjust.io
[releases]: https://github.com/adeven/adjust_unity_sdk/releases
[permissions]: https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/UnityPermissions.png
[receiver]: https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/UnityReceiver.png
[metadata] : https://raw.github.com/adeven/adjust_sdk/master/Resources/unity/UnityMetaData.png

## License

The file mod_pbxproj.py is licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0

The adjust-sdk is licensed under the MIT License.

Copyright (c) 2012-2013 adeven GmbH,
http://www.adeven.com

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

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

- (void)trackSubsessionStart;
- (void)trackSubsessionEnd;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ - (id)initWithAppToken:(NSString *)yourAppToken {
[self addNotificationObserver];
self.internalQueue = dispatch_queue_create(kInternalQueueName, DISPATCH_QUEUE_SERIAL);
self.environment = @"unknown"; // default value
self.clientSdk = AIUtil.clientSdk;

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

- (void)setSdkPrefix:(NSString *)sdkPrefix {
self.clientSdk = [NSString stringWithFormat:@"%@@%@", sdkPrefix, self.clientSdk];
}

- (void)trackSubsessionStart {
dispatch_async(self.internalQueue, ^{
[self startInternal];
Expand Down Expand Up @@ -112,7 +117,6 @@ - (void)initInternal:(NSString *)yourAppToken {
self.idForAdvertisers = UIDevice.currentDevice.aiIdForAdvertisers;
self.fbAttributionId = UIDevice.currentDevice.aiFbAttributionId;
self.userAgent = AIUtil.userAgent;
self.clientSdk = AIUtil.clientSdk;

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

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,5 @@
- (NSString *)aiSha1;
- (NSString *)aiUrlEncode;
- (NSString *)aiRemoveColons;
- (NSData *)aiDecodeBase64;

@end
Loading

0 comments on commit 5c5beb9

Please sign in to comment.