Skip to content

Commit

Permalink
Merge pull request #5 from adjust/api_upgrade
Browse files Browse the repository at this point in the history
API upgrade
  • Loading branch information
Uglješa Erceg committed Sep 17, 2015
2 parents 3eb9513 + f3aa230 commit 41feabc
Show file tree
Hide file tree
Showing 33 changed files with 1,380 additions and 637 deletions.
16 changes: 8 additions & 8 deletions iOS/Adjust/Adjust2dx.h → Adjust/ADJAdjust2dx.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// Adjust2dx.h
// AdjustDemo
// ADJAdjust2dx.h
// AdjustSDK
//
// Created by Uglješa Erceg on 17/06/15.
//
//

#ifndef __AdjustDemo__Adjust2dx__
#define __AdjustDemo__Adjust2dx__
#ifndef _ADJUST_ADJUST2DX_H_
#define _ADJUST_ADJUST2DX_H_

#include <iostream>

Expand All @@ -17,17 +17,17 @@
extern const std::string ADJEnvironmentSandbox2dx;
extern const std::string ADJEnvironmentProduction2dx;

class Adjust2dx {
class ADJAdjust2dx {
public:
static void appDidLaunch(ADJConfig2dx adjustConfig);
static void trackEvent(ADJEvent2dx adjustEvent);
static void trackSubsessionStart();
static void trackSubsessionEnd();
static void setEnabled(bool isEnabled);
static void appWillOpenUrl(std::string url);
static void appWillOpenUrl(void* url);
static void setDeviceToken(std::string deviceToken);

static void setOfflineMode(bool isOffline);
static bool isEnabled();
};

#endif /* defined(__AdjustDemo__Adjust2dx__) */
#endif /* _ADJUST_ADJUST2DX_H_ */
29 changes: 16 additions & 13 deletions iOS/Adjust/Adjust2dx.mm → Adjust/ADJAdjust2dx.mm
Original file line number Diff line number Diff line change
@@ -1,49 +1,52 @@
//
// Adjust2dx.mm
// AdjustDemo
// ADJAdjust2dx.mm
// AdjustSDK
//
// Created by Uglješa Erceg on 17/06/15.
//
//

#include "Adjust2dx.h"
#include "ADJAdjust2dx.h"
#include <Adjust/Adjust.h>

const std::string ADJEnvironmentSandbox2dx = std::string([ADJEnvironmentSandbox UTF8String]);
const std::string ADJEnvironmentProduction2dx = std::string([ADJEnvironmentProduction UTF8String]);

void Adjust2dx::appDidLaunch(ADJConfig2dx adjustConfig) {
[((ADJConfig *)adjustConfig.getConfig()) setSdkPrefix:@"cocos2d-x4.0.1"];
void ADJAdjust2dx::appDidLaunch(ADJConfig2dx adjustConfig) {
[Adjust appDidLaunch:(ADJConfig *)adjustConfig.getConfig()];
}

void Adjust2dx::trackEvent(ADJEvent2dx adjustEvent) {
void ADJAdjust2dx::trackEvent(ADJEvent2dx adjustEvent) {
[Adjust trackEvent:(ADJEvent *)adjustEvent.getEvent()];
}

void Adjust2dx::trackSubsessionStart() {
void ADJAdjust2dx::trackSubsessionStart() {
[Adjust trackSubsessionStart];
}

void Adjust2dx::trackSubsessionEnd() {
void ADJAdjust2dx::trackSubsessionEnd() {
[Adjust trackSubsessionEnd];
}

void Adjust2dx::setEnabled(bool isEnabled) {
void ADJAdjust2dx::setEnabled(bool isEnabled) {
[Adjust setEnabled:isEnabled];
}

void Adjust2dx::appWillOpenUrl(std::string url) {
NSURL *pUrl = [NSURL URLWithString:[NSString stringWithUTF8String:url.c_str()]];
void ADJAdjust2dx::appWillOpenUrl(void* url) {
NSURL *pUrl = (NSURL *)url;
[Adjust appWillOpenUrl:pUrl];
}

void Adjust2dx::setDeviceToken(std::string deviceToken) {
void ADJAdjust2dx::setDeviceToken(std::string deviceToken) {
NSData *pDeviceToken = [[NSString stringWithUTF8String:deviceToken.c_str()]
dataUsingEncoding:NSUTF8StringEncoding];
[Adjust setDeviceToken:pDeviceToken];
}

bool Adjust2dx::isEnabled() {
void ADJAdjust2dx::setOfflineMode(bool isOffline) {
[Adjust setOfflineMode:isOffline];
}

bool ADJAdjust2dx::isEnabled() {
return [Adjust isEnabled];
}
45 changes: 45 additions & 0 deletions Adjust/ADJConfig2dx.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
//
// ADJConfig2dx.h
// AdjustSDK
//
// Created by Uglješa Erceg on 17/06/15.
//
//

#ifndef _ADJUST_ADJUSTCONFIG2DX_H_
#define _ADJUST_ADJUSTCONFIG2DX_H_

#include <iostream>
#include "AdjustAttribution2dx.h"

enum ADJLogLevel2dx {
ADJLogLevel2dxVerbose = 1,
ADJLogLevel2dxDebug = 2,
ADJLogLevel2dxInfo = 3,
ADJLogLevel2dxWarn = 4,
ADJLogLevel2dxError = 5,
ADJLogLevel2dxAssert = 6 };

class ADJConfig2dx {
private:
void* config;
void (*callback)(AdjustAttribution2dx attribution);
void initConfig(std::string appToken, std::string environment, std::string sdkPrefix);

public:
ADJConfig2dx() {}
ADJConfig2dx(std::string appToken, std::string environment, std::string sdkPrefix) {
initConfig(appToken, environment, sdkPrefix);
}

void setLogLevel(ADJLogLevel2dx logLevel);
void setDefaultTracker(std::string defaultTracker);
void setEventBufferingEnabled(bool isEnabled);
void setMacMd5TrackingEnabled(bool isEnabled);

void setAttributionCallback(void (*callbackMethod)(AdjustAttribution2dx attribution));

void* getConfig();
};

#endif /* _ADJUST_ADJUSTCONFIG2DX_H_ */
63 changes: 9 additions & 54 deletions iOS/Adjust/ADJConfig2dx.mm → Adjust/ADJConfig2dx.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ADJConfig2dx.mm
// AdjustDemo
// AdjustSDK
//
// Created by Uglješa Erceg on 17/06/15.
//
Expand All @@ -16,7 +16,7 @@ @interface AttributionCallback : NSObject<AdjustDelegate>

@implementation AttributionCallback

void (*callbackToTrigger)(ADJAttribution2dx attribution);
void (*callbackToTrigger)(AdjustAttribution2dx attribution);

- (id)init {
self = [super init];
Expand All @@ -34,115 +34,70 @@ - (void)adjustAttributionChanged:(ADJAttribution *)attribution {

if (attribution.trackerToken != nil) {
trackerToken = std::string([attribution.trackerToken UTF8String]);
} else {
trackerToken = "";
}

if (attribution.trackerName != nil) {
trackerName = std::string([attribution.trackerName UTF8String]);
} else {
trackerName = "";
}

if (attribution.network != nil) {
network = std::string([attribution.network UTF8String]);
} else {
network = "";
}

if (attribution.campaign != nil) {
campaign = std::string([attribution.campaign UTF8String]);
} else {
campaign = "";
}

if (attribution.adgroup != nil) {
adgroup = std::string([attribution.adgroup UTF8String]);
} else {
adgroup = "";
}

if (attribution.creative != nil) {
creative = std::string([attribution.creative UTF8String]);
} else {
creative = "";
}

if (attribution.clickLabel != nil) {
clickLabel = std::string([attribution.clickLabel UTF8String]);
} else {
clickLabel = "";
}

ADJAttribution2dx attribution2dx = ADJAttribution2dx(trackerToken, trackerName, network, campaign, adgroup, creative,clickLabel);
AdjustAttribution2dx attribution2dx = AdjustAttribution2dx(trackerToken, trackerName, network, campaign, adgroup, creative,clickLabel);

callbackToTrigger(attribution2dx);
}

@end

void ADJConfig2dx::initConfig(std::string appToken, std::string environment) {
void ADJConfig2dx::initConfig(std::string appToken, std::string environment, std::string sdkPrefix) {
config = [[ADJConfig alloc] initWithAppToken:
[NSString stringWithUTF8String:appToken.c_str()]
environment:
[NSString stringWithUTF8String:environment.c_str()]];

AttributionCallback *attributionCallback = [[AttributionCallback alloc] init];
((ADJConfig *)config).delegate = attributionCallback;
}

std::string ADJConfig2dx::getAppToken() {
return std::string([((ADJConfig *)config).appToken UTF8String]);
[((ADJConfig *)config) setSdkPrefix:[NSString stringWithUTF8String:sdkPrefix.c_str()]];
}

void ADJConfig2dx::setLogLevel(ADJLogLevel2dx logLevel) {
((ADJConfig *)config).logLevel = (ADJLogLevel)logLevel;
}

ADJLogLevel2dx ADJConfig2dx::getLogLevel() {
return (ADJLogLevel2dx)((ADJConfig *)config).logLevel;
}

std::string ADJConfig2dx::getEnvironment() {
return std::string([((ADJConfig *)config).environment UTF8String]);
}

void ADJConfig2dx::setSdkPrefix(std::string sdkPrefix) {
((ADJConfig *)config).sdkPrefix = [NSString stringWithUTF8String:sdkPrefix.c_str()];
}

std::string ADJConfig2dx::getSdkPrefix() {
return std::string([((ADJConfig *)config).sdkPrefix UTF8String]);
}

void ADJConfig2dx::setDefaultTracker(std::string defaultTracker) {
((ADJConfig *)config).defaultTracker =
[NSString stringWithUTF8String:defaultTracker.c_str()];
}

std::string ADJConfig2dx::getDefaultTracker() {
return std::string([((ADJConfig *)config).defaultTracker UTF8String]);
}

void ADJConfig2dx::setEventBufferingEnabled(bool isEnabled) {
((ADJConfig *)config).eventBufferingEnabled = isEnabled;
}

bool ADJConfig2dx::getEventBufferingEnabled() {
return ((ADJConfig *)config).eventBufferingEnabled;
}

void ADJConfig2dx::setMacMd5TrackingEnabled(bool isEnabled) {
((ADJConfig *)config).macMd5TrackingEnabled = isEnabled;
}

bool ADJConfig2dx::getMacMd5TrackingEnabled() {
return ((ADJConfig *)config).macMd5TrackingEnabled;
}

void ADJConfig2dx::setAttributionCallback(void (*callbackMethod)(ADJAttribution2dx attribution)) {
void ADJConfig2dx::setAttributionCallback(void (*callbackMethod)(AdjustAttribution2dx attribution)) {
callback = callbackMethod;
callbackToTrigger = callback;

AttributionCallback *attributionCallback = [[AttributionCallback alloc] init];
((ADJConfig *)config).delegate = attributionCallback;
}

void* ADJConfig2dx::getConfig() {
Expand Down
8 changes: 4 additions & 4 deletions iOS/Adjust/ADJEvent2dx.h → Adjust/ADJEvent2dx.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// ADJEvent2dx.h
// AdjustDemo
// AdjustSDK
//
// Created by Uglješa Erceg on 17/06/15.
//
//

#ifndef __AdjustDemo__ADJEvent2dx__
#define __AdjustDemo__ADJEvent2dx__
#ifndef _ADJUST_ADJUSTEVENT2DX_H_
#define _ADJUST_ADJUSTEVENT2DX_H_

#include <iostream>

Expand All @@ -33,4 +33,4 @@ class ADJEvent2dx {
void* getEvent();
};

#endif /* defined(__AdjustDemo__ADJEvent2dx__) */
#endif /* _ADJUST_ADJUSTEVENT2DX_H_ */
2 changes: 1 addition & 1 deletion iOS/Adjust/ADJEvent2dx.mm → Adjust/ADJEvent2dx.mm
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//
// ADJEvent2dx.mm
// AdjustDemo
// AdjustSDK
//
// Created by Uglješa Erceg on 17/06/15.
//
Expand Down
Loading

0 comments on commit 41feabc

Please sign in to comment.