diff --git a/iOS/Adjust/Adjust2dx.h b/Adjust/ADJAdjust2dx.h similarity index 70% rename from iOS/Adjust/Adjust2dx.h rename to Adjust/ADJAdjust2dx.h index 43d83f6b..79f2efef 100644 --- a/iOS/Adjust/Adjust2dx.h +++ b/Adjust/ADJAdjust2dx.h @@ -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 @@ -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_ */ diff --git a/iOS/Adjust/Adjust2dx.mm b/Adjust/ADJAdjust2dx.mm similarity index 56% rename from iOS/Adjust/Adjust2dx.mm rename to Adjust/ADJAdjust2dx.mm index b9eef204..07b1acb0 100644 --- a/iOS/Adjust/Adjust2dx.mm +++ b/Adjust/ADJAdjust2dx.mm @@ -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 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]; } \ No newline at end of file diff --git a/Adjust/ADJConfig2dx.h b/Adjust/ADJConfig2dx.h new file mode 100644 index 00000000..38d72190 --- /dev/null +++ b/Adjust/ADJConfig2dx.h @@ -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 +#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_ */ diff --git a/iOS/Adjust/ADJConfig2dx.mm b/Adjust/ADJConfig2dx.mm similarity index 63% rename from iOS/Adjust/ADJConfig2dx.mm rename to Adjust/ADJConfig2dx.mm index 98ed0fce..5740e4fe 100644 --- a/iOS/Adjust/ADJConfig2dx.mm +++ b/Adjust/ADJConfig2dx.mm @@ -1,6 +1,6 @@ // // ADJConfig2dx.mm -// AdjustDemo +// AdjustSDK // // Created by Uglješa Erceg on 17/06/15. // @@ -16,7 +16,7 @@ @interface AttributionCallback : NSObject @implementation AttributionCallback -void (*callbackToTrigger)(ADJAttribution2dx attribution); +void (*callbackToTrigger)(AdjustAttribution2dx attribution); - (id)init { self = [super init]; @@ -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() { diff --git a/iOS/Adjust/ADJEvent2dx.h b/Adjust/ADJEvent2dx.h similarity index 82% rename from iOS/Adjust/ADJEvent2dx.h rename to Adjust/ADJEvent2dx.h index 40f3e52c..1cc15e59 100644 --- a/iOS/Adjust/ADJEvent2dx.h +++ b/Adjust/ADJEvent2dx.h @@ -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 @@ -33,4 +33,4 @@ class ADJEvent2dx { void* getEvent(); }; -#endif /* defined(__AdjustDemo__ADJEvent2dx__) */ +#endif /* _ADJUST_ADJUSTEVENT2DX_H_ */ diff --git a/iOS/Adjust/ADJEvent2dx.mm b/Adjust/ADJEvent2dx.mm similarity index 99% rename from iOS/Adjust/ADJEvent2dx.mm rename to Adjust/ADJEvent2dx.mm index 345f2bda..09501958 100644 --- a/iOS/Adjust/ADJEvent2dx.mm +++ b/Adjust/ADJEvent2dx.mm @@ -1,6 +1,6 @@ // // ADJEvent2dx.mm -// AdjustDemo +// AdjustSDK // // Created by Uglješa Erceg on 17/06/15. // diff --git a/Adjust/Adjust2dx.cpp b/Adjust/Adjust2dx.cpp new file mode 100644 index 00000000..05efb358 --- /dev/null +++ b/Adjust/Adjust2dx.cpp @@ -0,0 +1,134 @@ +// +// Adjust2dx.cpp +// Adjust SDK +// +// Created by Uglješa Erceg on 16/06/15. +// + +#include "Adjust2dx.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include +#include "platform/android/jni/JniHelper.h" +#include "AdjustProxy2dx.h" +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "ADJAdjust2dx.h" +#endif + +const std::string AdjustEnvironmentSandbox2dx = "sandbox"; +const std::string AdjustEnvironmentProduction2dx = "production"; + +void Adjust2dx::start(AdjustConfig2dx adjustConfig) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miOnCreate; + + if (!cocos2d::JniHelper::getStaticMethodInfo(miOnCreate, "com.adjust.sdk.Adjust", "onCreate", + "(Lcom/adjust/sdk/AdjustConfig;)V")) { + return; + } + + miOnCreate.env->CallStaticVoidMethod(miOnCreate.classID, miOnCreate.methodID, adjustConfig.getConfig()); + + onResume(); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJAdjust2dx::appDidLaunch(adjustConfig.getConfig()); +#endif +} + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +void Adjust2dx::onResume() { + cocos2d::JniMethodInfo miOnResume; + + if (!cocos2d::JniHelper::getStaticMethodInfo(miOnResume, "com.adjust.sdk.Adjust", "onResume", "()V")) { + return; + } + + miOnResume.env->CallStaticVoidMethod(miOnResume.classID, miOnResume.methodID); +} + +void Adjust2dx::onPause() { + cocos2d::JniMethodInfo miOnPause; + + if (!cocos2d::JniHelper::getStaticMethodInfo(miOnPause, "com.adjust.sdk.Adjust", "onPause", "()V")) { + return; + } + + miOnPause.env->CallStaticVoidMethod(miOnPause.classID, miOnPause.methodID); +} + +void Adjust2dx::setReferrer(std::string referrer) { + cocos2d::JniMethodInfo miSetReferrer; + + if (cocos2d::JniHelper::getStaticMethodInfo(miSetReferrer, "com.adjust.sdk.Adjust", "setReferrer", + "(Ljava/lang/String;)V")) { + jstring jReferrer = miSetReferrer.env->NewStringUTF(referrer.c_str()); + + miSetReferrer.env->CallStaticVoidMethod(miSetReferrer.classID, miSetReferrer.methodID, jReferrer); + + miSetReferrer.env->DeleteLocalRef(jReferrer); + } +} +#endif + +void Adjust2dx::trackEvent(AdjustEvent2dx event) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miTrackEvent; + + if (!cocos2d::JniHelper::getStaticMethodInfo(miTrackEvent, "com.adjust.sdk.Adjust", "trackEvent", + "(Lcom/adjust/sdk/AdjustEvent;)V")) { + return; + } + + miTrackEvent.env->CallStaticVoidMethod(miTrackEvent.classID, miTrackEvent.methodID, event.getEvent()); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJAdjust2dx::trackEvent(event.getEvent()); +#endif +} + +void Adjust2dx::setEnabled(bool isEnabled) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miSetEnabled; + + if (cocos2d::JniHelper::getStaticMethodInfo(miSetEnabled, "com.adjust.sdk.Adjust", "setEnabled", "(Z)V")) { + miSetEnabled.env->CallStaticVoidMethod(miSetEnabled.classID, miSetEnabled.methodID, isEnabled); + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJAdjust2dx::setEnabled(isEnabled); +#endif +} + +bool Adjust2dx::isEnabled() { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miIsEnabled; + + if (cocos2d::JniHelper::getStaticMethodInfo(miIsEnabled, "com.adjust.sdk.Adjust", "isEnabled", "()Z")) { + jboolean jIsEnabled = miIsEnabled.env->CallStaticBooleanMethod(miIsEnabled.classID, miIsEnabled.methodID); + + return jIsEnabled; + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + return ADJAdjust2dx::isEnabled(); +#else + return false; +#endif +} + +void Adjust2dx::setOfflineMode(bool isOffline) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miIsOffline; + + if (cocos2d::JniHelper::getStaticMethodInfo(miIsOffline, "com.adjust.sdk.Adjust", "setOfflineMode", "(Z)V")) { + miIsOffline.env->CallStaticVoidMethod(miIsOffline.classID, miIsOffline.methodID, isOffline); + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJAdjust2dx::setOfflineMode(isOffline); +#endif +} + +void Adjust2dx::appWillOpenUrl(void* url) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJAdjust2dx::appWillOpenUrl(url); +#endif +} diff --git a/Adjust/Adjust2dx.h b/Adjust/Adjust2dx.h new file mode 100644 index 00000000..8309dd8d --- /dev/null +++ b/Adjust/Adjust2dx.h @@ -0,0 +1,37 @@ +// +// Adjust2dx.h +// Adjust SDK +// +// Created by Uglješa Erceg on 16/06/15. +// + +#ifndef ADJUST_ADJUST2DX_H_ +#define ADJUST_ADJUST2DX_H_ + +#include + +#include "AdjustEvent2dx.h" +#include "AdjustConfig2dx.h" + +extern const std::string AdjustEnvironmentSandbox2dx; +extern const std::string AdjustEnvironmentProduction2dx; + +class Adjust2dx { +public: + static void start(AdjustConfig2dx adjustConfig); + static void trackEvent(AdjustEvent2dx event); + static void setEnabled(bool isEnabled); + static bool isEnabled(); + static void setOfflineMode(bool isOffline); + static void appWillOpenUrl(void* url); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + static void onResume(); + static void onPause(); + static void setReferrer(std::string referrer); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + static void setDeviceToken(std::string deviceToken); +#endif +}; + +#endif /* ADJUST_ADJUST2DX_H_ */ diff --git a/Adjust/AdjustAttribution2dx.cpp b/Adjust/AdjustAttribution2dx.cpp new file mode 100644 index 00000000..9a7c0917 --- /dev/null +++ b/Adjust/AdjustAttribution2dx.cpp @@ -0,0 +1,36 @@ +// +// AdjustAttribution2dx.cpp +// Adjust SDK +// +// Created by Uglješa Erceg on 16/06/15. +// + +#include "AdjustAttribution2dx.h" + +std::string AdjustAttribution2dx::getTrackerToken() { + return this->trackerToken; +} + +std::string AdjustAttribution2dx::getTrackerName() { + return this->trackerName; +} + +std::string AdjustAttribution2dx::getNetwork() { + return this->network; +} + +std::string AdjustAttribution2dx::getCampaign() { + return this->campaign; +} + +std::string AdjustAttribution2dx::getAdgroup() { + return this->adgroup; +} + +std::string AdjustAttribution2dx::getCreative() { + return this->creative; +} + +std::string AdjustAttribution2dx::getClickLabel() { + return this->clickLabel; +} diff --git a/iOS/Adjust/ADJAttribution2dx.h b/Adjust/AdjustAttribution2dx.h similarity index 59% rename from iOS/Adjust/ADJAttribution2dx.h rename to Adjust/AdjustAttribution2dx.h index 9a9e86ba..7c9ffd86 100644 --- a/iOS/Adjust/ADJAttribution2dx.h +++ b/Adjust/AdjustAttribution2dx.h @@ -1,17 +1,16 @@ // -// ADJAttribution2dx.h -// AdjustDemo -// -// Created by Uglješa Erceg on 17/06/15. +// AdjustAttribution2dx.h +// Adjust SDK // +// Created by Uglješa Erceg on 16/06/15. // -#ifndef __AdjustDemo__ADJAttribution2dx__ -#define __AdjustDemo__ADJAttribution2dx__ +#ifndef ADJUST_ADJUSTATTRIBUTION2DX_H_ +#define ADJUST_ADJUSTATTRIBUTION2DX_H_ #include -class ADJAttribution2dx { +class AdjustAttribution2dx { private: std::string trackerToken; std::string trackerName; @@ -21,10 +20,10 @@ class ADJAttribution2dx { std::string creative; std::string clickLabel; public: - ADJAttribution2dx() {} - ADJAttribution2dx(std::string trackerToken, std::string trackerName, std::string network, - std::string campaign, std::string adgroup, std::string creative, - std::string clickLabel) { + AdjustAttribution2dx() {} + AdjustAttribution2dx(std::string trackerToken, std::string trackerName, std::string network, + std::string campaign, std::string adgroup, std::string creative, + std::string clickLabel) { this->trackerToken = trackerToken; this->trackerName = trackerName; this->network = network; @@ -43,4 +42,4 @@ class ADJAttribution2dx { std::string getClickLabel(); }; -#endif /* defined(__AdjustDemo__ADJAttribution2dx__) */ +#endif /* ADJUST_ADJUSTATTRIBUTION2DX_H_ */ diff --git a/Adjust/AdjustConfig2dx.cpp b/Adjust/AdjustConfig2dx.cpp new file mode 100644 index 00000000..f8b2f2e9 --- /dev/null +++ b/Adjust/AdjustConfig2dx.cpp @@ -0,0 +1,209 @@ +// +// AdjustConfig2dx.cpp +// Adjust SDK +// +// Created by Uglješa Erceg on 16/06/15. +// + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include +#include "platform/android/jni/JniHelper.h" +#include "AdjustProxy2dx.h" +#endif + +#include "AdjustConfig2dx.h" + +void AdjustConfig2dx::initConfig(std::string appToken, std::string environment) { + std::string sdkPrefix = "cocos2d-x4.1.0"; + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miInit; + + if (cocos2d::JniHelper::getMethodInfo(miInit, "com.adjust.sdk.AdjustConfig", "", + "(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V")) { + jclass clsAdjustConfig = miInit.env->FindClass("com.adjust.sdk.AdjustConfig"); + jmethodID midInit = miInit.env->GetMethodID(clsAdjustConfig, "", + "(Landroid/content/Context;Ljava/lang/String;Ljava/lang/String;)V"); + + cocos2d::JniMethodInfo miGetContext; + + if (cocos2d::JniHelper::getStaticMethodInfo(miGetContext, "org/cocos2dx/lib/Cocos2dxActivity", "getContext", + "()Landroid/content/Context;")) { + // Get context and initialize config object. + jobject jContext = (jobject)miGetContext.env->CallStaticObjectMethod(miGetContext.classID, miGetContext.methodID); + jstring jAppToken = miInit.env->NewStringUTF(appToken.c_str()); + jstring jEnvironment = miInit.env->NewStringUTF(environment.c_str()); + + config = miInit.env->NewObject(clsAdjustConfig, midInit, jContext, jAppToken, jEnvironment); + + miGetContext.env->DeleteLocalRef(jContext); + miInit.env->DeleteLocalRef(jAppToken); + miInit.env->DeleteLocalRef(jEnvironment); + + // Set SDK prefix. + cocos2d::JniMethodInfo miSetSdkPrefix; + + if (cocos2d::JniHelper::getMethodInfo(miSetSdkPrefix, "com.adjust.sdk.AdjustConfig", "setSdkPrefix", + "(Ljava/lang/String;)V")) { + jstring jSdkPrefix = miSetSdkPrefix.env->NewStringUTF(sdkPrefix.c_str()); + + miSetSdkPrefix.env->CallVoidMethod(config, miSetSdkPrefix.methodID, jSdkPrefix); + + miSetSdkPrefix.env->DeleteLocalRef(jSdkPrefix); + } + } + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + config = ADJConfig2dx(appToken, environment, sdkPrefix); + isConfigSet = true; +#endif +} + +void AdjustConfig2dx::setLogLevel(AdjustLogLevel2dx logLevel) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miSetLogLevel; + + if (NULL != config) { + if (cocos2d::JniHelper::getMethodInfo(miSetLogLevel, "com.adjust.sdk.AdjustConfig", "setLogLevel", + "(Lcom/adjust/sdk/LogLevel;)V")) { + jclass clsLogLevel = miSetLogLevel.env->FindClass("com/adjust/sdk/LogLevel"); + + std::string enumValue; + + switch (logLevel) { + case AdjustLogLevel2dxAssert: + enumValue = "ASSERT"; + break; + case AdjustLogLevel2dxDebug: + enumValue = "DEBUG"; + break; + case AdjustLogLevel2dxError: + enumValue = "ERROR"; + break; + case AdjustLogLevel2dxInfo: + enumValue = "INFO"; + break; + case AdjustLogLevel2dxVerbose: + enumValue = "VERBOSE"; + break; + case AdjustLogLevel2dxWarn: + enumValue = "WARN"; + break; + default: + enumValue = "INFO"; + break; + } + + jfieldID fidValue = miSetLogLevel.env->GetStaticFieldID(clsLogLevel, enumValue.c_str(), + "Lcom/adjust/sdk/LogLevel;"); + jobject jLogLevel = miSetLogLevel.env->GetStaticObjectField(clsLogLevel, fidValue); + + miSetLogLevel.env->CallVoidMethod(config, miSetLogLevel.methodID, jLogLevel); + + miSetLogLevel.env->DeleteLocalRef(jLogLevel); + } + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if (isConfigSet) { + config.setLogLevel((ADJLogLevel2dx)logLevel); + } +#endif +} + +void AdjustConfig2dx::setEventBufferingEnabled(bool isEnabled) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miSetEventBufferingEnabled; + + if (NULL != config) { + if (cocos2d::JniHelper::getMethodInfo(miSetEventBufferingEnabled, "com.adjust.sdk.AdjustConfig", + "setEventBufferingEnabled", "(Z)V")) { + miSetEventBufferingEnabled.env->CallVoidMethod(config, miSetEventBufferingEnabled.methodID, isEnabled); + } + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if (isConfigSet) { + config.setEventBufferingEnabled(isEnabled); + } +#endif +} + +void AdjustConfig2dx::setDefaultTracker(std::string defaultTracker) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miSetDefaultTracker; + + if (NULL != config) { + if (cocos2d::JniHelper::getMethodInfo(miSetDefaultTracker, "com.adjust.sdk.AdjustConfig", "setDefaultTracker", + "(Ljava/lang/String;)V")) { + jstring jDefaultTracker = miSetDefaultTracker.env->NewStringUTF(defaultTracker.c_str()); + + miSetDefaultTracker.env->CallVoidMethod(config, miSetDefaultTracker.methodID, jDefaultTracker); + + miSetDefaultTracker.env->DeleteLocalRef(jDefaultTracker); + } + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if (isConfigSet) { + config.setDefaultTracker(defaultTracker); + } +#endif +} + +void AdjustConfig2dx::setAttributionCallback(void (*callbackMethod)(AdjustAttribution2dx attribution)) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + setAttributionCallbackMethod(callbackMethod); + + cocos2d::JniMethodInfo miSetCallback; + + if (NULL != config) { + if (cocos2d::JniHelper::getMethodInfo(miSetCallback, "com.adjust.sdk.AdjustConfig", "setOnAttributionChangedListener", + "(Lcom/adjust/sdk/OnAttributionChangedListener;)V")) { + cocos2d::JniMethodInfo miInit; + + if (cocos2d::JniHelper::getMethodInfo(miInit, "com.adjust.sdk.Adjust2dxAttributionCallback", "", "()V")) { + jclass clsAdjust2dxAttributionCallback = miInit.env->FindClass("com/adjust/sdk/Adjust2dxAttributionCallback"); + jmethodID midInit = miInit.env->GetMethodID(clsAdjust2dxAttributionCallback, "", "()V"); + jobject jCallbackProxy = miInit.env->NewObject(clsAdjust2dxAttributionCallback, midInit); + + miSetCallback.env->CallVoidMethod(config, miSetCallback.methodID, jCallbackProxy); + + miInit.env->DeleteLocalRef(jCallbackProxy); + } + } + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if (isConfigSet) { + config.setAttributionCallback(callbackMethod); + } +#endif +} + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +jobject AdjustConfig2dx::getConfig() { + return config; +} + +void AdjustConfig2dx::setProcessName(std::string processName) { + cocos2d::JniMethodInfo miSetProcessName; + + if (NULL != config) { + if (cocos2d::JniHelper::getMethodInfo(miSetProcessName, "com.adjust.sdk.AdjustConfig", "setProcessName", + "(Ljava/lang/String;)V")) { + jstring jProcessName = miSetProcessName.env->NewStringUTF(processName.c_str()); + + miSetProcessName.env->CallVoidMethod(config, miSetProcessName.methodID, jProcessName); + + miSetProcessName.env->DeleteLocalRef(jProcessName); + } + } +} +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +ADJConfig2dx AdjustConfig2dx::getConfig() { + return config; +} + +void AdjustConfig2dx::setMacMd5TrackingEnabled(bool isEnabled) { + if (isConfigSet) { + config.setMacMd5TrackingEnabled(isEnabled); + } +} +#endif diff --git a/Adjust/AdjustConfig2dx.h b/Adjust/AdjustConfig2dx.h new file mode 100644 index 00000000..ac4d7be8 --- /dev/null +++ b/Adjust/AdjustConfig2dx.h @@ -0,0 +1,62 @@ +// +// AdjustConfig2dx.h +// Adjust SDK +// +// Created by Uglješa Erceg on 16/06/15. +// + +#ifndef ADJUST_ADJUSTCONFIG2DX_H_ +#define ADJUST_ADJUSTCONFIG2DX_H_ + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "ADJConfig2dx.h" +#endif + +#include +#include "AdjustAttribution2dx.h" + +enum AdjustLogLevel2dx { + AdjustLogLevel2dxVerbose = 1, + AdjustLogLevel2dxDebug = 2, + AdjustLogLevel2dxInfo = 3, + AdjustLogLevel2dxWarn = 4, + AdjustLogLevel2dxError = 5, + AdjustLogLevel2dxAssert = 6 }; + +class AdjustConfig2dx { +private: +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + jobject config; +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJConfig2dx config; + bool isConfigSet; +#endif + void initConfig(std::string appToken, std::string environment); + +public: + AdjustConfig2dx() {} + AdjustConfig2dx(std::string appToken, std::string environment) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + initConfig(appToken, environment); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + isConfigSet = true; + initConfig(appToken, environment); +#endif + } + + void setEventBufferingEnabled(bool isEnabled); + void setLogLevel(AdjustLogLevel2dx logLevel); + void setDefaultTracker(std::string defaultTracker); + void setAttributionCallback(void (*callbackMethod)(AdjustAttribution2dx attribution)); +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + jobject getConfig(); + void setProcessName(std::string processName); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJConfig2dx getConfig(); + void setMacMd5TrackingEnabled(bool isEnabled); +#endif +}; + +#endif /* ADJUST_ADJUSTCONFIG2DX_H_ */ diff --git a/Adjust/AdjustEvent2dx.cpp b/Adjust/AdjustEvent2dx.cpp new file mode 100644 index 00000000..ed975fd5 --- /dev/null +++ b/Adjust/AdjustEvent2dx.cpp @@ -0,0 +1,147 @@ +// +// AdjustEvent2dx.cpp +// Adjust SDK +// +// Created by Uglješa Erceg on 16/06/15. +// + +#include "AdjustEvent2dx.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include +#include "platform/android/jni/JniHelper.h" +#endif + +void AdjustEvent2dx::initEvent(std::string eventToken) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miInit; + + if (cocos2d::JniHelper::getMethodInfo(miInit, "com.adjust.sdk.AdjustEvent", "", "(Ljava/lang/String;)V")) { + jclass clsAdjustEvent = miInit.env->FindClass("com/adjust/sdk/AdjustEvent"); + jmethodID midInit = miInit.env->GetMethodID(clsAdjustEvent, "", "(Ljava/lang/String;)V"); + jstring jToken = miInit.env->NewStringUTF(eventToken.c_str()); + + event = miInit.env->NewObject(clsAdjustEvent, midInit, jToken); + + miInit.env->DeleteLocalRef(jToken); + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + event = ADJEvent2dx(eventToken); + isEventSet = true; +#endif +} + +void AdjustEvent2dx::addCallbackParameter(std::string key, std::string value) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miAddCallbackParameter; + + if (NULL != event) { + if (cocos2d::JniHelper::getMethodInfo(miAddCallbackParameter, "com.adjust.sdk.AdjustEvent", "addCallbackParameter", + "(Ljava/lang/String;Ljava/lang/String;)V")) { + jstring jKey = miAddCallbackParameter.env->NewStringUTF(key.c_str()); + jstring jValue = miAddCallbackParameter.env->NewStringUTF(value.c_str()); + + miAddCallbackParameter.env->CallVoidMethod(event, miAddCallbackParameter.methodID, jKey, jValue); + + miAddCallbackParameter.env->DeleteLocalRef(jKey); + miAddCallbackParameter.env->DeleteLocalRef(jValue); + } + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if (isEventSet) { + event.addCallbackParameter(key, value); + } +#endif +} + +void AdjustEvent2dx::addPartnerParameter(std::string key, std::string value) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miAddPartnerParameter; + + if (NULL != event) { + if (cocos2d::JniHelper::getMethodInfo(miAddPartnerParameter, "com.adjust.sdk.AdjustEvent", "addPartnerParameter", + "(Ljava/lang/String;Ljava/lang/String;)V")) { + jstring jKey = miAddPartnerParameter.env->NewStringUTF(key.c_str()); + jstring jValue = miAddPartnerParameter.env->NewStringUTF(value.c_str()); + + miAddPartnerParameter.env->CallVoidMethod(event, miAddPartnerParameter.methodID, jKey, jValue); + + miAddPartnerParameter.env->DeleteLocalRef(jKey); + miAddPartnerParameter.env->DeleteLocalRef(jValue); + } + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if (isEventSet) { + event.addPartnerParameter(key, value); + } +#endif +} + +void AdjustEvent2dx::setRevenue(double amount, std::string currency) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miSetRevenue; + + if (NULL != event) { + if (cocos2d::JniHelper::getMethodInfo(miSetRevenue, "com.adjust.sdk.AdjustEvent", "setRevenue", + "(DLjava/lang/String;)V")) { + jstring jCurrency = miSetRevenue.env->NewStringUTF(currency.c_str()); + + miSetRevenue.env->CallVoidMethod(event, miSetRevenue.methodID, amount, jCurrency); + + miSetRevenue.env->DeleteLocalRef(jCurrency); + } + } +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if (isEventSet) { + event.setRevenue(amount, currency); + } +#endif +} + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +void AdjustEvent2dx::setTransactionId(std::string transactionId) { + if (isEventSet) { + event.setTransactionId(transactionId); + } +} + +void AdjustEvent2dx::setReceipt(std::string receipt, std::string transactionId) { + if (isEventSet) { + event.setReceipt(receipt, transactionId); + } +} +#endif + +bool AdjustEvent2dx::isValid() { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + cocos2d::JniMethodInfo miIsValid; + + if (NULL != event) { + if (cocos2d::JniHelper::getMethodInfo(miIsValid, "com.adjust.sdk.AdjustEvent", "isValid", "()Z")) { + jboolean jIsValid = miIsValid.env->CallBooleanMethod(event, miIsValid.methodID); + + return jIsValid; + } + } + + return false; +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + if (isEventSet) { + return event.isValid(); + } else { + return false; + } +#else + return false; +#endif +} + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +jobject AdjustEvent2dx::getEvent() { + return event; +} +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +ADJEvent2dx AdjustEvent2dx::getEvent() { + return event; +} +#endif diff --git a/Adjust/AdjustEvent2dx.h b/Adjust/AdjustEvent2dx.h new file mode 100644 index 00000000..142869b1 --- /dev/null +++ b/Adjust/AdjustEvent2dx.h @@ -0,0 +1,53 @@ +// +// AdjustEvent2dx.h +// Adjust SDK +// +// Created by Uglješa Erceg on 16/06/15. +// + +#ifndef ADJUST_ADJUSTEVENT2DX_H_ +#define ADJUST_ADJUSTEVENT2DX_H_ + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +#include +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) +#include "ADJEvent2dx.h" +#endif + +#include + +class AdjustEvent2dx { +private: +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + jobject event; +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJEvent2dx event; + bool isEventSet; +#endif + void initEvent(std::string eventToken); + +public: + AdjustEvent2dx(std::string eventToken) { +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + initEvent(eventToken); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + isEventSet = false; + initEvent(eventToken); +#endif + } + + void setRevenue(double amount, std::string currency); + void addCallbackParameter(std::string key, std::string value); + void addPartnerParameter(std::string key, std::string value); + bool isValid(); + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + jobject getEvent(); +#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS) + ADJEvent2dx getEvent(); + void setTransactionId(std::string transactionId); + void setReceipt(std::string receipt, std::string transactionId); +#endif +}; + +#endif /* ADJUST_ADJUSTEVENT2DX_H_ */ diff --git a/Adjust/AdjustProxy2dx.cpp b/Adjust/AdjustProxy2dx.cpp new file mode 100644 index 00000000..7ca16dd5 --- /dev/null +++ b/Adjust/AdjustProxy2dx.cpp @@ -0,0 +1,101 @@ +// +// AdjustProxy2dx.cpp +// Adjust SDK +// +// Created by Uglješa Erceg on 03/09/15. +// + +#include "AdjustProxy2dx.h" + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) +JNIEXPORT void JNICALL Java_com_adjust_sdk_Adjust2dxAttributionCallback_attributionChanged +(JNIEnv *env, jobject obj, jobject attributionObject) { + if (callbackToTrigger != NULL) { + std::string trackerToken; + std::string trackerName; + std::string network; + std::string campaign; + std::string adgroup; + std::string creative; + std::string clickLabel; + + jclass clsAdjustAttribution = env->FindClass("com/adjust/sdk/AdjustAttribution"); + + jfieldID fTrackerTokenID = env->GetFieldID(clsAdjustAttribution, "trackerToken", "Ljava/lang/String;"); + jfieldID fTrackerNameID = env->GetFieldID(clsAdjustAttribution, "trackerName", "Ljava/lang/String;"); + jfieldID fNetworkID = env->GetFieldID(clsAdjustAttribution, "network", "Ljava/lang/String;"); + jfieldID fCampaignID = env->GetFieldID(clsAdjustAttribution, "campaign", "Ljava/lang/String;"); + jfieldID fAdgroupID = env->GetFieldID(clsAdjustAttribution, "adgroup", "Ljava/lang/String;"); + jfieldID fCreativeID = env->GetFieldID(clsAdjustAttribution, "creative", "Ljava/lang/String;"); + jfieldID fClickLabelID = env->GetFieldID(clsAdjustAttribution, "clickLabel", "Ljava/lang/String;"); + + jstring jTrackerToken = (jstring)env->GetObjectField(attributionObject, fTrackerTokenID); + jstring jTrackerName = (jstring)env->GetObjectField(attributionObject, fTrackerNameID); + jstring jNetwork = (jstring)env->GetObjectField(attributionObject, fNetworkID); + jstring jCampaign = (jstring)env->GetObjectField(attributionObject, fCampaignID); + jstring jAdgroup = (jstring)env->GetObjectField(attributionObject, fAdgroupID); + jstring jCreative = (jstring)env->GetObjectField(attributionObject, fCreativeID); + jstring jClickLabel = (jstring)env->GetObjectField(attributionObject, fClickLabelID); + + if (jTrackerToken != NULL) { + const char *trackerTokenCStr = env->GetStringUTFChars(jTrackerToken, NULL); + trackerToken = std::string(trackerTokenCStr); + env->ReleaseStringUTFChars(jTrackerToken, trackerTokenCStr); + env->DeleteLocalRef(jTrackerToken); + } + + if (jTrackerName != NULL) { + const char *trackerNameCStr = env->GetStringUTFChars(jTrackerName, NULL); + trackerName = std::string(trackerNameCStr); + env->ReleaseStringUTFChars(jTrackerName, trackerNameCStr); + env->DeleteLocalRef(jTrackerName); + } + + if (jNetwork != NULL) { + const char *networkCStr = env->GetStringUTFChars(jNetwork, NULL); + network = std::string(networkCStr); + env->ReleaseStringUTFChars(jNetwork, networkCStr); + env->DeleteLocalRef(jNetwork); + } + + if (jCampaign != NULL) { + const char *campaignCStr = env->GetStringUTFChars(jCampaign, NULL); + campaign = std::string(campaignCStr); + env->ReleaseStringUTFChars(jCampaign, campaignCStr); + env->DeleteLocalRef(jCampaign); + } + + if (jAdgroup != NULL) { + const char *adgroupCStr = env->GetStringUTFChars(jAdgroup, NULL); + adgroup = std::string(adgroupCStr); + env->ReleaseStringUTFChars(jAdgroup, adgroupCStr); + env->DeleteLocalRef(jAdgroup); + } + + if (jCreative != NULL) { + const char *creativeCStr = env->GetStringUTFChars(jCreative, NULL); + creative = std::string(creativeCStr); + env->ReleaseStringUTFChars(jCreative, creativeCStr); + env->DeleteLocalRef(jCreative); + } + + if (jClickLabel != NULL) { + const char *clickLabelCStr = env->GetStringUTFChars(jClickLabel, NULL); + clickLabel = std::string(clickLabelCStr); + env->ReleaseStringUTFChars(jClickLabel, clickLabelCStr); + env->DeleteLocalRef(jClickLabel); + } + + AdjustAttribution2dx attribution = AdjustAttribution2dx(trackerToken, trackerName, network, + campaign, adgroup, creative, clickLabel); + callbackToTrigger(attribution); + } +} + +void setAttributionCallbackMethod(void (*callbackMethod)(AdjustAttribution2dx attribution)) { + if (callbackToTrigger == NULL) { + callbackToTrigger = callbackMethod; + } +} + +#endif diff --git a/Adjust/AdjustProxy2dx.h b/Adjust/AdjustProxy2dx.h new file mode 100644 index 00000000..cd7dc8e7 --- /dev/null +++ b/Adjust/AdjustProxy2dx.h @@ -0,0 +1,22 @@ +// +// AdjustProxy2dx.h +// Adjust SDK +// +// Created by Uglješa Erceg on 03/09/15. +// + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + +#include +#include "Adjust/AdjustAttribution2dx.h" + +extern "C" { +static void (*callbackToTrigger)(AdjustAttribution2dx attribution); + +JNIEXPORT void JNICALL Java_com_adjust_sdk_Adjust2dxAttributionCallback_attributionChanged +(JNIEnv *, jobject, jobject); + +void setAttributionCallbackMethod(void (*callbackMethod)(AdjustAttribution2dx attribution)); +} + +#endif diff --git a/Android/Adjust/Adjust2dx.cpp b/Android/Adjust/Adjust2dx.cpp deleted file mode 100644 index 4fd16590..00000000 --- a/Android/Adjust/Adjust2dx.cpp +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Adjust2dx.cpp - * - * Created on: Jun 16, 2015 - * Author: uerceg - */ - -#include "Adjust/Adjust2dx.h" - -#include -#include "platform/android/jni/JniHelper.h" - - -void Adjust2dx::trackEvent(AdjustEvent2dx event) { - cocos2d::JniMethodInfo methodInfo; - - if (!cocos2d::JniHelper::getStaticMethodInfo(methodInfo, "com/adjust/sdk/Adjust", "trackEvent", - "(Lcom/adjust/sdk/AdjustEvent;)V")) { - return; - } - - methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, event.getEvent()); -} - -void Adjust2dx::setEnabled(bool isEnabled) { - cocos2d::JniMethodInfo methodInfo; - - if (cocos2d::JniHelper::getStaticMethodInfo(methodInfo, "com/adjust/sdk/Adjust", "setEnabled", "(Z)V")) { - methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, isEnabled); - } -} - -bool Adjust2dx::isEnabled() { - return false; -} - -void Adjust2dx::setOfflineMode(bool isOffline) { - cocos2d::JniMethodInfo methodInfo; - - if (cocos2d::JniHelper::getStaticMethodInfo(methodInfo, "com/adjust/sdk/Adjust", "setOfflineMode", "(Z)V")) { - methodInfo.env->CallStaticVoidMethod(methodInfo.classID, methodInfo.methodID, isOffline); - } -} - diff --git a/Android/Adjust/Adjust2dx.h b/Android/Adjust/Adjust2dx.h deleted file mode 100644 index b359cd14..00000000 --- a/Android/Adjust/Adjust2dx.h +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Adjust2dx.h - * - * Created on: Jun 16, 2015 - * Author: uerceg - */ - -#ifndef ADJUST_ADJUST2DX_H_ -#define ADJUST_ADJUST2DX_H_ - -#include - -#include "Adjust/AdjustEvent2dx.h" - -extern std::string AdjustEnvironmentSandbox2dx; -extern std::string AdjustEnvironmentProduction2dx; - -class Adjust2dx { -public: - - static void trackEvent(AdjustEvent2dx event); - static void setEnabled(bool isEnabled); - static bool isEnabled(); - static void setOfflineMode(bool isOffline); -}; - -#endif /* ADJUST_ADJUST2DX_H_ */ diff --git a/Android/Adjust/AdjustEvent2dx.cpp b/Android/Adjust/AdjustEvent2dx.cpp deleted file mode 100644 index 63447c2f..00000000 --- a/Android/Adjust/AdjustEvent2dx.cpp +++ /dev/null @@ -1,109 +0,0 @@ -/* - * AdjustEvent2dx.cpp - * - * Created on: Jun 16, 2015 - * Author: uerceg - */ - -#include "Adjust/AdjustEvent2dx.h" - -#include -#include "platform/android/jni/JniHelper.h" - - -void AdjustEvent2dx::initEvent(std::string eventToken) { - cocos2d::JniMethodInfo methodInfo; - - if (cocos2d::JniHelper::getMethodInfo(methodInfo, "com/adjust/sdk/AdjustEvent", "", "(Ljava/lang/String;)V")) { - jclass cls = methodInfo.env->FindClass("com/adjust/sdk/AdjustEvent"); - jmethodID init = methodInfo.env->GetMethodID(cls, "", "(Ljava/lang/String;)V"); - jstring jtoken = methodInfo.env->NewStringUTF(eventToken.c_str()); - event = methodInfo.env->NewObject(cls, init, jtoken); - } -} - -void AdjustEvent2dx::addCallbackParameter(std::string key, std::string value) { - cocos2d::JniMethodInfo methodInfo; - - if (NULL != event) { - if (cocos2d::JniHelper::getMethodInfo(methodInfo, "com/adjust/sdk/AdjustEvent", "addCallbackParameter", - "(Ljava/lang/String;Ljava/lang/String;)V")) { - jstring jkey = methodInfo.env->NewStringUTF(key.c_str()); - jstring jvalue = methodInfo.env->NewStringUTF(value.c_str()); - - methodInfo.env->CallVoidMethod(event, methodInfo.methodID, jkey, jvalue); - } - } -} - -void AdjustEvent2dx::addPartnerParameter(std::string key, std::string value) { - cocos2d::JniMethodInfo methodInfo; - - if (NULL != event) { - if (cocos2d::JniHelper::getMethodInfo(methodInfo, "com/adjust/sdk/AdjustEvent", "addPartnerParameter", - "(Ljava/lang/String;Ljava/lang/String;)V")) { - jstring jkey = methodInfo.env->NewStringUTF(key.c_str()); - jstring jvalue = methodInfo.env->NewStringUTF(value.c_str()); - - methodInfo.env->CallVoidMethod(event, methodInfo.methodID, jkey, jvalue); - } - } -} - -void AdjustEvent2dx::setRevenue(double amount, std::string currency) { - cocos2d::JniMethodInfo methodInfo; - - if (NULL != event) { - if (cocos2d::JniHelper::getMethodInfo(methodInfo, "com/adjust/sdk/AdjustEvent", "setRevenue", - "(DLjava/lang/String;)V")) { - jstring jcurrency = methodInfo.env->NewStringUTF(currency.c_str()); - - methodInfo.env->CallVoidMethod(event, methodInfo.methodID, amount, jcurrency); - } - } -} - -void AdjustEvent2dx::setTransactionId(std::string transactionId) { - cocos2d::JniMethodInfo methodInfo; - - if (NULL != event) { - if (cocos2d::JniHelper::getMethodInfo(methodInfo, "com/adjust/sdk/AdjustEvent", "setTransactionId", - "(Ljava/lang/String;)V")) { - jstring jtransactionId = methodInfo.env->NewStringUTF(transactionId.c_str()); - - methodInfo.env->CallVoidMethod(event, methodInfo.methodID, jtransactionId); - } - } -} - -void AdjustEvent2dx::setReceipt(std::string receipt, std::string transactionId) { - cocos2d::JniMethodInfo methodInfo; - - if (NULL != event) { - if (cocos2d::JniHelper::getMethodInfo(methodInfo, "com/adjust/sdk/AdjustEvent", "setReceipt", - "(Ljava/lang/String;Ljava/lang/String;)V")) { - jstring jreceipt = methodInfo.env->NewStringUTF(receipt.c_str()); - jstring jtransactionId = methodInfo.env->NewStringUTF(transactionId.c_str()); - - methodInfo.env->CallVoidMethod(event, methodInfo.methodID, jreceipt, jtransactionId); - } - } -} - -bool AdjustEvent2dx::isValid() { - cocos2d::JniMethodInfo methodInfo; - - if (NULL != event) { - if (cocos2d::JniHelper::getMethodInfo(methodInfo, "com/adjust/sdk/AdjustEvent", "isValid", "()Z")) { - jboolean jisValid = methodInfo.env->CallBooleanMethod(event, methodInfo.methodID); - - return jisValid; - } - } - - return false; -} - -jobject AdjustEvent2dx::getEvent() { - return event; -} diff --git a/Android/Adjust/AdjustEvent2dx.h b/Android/Adjust/AdjustEvent2dx.h deleted file mode 100644 index 7f30f354..00000000 --- a/Android/Adjust/AdjustEvent2dx.h +++ /dev/null @@ -1,33 +0,0 @@ -/* - * AdjustEvent2dx.h - * - * Created on: Jun 16, 2015 - * Author: uerceg - */ - -#ifndef ADJUST_ADJUSTEVENT2DX_H_ -#define ADJUST_ADJUSTEVENT2DX_H_ - -#include -#include - -class AdjustEvent2dx { -private: - jobject event; - void initEvent(std::string eventToken); - -public: - AdjustEvent2dx(std::string eventToken) { - initEvent(eventToken); - } - - void addCallbackParameter(std::string key, std::string value); - void addPartnerParameter(std::string key, std::string value); - void setRevenue(double amount, std::string currency); - void setTransactionId(std::string transactionId); - bool isValid(); - void setReceipt(std::string receipt, std::string transactionId); - jobject getEvent(); -}; - -#endif /* ADJUST_ADJUSTEVENT2DX_H_ */ diff --git a/Android/adjust-android.jar b/Android/adjust-android.jar index 3813f3d3..97e6b574 100644 Binary files a/Android/adjust-android.jar and b/Android/adjust-android.jar differ diff --git a/VERSION b/VERSION index 1454f6ed..ee74734a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -4.0.1 +4.1.0 diff --git a/doc/android/android.md b/doc/android/android.md index 729111fb..dffb6e05 100644 --- a/doc/android/android.md +++ b/doc/android/android.md @@ -14,7 +14,7 @@ archive into a directory of your choice. ### 2. Add adjust source files to your project -Take the files from the `Android/Adjust` folder and add them to your Android project. +Take the files from the `Adjust` folder and add them to your Android project. ![][add_android_files] @@ -60,7 +60,7 @@ these steps: the Android SDK directory. 4. After you've added the Google Play services library as a dependency for your app project, -open your app's manifest file and add the following tag as a child of the [][application] element: +open your app's manifest file and add the following tag as a child of the `manifest` element: ```xml ` element. -3. Add the attribute `android:name` and set it to the name of your new application class prefixed by a dot. - - In our example app we use an `Application` class named `GlobalApplication`, so the manifest file is configured as: - ```xml - - ... - - ``` - - ![][manifest_application] +```cpp +#include "Adjust/Adjust2dx.h" +// ... +std::string appToken = "{YourAppToken}"; +std::string environment = AdjustEnvironmentSandbox2dx; -In your `Application` class find or create the `onCreate` method and add the -following code to initialize the adjust SDK: +AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment); -```java -import com.adjust.sdk.Adjust; -import com.adjust.sdk.AdjustConfig; - -public class YourApplicationClass extends Application { - @Override - public void onCreate() { - super.onCreate(); - - String appToken = "{YourAppToken}"; - String environment = AdjustConfig.ENVIRONMENT_SANDBOX; - AdjustConfig config = new AdjustConfig(this, appToken, environment); - Adjust.onCreate(config); - } -} +Adjust2dx::start(adjustConfig); ``` -![][application_config] +![][add_adjust2dx] Replace `{YourAppToken}` with your app token. You can find this in your [dashboard]. @@ -163,16 +137,15 @@ Replace `{YourAppToken}` with your app token. You can find this in your Depending on whether you build your app for testing or for production, you must set `environment` with one of these values: -```java -String environment = AdjustConfig.ENVIRONMENT_SANDBOX; -String environment = AdjustConfig.ENVIRONMENT_PRODUCTION; +```cpp +std::string environment = AdjustEnvironmentSandbox2dx; +std::string environment = AdjustEnvironmentProduction2dx; ``` -**Important:** This value should be set to `AdjustConfig.ENVIRONMENT_SANDBOX` -if and only if you or someone else is testing your app. Make sure to set the -environment to `AdjustConfig.ENVIRONMENT_PRODUCTION` just before you publish -the app. Set it back to `AdjustConfig.ENVIRONMENT_SANDBOX` when you start -developing and testing it again. +**Important:** This value should be set to `AdjustEnvironmentSandbox2dx` if and only +if you or someone else is testing your app. Make sure to set the environment to +`AdjustEnvironmentProduction2dx` just before you publish the app. Set it back to +`AdjustEnvironmentSandbox2dx` when you start developing and testing it again. We use this environment to distinguish between real traffic and test traffic from test devices. It is very important that you keep this value meaningful at @@ -181,55 +154,54 @@ all times! This is especially important if you are tracking revenue. #### Adjust Logging You can increase or decrease the amount of logs you see in tests by calling -`setLogLevel` on your `AdjustConfig` instance with one of the following +`setLogLevel` on your `AdjustConfig2dx` instance with one of the following parameters: -```java -config.setLogLevel(LogLevel.VERBOSE); // enable all logging -config.setLogLevel(LogLevel.DEBUG); // enable more logging -config.setLogLevel(LogLevel.INFO); // the default -config.setLogLevel(LogLevel.WARN); // disable info logging -config.setLogLevel(LogLevel.ERROR); // disable warnings as well -config.setLogLevel(LogLevel.ASSERT); // disable errors as well +```cpp +adjustConfig.setLogLevel(AdjustLogLevel2dxVerbose); // enable all logging +adjustConfig.setLogLevel(AdjustLogLevel2dxDebug); // enable more logging +adjustConfig.setLogLevel(AdjustLogLevel2dxInfo); // the default +adjustConfig.setLogLevel(AdjustLogLevel2dxWarn); // disable info logging +adjustConfig.setLogLevel(AdjustLogLevel2dxError); // disable warnings as well +adjustConfig.setLogLevel(AdjustLogLevel2dxAssert); // disable errors as well ``` -### 9. Update your activities +### 9. Session tracking To provide proper session tracking it is required to call certain Adjust -methods every time any Activity resumes or pauses. Otherwise the SDK might miss -a session start or session end. In order to do so you should follow these steps -for **each** Activity of your app: +methods every time app goes to background or comes to foreground. Otherwise the SDK +might miss a session start or session end. In order to do so you should follow these steps: -1. Open the source file of your Activity. -2. Add the `import` statement at the top of the file. -3. In your Activity's `onResume` method call `Adjust.onResume`. Create the - method if needed. -4. In your Activity's `onPause` method call `Adjust.onPause`. Create the method - if needed. +1. Open the app delegate file. +2. Add call to `onResume` method in `applicationWillEnterForeground` method. +3. Add call to `onPause` method in `applicationDidEnterBackground` method. -After these steps your activity should look like this: +After these steps your app delegate should look like this: -```java -import com.adjust.sdk.Adjust; +```cpp +#include "Adjust/Adjust2dx.h" // ... -public class YourActivity extends Cocos2dxActivity { - protected void onResume() { - super.onResume(); - Adjust.onResume(); - } - protected void onPause() { - super.onPause(); - Adjust.onPause(); - } + +void AppDelegate::applicationDidEnterBackground() { // ... + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Adjust2dx::onPause(); +#endif } -``` -![][activity] +void AppDelegate::applicationWillEnterForeground() { + // ... -Repeat these steps for **every** Activity of your app. Don't forget these steps -when you create new Activities in the future. Depending on your coding style -you might want to implement this in a common superclass of all your Activities. +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Adjust2dx::onResume(); +#endif +} + +// ... +``` + +![][on_resume_on_pause] ### 10. Build your app @@ -239,12 +211,12 @@ the following Adjust log: `Install tracked` ![][log_message] -## Additional Features +## Additional features -Once you have integrated the adjust SDK into your project, you can take -advantage of the following features. +Once you integrate the adjust SDK into your project, you can take advantage of +the following features. -### 11. Add tracking of custom events +### 11. Set up event tracking You can use adjust to track events. You would create a new event token in your [dashboard], which has an associated event token - looking something like `abc123`. In your @@ -255,12 +227,15 @@ AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); Adjust2dx::trackEvent(adjustEvent); ``` -The event instance can be used to configure the event even more before tracking it. +When this event is triggered, you should see `Event tracked` in the logs. + +The event instance can be used to configure the event further before tracking +it. -#### Add tracking of revenue +#### Track revenue If your users can generate revenue by tapping on advertisements or making -in-app purchases you can track those revenues with events. Let's say a tap is +in-app purchases, then you can track those revenues with events. Let's say a tap is worth one Euro cent. You could then track the revenue event like this: ```cpp @@ -269,78 +244,72 @@ adjustEvent.setRevenue(0.01, "EUR"); Adjust2dx::trackEvent(adjustEvent); ``` -This can of course be combined with callback parameters. +This can be combined with callback parameters of course. -When you set a currency token, adjust will automatically convert the incoming revenues into -a reporting revenue of your choice. Read more about [currency conversion here.][currency-conversion] +When you set a currency token, adjust will automatically convert the incoming revenues into a reporting +revenue of your choice. Read more about [currency conversion here.][currency-conversion] -You can read more about revenue and event tracking in the [event tracking -guide.][event-tracking] +You can read more about revenue and event tracking in the [event tracking guide.][event-tracking] #### Add callback parameters You can register a callback URL for your events in your [dashboard]. We will send a GET request to that URL whenever the event is tracked. You can add callback parameters to that event by calling `addCallbackParameter` on the -event instance before tracking it. We will then append these parameters to your -callback URL. +event before tracking it. We will then append these parameters to your callback +URL. For example, suppose you have registered the URL `http://www.adjust.com/callback` then track an event like this: ```cpp AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); - adjustEvent.addCallbackParameter("key", "value"); adjustEvent.addCallbackParameter("foo", "bar"); - Adjust2dx::trackEvent(adjustEvent); ``` In that case we would track the event and send a request to: -``` -http://www.adjust.com/callback?key=value&foo=bar -``` + http://www.adjust.com/callback?key=value&foo=bar -It should be mentioned that we support a variety of placeholders like -`{android_id}` that can be used as parameter values. In the resulting callback -this placeholder would be replaced with the AndroidID 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. +It should be mentioned that we support a variety of placeholders like `{android_id}`, which can be used as parameter values. In the resulting callback this placeholder would be replaced with the AndroidID 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. You can read more about using URL callbacks, including a full list of available values, in our [callbacks guide][callbacks-guide]. #### Partner parameters -You can also add parameters to be transmitted to network partners, for the +You can also add parameters to be transmitted to network partners for integrations that have been activated in your adjust dashboard. -This works similarly to the callback parameters mentioned above, but can be -added by calling the `addPartnerParameter` method on your `AdjustEvent2dx` instance. +This works similarly to the callback parameters mentioned above, but can +be added by calling the `addPartnerParameter` method on your `AdjustEvent2dx` +instance. ```cpp AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); - -adjustEvent.addPartnerParameter("key", "value"); adjustEvent.addPartnerParameter("foo", "bar"); - Adjust2dx::trackEvent(adjustEvent); ``` -You can read more about special partners and these integrations in our [guide -to special partners.][special-partners] +You can read more about special partners and these integrations in our +[guide to special partners.][special-partners] ### 12. Set up deep link reattributions You can set up the adjust SDK to handle deep links that are used to open your -app. We will only read certain adjust specific parameters. This is essential if -you are planning to run retargeting or re-engagement campaigns with deep links. +app via a custom URL scheme. We will only read certain adjust specific +parameters. This is essential if you are planning to run retargeting or +re-engagement campaigns with deep links. + +For each activity that accepts deep links, find the `onCreate` or `onNewIntent` +method and add the following call to adjust: -For each activity that accepts deep links, find the `onCreate` method and add -the following call to adjust: +##### For activities with `standard` launch mode ```java protected void onCreate(Bundle savedInstanceState) { @@ -349,79 +318,82 @@ protected void onCreate(Bundle savedInstanceState) { Intent intent = getIntent(); Uri data = intent.getData(); Adjust.appWillOpenUrl(data); - //... + // ... } ``` +##### For activities with `singleTop` launch mode + +```java +protected void onNewIntent(Intent intent) { + super.onNewIntent(intent); + + Uri data = intent.getData(); + Adjust.appWillOpenUrl(data); + // ... +} +``` + +You can read more about activity launch mode on this [page][google-launch-modes]. You can read more about [deeplinking in our docs][deeplinking]. ### 13. Enable event buffering If your app makes heavy use of event tracking, you might want to delay some HTTP requests in order to send them in one batch every minute. You can enable -event buffering with your `AdjustConfig` instance: - -```java -AdjustConfig config = new AdjustConfig(this, appToken, environment); - -config.setEventBufferingEnabled(true); +event buffering with your `AdjustConfig2dx` instance: -Adjust.onCreate(config); +```cpp +adjustConfig.setEventBufferingEnabled(true); ``` -### 14. Set listener for attribution changes +### 14. Implement the attribution callback -You can register a listener to be notified of tracker attribution changes. Due -to the different sources considered for attribution, this information can not -by provided synchronously. The simplest way is to create a single anonymous -listener: +You can register a delegate callback to be notified of tracker attribution +changes. Due to the different sources considered for attribution, this +information can not be provided synchronously. Follow these steps to implement +the optional delegate protocol in your app delegate: Please make sure to consider our [applicable attribution data -policies][attribution-data]. - -With the `AdjustConfig` instance, before starting the SDK, add the anonymous listener: +policies.][attribution-data] -```java -AdjustConfig config = new AdjustConfig(this, appToken, environment); +1. Open `AppDelegate.cpp` and add the following delegate callback function to + your app delegate implementation. -config.setOnAttributionChangedListener(new OnAttributionChangedListener() { - @Override - public void onAttributionChanged(AdjustAttribution attribution) { + ```cpp + void attributionCallbackMethod(AdjustAttribution2dx attribution) { } -}); - -Adjust.onCreate(config); -``` - -Alternatively, you could implement the `OnAttributionChangedListener` -interface in your `Application` class and set it as listener: - -```java -AdjustConfig config = new AdjustConfig(this, appToken, environment); -config.setOnAttributionChangedListener(this); -Adjust.onCreate(config); -``` + ``` -The listener function will be called when the SDK receives the final attribution -information. Within the listener function you have access to the `attribution` -parameter. Here is a quick summary of its properties: +2. Set the delegate with your `AdjustConfig2dx` instance: -- `String trackerToken` the tracker token of the current install. -- `String trackerName` the tracker name of the current install. -- `String network` the network grouping level of the current install. -- `String campaign` the campaign grouping level of the current install. -- `String adgroup` the ad group grouping level of the current install. -- `String creative` the creative grouping level of the current install. -- `String clickLabel` the click label of the current install. + ```cpp + adjustConfig.setAttributionCallback(attributionCallbackMethod); + ``` + +As the delegate callback is configured using the `AdjustConfig2dx` instance, you +should call `setAttributionCallback` before calling `Adjust2dx::start(adjustConfig)`. + +The delegate function will be called when the SDK receives final attribution data. +Within the delegate function you have access to the `attribution` parameter. +Here is a quick summary of its properties: + +- `std::string trackerToken` the tracker token of the current install. +- `std::string trackerName` the tracker name of the current install. +- `std::string network` the network grouping level of the current install. +- `std::string campaign` the campaign grouping level of the current install. +- `std::string adgroup` the ad group grouping level of the current install. +- `std::string creative` the creative grouping level of the current install. +- `std::string clickLabel` the click label of the current install. ### 15. Disable tracking You can disable the adjust SDK from tracking any activities of the current -device by calling `setEnabled` with parameter `false`. This setting is -remembered between sessions. +device by calling `setEnabled` with parameter `false`. This setting is remembered +between sessions, but it can only be activated after the first session. -```java -Adjust.setEnabled(false); +```objc +Adjust2dx::setEnabled(false); ``` You can check if the adjust SDK is currently enabled by calling the function @@ -430,14 +402,13 @@ You can check if the adjust SDK is currently enabled by calling the function ### 16. Offline mode -You can put the adjust SDK in offline mode to suspend transmission to our servers, -while retaining tracked data to be sent later. While in offline mode, all information is saved +You can put the adjust SDK in offline mode to suspend transmission to our servers while retaining tracked data to be sent later. While in offline mode, all information is saved in a file, so be careful not to trigger too many events while in offline mode. You can activate offline mode by calling `setOfflineMode` with the parameter `true`. -```java -Adjust.setOfflineMode(true); +```objc +Adjust2dx::setOfflineMode(true); ``` Conversely, you can deactivate offline mode by calling `setOfflineMode` with `false`. @@ -450,19 +421,18 @@ even if the app was terminated in offline mode. [dashboard]: http://adjust.com [releases]: https://github.com/adjust/cocos2dx_sdk/releases -[add_android_files]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/add_android_files.png -[add_android_jar]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/add_android_jar.png -[add_to_android_mk]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/add_to_android_mk.png -[manifest_permissions]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/manifest_permissions.png -[receiver]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/receiver.png -[application_class]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/application_class.png -[manifest_application]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/manifest_application.png -[application_config]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/application_config.png -[activity]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/activity.png -[log_message]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/log_message.png +[add_android_files]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/4.1.0/add_android_files.png +[add_android_jar]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/4.1.0/add_android_jar.png +[add_to_android_mk]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/4.1.0/add_to_android_mk.png +[manifest_permissions]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/4.1.0/manifest_permissions.png +[receiver]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/4.1.0/receiver.png +[add_adjust2dx]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/4.1.0/add_adjust2dx.png +[on_resume_on_pause]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/4.1.0/on_resume_on_pause.png +[log_message]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/android/4.1.0/log_message.png [referrer]: https://github.com/adjust/android_sdk/blob/master/doc/referrer.md [attribution-data]: https://github.com/adjust/sdks/blob/master/doc/attribution-data.md +[eclipse_library]: http://developer.android.com/tools/projects/projects-eclipse.html#ReferencingLibraryProject [google_play_services]: http://developer.android.com/google/play-services/setup.html [android_application]: http://developer.android.com/reference/android/app/Application.html [application_name]: http://developer.android.com/guide/topics/manifest/application-element.html#nm @@ -474,7 +444,8 @@ even if the app was terminated in offline mode. [maven]: http://maven.org [example]: https://github.com/adjust/android_sdk/tree/master/Adjust/example [currency-conversion]: https://docs.adjust.com/en/event-tracking/#tracking-purchases-in-different-currencies -[deeplinking]: https://docs.adjust.com/en/tracker-generation/#deeplinking +[deeplinking]: https://docs.adjust.com/en/tracker-generation/#deeplinking +[google-launch-modes]: http://developer.android.com/guide/topics/manifest/activity-element.html#lmode ## License diff --git a/doc/ios/ios.md b/doc/ios/ios.md index c3e18b71..df7c95e2 100644 --- a/doc/ios/ios.md +++ b/doc/ios/ios.md @@ -14,7 +14,7 @@ archive into a directory of your choice. ### 2. Add adjust source files to your solution -Take the files from the `iOS/Adjust` folder and add them to your iOS project. +Take the files from the `Adjust` folder and add them to your iOS project. ![][add_ios_files] @@ -29,9 +29,9 @@ the `AdSupport.framework` and `iAd.framework`. ### 4. Add additional linker flags -If you are not using `Objective-C Automatic Reference Counting`, you should add two additional linker flags. +In order to support categories from `Adjust.framework`, you should add an additional linker flag. Go to the `Build Settings` part of Project Settings and look for `Other Linker Flags` option. -Add `-fobjc-arc` and `-ObjC` flags to it. +Add `-ObjC` flag to it. ![][add_other_linker_flags] @@ -39,16 +39,17 @@ Add `-fobjc-arc` and `-ObjC` flags to it. In the Project Navigator, open the source file of your application delegate. Add the import statement at the top of the file, then add the following call to -Adjust in the applicationDidFinishLaunching of your app delegate: +Adjust in the `applicationDidFinishLaunching` of your app delegate: ```cpp -#include "Adjust2dx.h" +#include "Adjust/Adjust2dx.h" // ... -std::string yourAppToken = "{YourAppToken}"; -std::string environment = ADJEnvironmentSandbox2dx; +std::string appToken = "{YourAppToken}"; +std::string environment = AdjustEnvironmentSandbox2dx; -ADJConfig2dx adjustConfig = ADJConfig2dx(yourAppToken, environment); -Adjust2dx::appDidLaunch(adjustConfig); +AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment); + +Adjust2dx::start(adjustConfig); ``` ![][add_adjust2dx] @@ -60,14 +61,14 @@ Depending on whether you build your app for testing or for production, you must set `environment` with one of these values: ```cpp -std::string environment = ADJEnvironmentSandbox2dx; -std::string environment = ADJEnvironmentProduction2dx; +std::string environment = AdjustEnvironmentSandbox2dx; +std::string environment = AdjustEnvironmentProduction2dx; ``` -**Important:** This value should be set to `ADJEnvironmentSandbox2dx` if and only +**Important:** This value should be set to `AdjustEnvironmentSandbox2dx` if and only if you or someone else is testing your app. Make sure to set the environment to -`ADJEnvironmentProduction2dx` just before you publish the app. Set it back to -`ADJEnvironmentSandbox2dx` when you start developing and testing it again. +`AdjustEnvironmentProduction2dx` just before you publish the app. Set it back to +`AdjustEnvironmentSandbox2dx` when you start developing and testing it again. We use this environment to distinguish between real traffic and test traffic from test devices. It is very important that you keep this value meaningful at @@ -76,16 +77,16 @@ all times! This is especially important if you are tracking revenue. #### Adjust Logging You can increase or decrease the amount of logs you see in tests by calling -`setLogLevel` on your `ADJConfig2dx` instance with one of the following +`setLogLevel` on your `AdjustConfig2dx` instance with one of the following parameters: ```cpp -adjustConfig.setLogLevel(ADJLogLevel2dxVerbose); // enable all logging -adjustConfig.setLogLevel(ADJLogLevel2dxDebug); // enable more logging -adjustConfig.setLogLevel(ADJLogLevel2dxInfo); // the default -adjustConfig.setLogLevel(ADJLogLevel2dxWarn); // disable info logging -adjustConfig.setLogLevel(ADJLogLevel2dxError); // disable warnings as well -adjustConfig.setLogLevel(ADJLogLevel2dxAssert); // disable errors as well +adjustConfig.setLogLevel(AdjustLogLevel2dxVerbose); // enable all logging +adjustConfig.setLogLevel(AdjustLogLevel2dxDebug); // enable more logging +adjustConfig.setLogLevel(AdjustLogLevel2dxInfo); // the default +adjustConfig.setLogLevel(AdjustLogLevel2dxWarn); // disable info logging +adjustConfig.setLogLevel(AdjustLogLevel2dxError); // disable warnings as well +adjustConfig.setLogLevel(AdjustLogLevel2dxAssert); // disable errors as well ``` ### 5. Build your app @@ -104,11 +105,11 @@ the following features. ### 6. Set up event tracking You can use adjust to track events. You would create a new event token in your [dashboard], -which has an associated event token - looking something like `abc123`. In your -game you would then add the following lines to track the event you are interested in: +which has an associated event token - something like `abc123`. In your +game, you would then add the following lines to track the event you are interested in: ```cpp -ADJEvent2dx adjustEvent = ADJEvent2dx("abc123"); +AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); Adjust2dx::trackEvent(adjustEvent); ``` @@ -120,11 +121,11 @@ it. #### Track revenue If your users can generate revenue by tapping on advertisements or making -in-app purchases you can track those revenues with events. Lets say a tap is +in-app purchases, you can track those revenues with events. Let's say a tap is worth one Euro cent. You could then track the revenue event like this: ```cpp -ADJEvent2dx adjustEvent = ADJEvent2dx("abc123"); +AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); adjustEvent.setRevenue(0.01, "EUR"); Adjust2dx::trackEvent(adjustEvent); ``` @@ -136,10 +137,40 @@ revenue of your choice. Read more about [currency conversion here.][currency-con You can read more about revenue and event tracking in the [event tracking guide.][event-tracking] +##### Revenue deduplication + +You can also pass in an optional transaction ID to avoid tracking duplicate revenues. The last ten transaction +IDs are remembered and revenue events with duplicate transaction IDs are skipped. This is especially useful for +in-app purchase tracking. See an example below. + +If you want to track in-app purchases, please make sure to call `trackEvent` only if the transaction is finished +and item is purchased. That way you can avoid tracking revenue that is not actually being generated. + +```cpp +AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); +adjustEvent.setRevenue(0.01, "EUR"); +adjustEvent.setTransactionId("transactionID"); +Adjust2dx::trackEvent(adjustEvent); +``` + +##### Receipt verification + +If you track in-app purchases, you can also attach the receipt to the tracked event. In that case, our servers +will verify that receipt with Apple and discard the event if the verification failed. To make this work, you +also need to send us the transaction ID of the purchase. The transaction ID will also be used for SDK side +deduplication as explained [above](#deduplication): + +```cpp +AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); +adjustEvent.setRevenue(0.01, "EUR"); +adjustEvent.setReceipt("receipt", "transactionID"); +Adjust2dx::trackEvent(adjustEvent); +``` + #### Add callback parameters You can register a callback URL for your events in your [dashboard]. We will -send a GET request to that URL whenever the event gets tracked. You can add +send a GET request to that URL whenever the event is tracked. You can add callback parameters to that event by calling `addCallbackParameter` on the event before tracking it. We will then append these parameters to your callback URL. @@ -148,13 +179,13 @@ For example, suppose you have registered the URL `http://www.adjust.com/callback` then track an event like this: ```cpp -ADJEvent2dx adjustEvent = ADJEvent2dx("abc123"); +AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); adjustEvent.addCallbackParameter("key", "value"); adjustEvent.addCallbackParameter("foo", "bar"); Adjust2dx::trackEvent(adjustEvent); ``` -In that case we would track the event and send a request to: +In that case, we would track the event and send a request to: http://www.adjust.com/callback?key=value&foo=bar @@ -174,11 +205,11 @@ You can also add parameters to be transmitted to network partners, for the integrations that have been activated in your adjust dashboard. This works similarly to the callback parameters mentioned above, but can -be added by calling the `addPartnerParameter` method on your `ADJEvent2dx` +be added by calling the `addPartnerParameter` method on your `AdjustEvent2dx` instance. ```cpp -ADJEvent2dx adjustEvent = ADJEvent2dx("abc123"); +AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); adjustEvent.addPartnerParameter("foo", "bar"); Adjust2dx::trackEvent(adjustEvent); ``` @@ -188,18 +219,22 @@ You can read more about special partners and these integrations in our ### 7. Set up deep link reattributions -You can set up the adjust SDK to handle deep links that are used to open your +You can set up the adjust SDK to handle deep links used to open your app via a custom URL scheme. We will only read certain adjust specific parameters. This is essential if you are planning to run retargeting or re-engagement campaigns with deep links. -In the Project Navigator open the source file of your App Controller. Find -or add the method `openURL` and add the following call to adjust: +In the Project Navigator open the source file of your iOS App Controller. Find +or add the method `openURL` and add __one__ of the following calls to adjust: ```objc - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { + // Like it was in previous versions: [Adjust appWillOpenUrl:url]; + + // OR use new C++ interface: + Adjust2dx::appWillOpenUrl(url); return YES; } @@ -211,7 +246,7 @@ You can read more about [deeplinking in our docs][deeplinking]. If your app makes heavy use of event tracking, you might want to delay some HTTP requests in order to send them in one batch every minute. You can enable -event buffering with your `ADJConfig2dx` instance: +event buffering with your `AdjustConfig2dx` instance: ```cpp adjustConfig.setEventBufferingEnabled(true); @@ -221,7 +256,7 @@ adjustConfig.setEventBufferingEnabled(true); You can register a delegate callback to be notified of tracker attribution changes. Due to the different sources considered for attribution, this -information can not be provided synchronously. Follow these steps to implement +information cannot be provided synchronously. Follow these steps to implement the optional delegate protocol in your app delegate: Please make sure to consider our [applicable attribution data @@ -231,18 +266,18 @@ policies.][attribution-data] your app delegate implementation. ```cpp - void attributionCallbackMethod(ADJAttribution2dx attribution) { + void attributionCallbackMethod(AdjustAttribution2dx attribution) { } ``` -2. Set the delegate with your `ADJConfig2dx` instance: +2. Set the delegate with your `AdjustConfig2dx` instance: ```cpp adjustConfig.setAttributionCallback(attributionCallbackMethod); ``` -As the delegate callback is configured using the `ADJConfig2dx` instance, you -should call `setAttributionCallback` before calling `Adjust2dx::appDidLaunch(adjustConfig)`. +As the delegate callback is configured using the `AdjustConfig2dx` instance, you +should call `setAttributionCallback` before calling `Adjust2dx::start(adjustConfig)`. The delegate function will be called when the SDK receives final attribution data. Within the delegate function you have access to the `attribution` parameter. @@ -293,14 +328,40 @@ even if the app was terminated in offline mode. [adjust.com]: http://adjust.com [dashboard]: http://adjust.com [releases]: https://github.com/adjust/cocos2dx_sdk/releases -[add_ios_files]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/add_ios_files.png -[add_the_frameworks]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/add_the_frameworks.png -[add_other_linker_flags]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/add_other_linker_flags.png -[add_adjust2dx]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/add_adjust2dx.png -[run]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/run.png +[add_ios_files]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/4.1.0/add_ios_files.png +[add_the_frameworks]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/4.1.0/add_the_frameworks.png +[add_other_linker_flags]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/4.1.0/add_other_linker_flags.png +[add_adjust2dx]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/4.1.0/add_adjust2dx.png +[run]: https://raw.github.com/adjust/sdks/master/Resources/cocos2dx/ios/4.1.0/run.png [attribution-data]: https://github.com/adjust/sdks/blob/master/doc/attribution-data.md [callbacks-guide]: https://docs.adjust.com/en/callbacks [event-tracking]: https://docs.adjust.com/en/event-tracking [special-partners]: https://docs.adjust.com/en/special-partners [currency-conversion]: https://docs.adjust.com/en/event-tracking/#tracking-purchases-in-different-currencies [deeplinking]: https://docs.adjust.com/en/tracker-generation/#deeplinking + +## License + +The adjust SDK is licensed under the MIT License. + +Copyright (c) 2012-2015 adjust GmbH, +http://www.adjust.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. + diff --git a/doc/migrate.md b/doc/migrate.md new file mode 100644 index 00000000..61d10a9c --- /dev/null +++ b/doc/migrate.md @@ -0,0 +1,200 @@ +## Migrate your adjust SDK for Cocos2d-x to 4.1.0 from 4.0.x + +### SDK initialization + +We have changed the API in comparison with 4.0.x versions, as well as some of the class names. +We also changed how you configure and start the adjust SDK. + +Here is an example of how the setup might look before and after the migration: + +#### iOS + +##### Before: + +```cpp +#include "Adjust2dx.h" +// ... +ADJConfig2dx adjustConfig = ADJConfig2dx(yourAppToken, environment); +``` + +##### After: + +```cpp +#include "Adjust/Adjust2dx.h" +// ... +AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment); +``` + +#### Android + +There is no longer a need for you to initialize and start our SDK using Java code. You can now use C++ code. + +##### Before: + +```java +import com.adjust.sdk.Adjust; +import com.adjust.sdk.AdjustConfig; + +public class YourApplicationClass extends Application { + @Override + public void onCreate() { + super.onCreate(); + + String appToken = "{YourAppToken}"; + String environment = AdjustConfig.ENVIRONMENT_SANDBOX; + AdjustConfig config = new AdjustConfig(this, appToken, environment); + Adjust.onCreate(config); + } +} +``` + +##### After: + +```cpp +#include "Adjust/Adjust2dx.h" +// ... +std::string appToken = "{YourAppToken}"; +std::string environment = AdjustEnvironmentSandbox2dx; + +AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment); + +Adjust2dx::start(adjustConfig); +``` + +### Event tracking + +Again, an example of how it might look like before and after: + +#### iOS + +##### Before: + +```cpp +ADJEvent2dx adjustEvent = ADJEvent2dx("abc123"); +// ... +``` + +##### After: + +```cpp +AdjustEvent2dx adjustEvent = AdjustEvent2dx("abc123"); +// ... +``` + +### Session tracking + +#### Android + +Previously, you needed to update each activity with calls to `Adjust.onResume()` and `Adjust.onPause()`. + +Not anymore. All you need to do now is to update the `applicationDidEnterBackground` and +`applicationWillEnterForeground` methods in your app delegate. + +##### Before: + +```java +import com.adjust.sdk.Adjust; +// ... +public class YourActivity extends Cocos2dxActivity { + protected void onResume() { + super.onResume(); + Adjust.onResume(); + } + protected void onPause() { + super.onPause(); + Adjust.onPause(); + } + // ... +} +``` + +##### After: + +```cpp +#include "Adjust/Adjust2dx.h" +// ... + +void AppDelegate::applicationDidEnterBackground() { + // ... + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Adjust2dx::onPause(); +#endif +} + +void AppDelegate::applicationWillEnterForeground() { + // ... + +#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID) + Adjust2dx::onResume(); +#endif +} + +// ... +``` + +### Implement the attribution callback + +#### Android + +Since the SDK initialization was done in Java code, attribution callbacks had to be implemented in Java as well. Now, you can do everything in C++ code. + +##### Before: + +```java +AdjustConfig config = new AdjustConfig(this, appToken, environment); + +config.setOnAttributionChangedListener(new OnAttributionChangedListener() { + @Override + public void onAttributionChanged(AdjustAttribution attribution) { + } +}); + +Adjust.onCreate(config); +``` + +##### After: + +```cpp +void attributionCallbackMethod(AdjustAttribution2dx attribution) { +} + +// ... + +AdjustConfig2dx adjustConfig = AdjustConfig2dx(appToken, environment); +adjustConfig.setAttributionCallback(attributionCallbackMethod); +Adjust2dx::start(adjustConfig); +``` + +### Set up deep link reattributions + +#### iOS + +Instead of opening a URL directly from Objective-C, we now offer a C++ interface for you to do this. +Both are functional and you can choose one from those two methods. + +##### Objective-C code + +Scenario used so far: + +```objc +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url + sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { + [Adjust appWillOpenUrl:url]; + + return YES; +} +``` + +##### C++ code + +Newly offered scenario: + +```objc +- (BOOL)application:(UIApplication *)application openURL:(NSURL *)url + sourceApplication:(NSString *)sourceApplication annotation:(id)annotation { + Adjust2dx::appWillOpenUrl(url); + + return YES; +} +``` diff --git a/ext/Android/Makefile b/ext/Android/Makefile index 08406f35..06066296 100644 --- a/ext/Android/Makefile +++ b/ext/Android/Makefile @@ -1,6 +1,10 @@ MVNDIR = ./sdk/Adjust JARINDIR = ./sdk/Adjust/target JAROUTDIR = ../../Android +PROXYDIR = ./proxy +JAR = $(JAVA_6_PATH)/bin/jar +JAVAC = $(JAVA_6_PATH)/bin/javac +VERSION = $(shell cat ./sdk/VERSION) default: copy @@ -11,8 +15,9 @@ clean: cd $(MVNDIR); mvn clean copy: build - rm $(JAROUTDIR)/adjust-android*; \ - cp $(JARINDIR)/adjust-android-*.*.*.jar $(JAROUTDIR); \ - rm $(JAROUTDIR)/*-javadoc.jar; \ - rm $(JAROUTDIR)/*-sources.jar; \ - mv $(JAROUTDIR)/adjust-android-*.*.*.jar $(JAROUTDIR)/adjust-android.jar + cp $(JARINDIR)/adjust-android-$(VERSION).jar $(PROXYDIR); \ + mv $(PROXYDIR)/adjust-android-$(VERSION).jar $(PROXYDIR)/adjust-android.jar; cd $(PROXYDIR); \ + $(JAVAC) -cp adjust-android.jar com/adjust/sdk/*.java; \ + $(JAR) uf adjust-android.jar com/adjust/sdk/*.class; cd ..; \ + mv $(PROXYDIR)/adjust-android.jar $(JAROUTDIR)/adjust-android.jar; \ + rm $(PROXYDIR)/com/adjust/sdk/*.class; diff --git a/ext/Android/proxy/com/adjust/sdk/Adjust2dxAttributionCallback.java b/ext/Android/proxy/com/adjust/sdk/Adjust2dxAttributionCallback.java new file mode 100644 index 00000000..ea30567f --- /dev/null +++ b/ext/Android/proxy/com/adjust/sdk/Adjust2dxAttributionCallback.java @@ -0,0 +1,12 @@ +package com.adjust.sdk; + +public class Adjust2dxAttributionCallback implements OnAttributionChangedListener { + public native void attributionChanged(Object attributionString); + + public Adjust2dxAttributionCallback() {} + + @Override + public void onAttributionChanged(AdjustAttribution attribution) { + attributionChanged(attribution); + } +} diff --git a/ext/Android/sdk b/ext/Android/sdk index 9cff8af2..cf544efb 160000 --- a/ext/Android/sdk +++ b/ext/Android/sdk @@ -1 +1 @@ -Subproject commit 9cff8af2ddbb2c4e8e4bc0cbe16ef3f7a92d33dc +Subproject commit cf544efb2f8193e05b358532f62eb842ae212731 diff --git a/ext/iOS/sdk b/ext/iOS/sdk index 59f650ff..6c9d22b5 160000 --- a/ext/iOS/sdk +++ b/ext/iOS/sdk @@ -1 +1 @@ -Subproject commit 59f650ffaca42a6c2102d8dd891603201ab7e728 +Subproject commit 6c9d22b51f0622c07eb9f7a9df8a57580edcad55 diff --git a/iOS/Adjust.framework/Versions/A/Adjust b/iOS/Adjust.framework/Versions/A/Adjust index 4cd7b3ec..f5755f63 100644 Binary files a/iOS/Adjust.framework/Versions/A/Adjust and b/iOS/Adjust.framework/Versions/A/Adjust differ diff --git a/iOS/Adjust.framework/Versions/A/Headers/ADJConfig.h b/iOS/Adjust.framework/Versions/A/Headers/ADJConfig.h index 07a395f3..c23e227e 100644 --- a/iOS/Adjust.framework/Versions/A/Headers/ADJConfig.h +++ b/iOS/Adjust.framework/Versions/A/Headers/ADJConfig.h @@ -88,7 +88,7 @@ * @param delegate The delegate that might implement the optional delegate * methods like adjustAttributionChanged: */ -@property (nonatomic, retain) NSObject *delegate; +@property (nonatomic, weak) NSObject *delegate; @property (nonatomic, assign) BOOL hasDelegate; - (BOOL) isValid; diff --git a/iOS/Adjust/ADJAttribution2dx.mm b/iOS/Adjust/ADJAttribution2dx.mm deleted file mode 100644 index b6292e8b..00000000 --- a/iOS/Adjust/ADJAttribution2dx.mm +++ /dev/null @@ -1,37 +0,0 @@ -// -// ADJAttribution2dx.mm -// AdjustDemo -// -// Created by Uglješa Erceg on 17/06/15. -// -// - -#include "ADJAttribution2dx.h" - -std::string ADJAttribution2dx::getTrackerToken() { - return this->trackerToken; -} - -std::string ADJAttribution2dx::getTrackerName() { - return this->trackerName; -} - -std::string ADJAttribution2dx::getNetwork() { - return this->network; -} - -std::string ADJAttribution2dx::getCampaign() { - return this->campaign; -} - -std::string ADJAttribution2dx::getAdgroup() { - return this->adgroup; -} - -std::string ADJAttribution2dx::getCreative() { - return this->creative; -} - -std::string ADJAttribution2dx::getClickLabel() { - return this->clickLabel; -} \ No newline at end of file diff --git a/iOS/Adjust/ADJConfig2dx.h b/iOS/Adjust/ADJConfig2dx.h deleted file mode 100644 index c6c853ff..00000000 --- a/iOS/Adjust/ADJConfig2dx.h +++ /dev/null @@ -1,59 +0,0 @@ -// -// ADJConfig2dx.h -// AdjustDemo -// -// Created by Uglješa Erceg on 17/06/15. -// -// - -#ifndef __AdjustDemo__ADJConfig2dx__ -#define __AdjustDemo__ADJConfig2dx__ - -#include -#include "ADJAttribution2dx.h" - -enum ADJLogLevel2dx { - ADJLogLevel2dxVerbose = 1, - ADJLogLevel2dxDebug = 2, - ADJLogLevel2dxInfo = 3, - ADJLogLevel2dxWarn = 4, - ADJLogLevel2dxError = 5, - ADJLogLevel2dxAssert = 6 }; - -class ADJConfig2dx { -private: - void* config; - void (*callback)(ADJAttribution2dx attribution); - void initConfig(std::string appToken, std::string environment); - -public: - ADJConfig2dx() {} - ADJConfig2dx(std::string appToken, std::string environment) { - initConfig(appToken, environment); - } - - std::string getAppToken(); - - void setLogLevel(ADJLogLevel2dx logLevel); - ADJLogLevel2dx getLogLevel(); - - std::string getEnvironment(); - - void setSdkPrefix(std::string sdkPrefix); - std::string getSdkPrefix(); - - void setDefaultTracker(std::string defaultTracker); - std::string getDefaultTracker(); - - void setEventBufferingEnabled(bool isEnabled); - bool getEventBufferingEnabled(); - - void setMacMd5TrackingEnabled(bool isEnabled); - bool getMacMd5TrackingEnabled(); - - void setAttributionCallback(void (*callbackMethod)(ADJAttribution2dx attribution)); - - void* getConfig(); -}; - -#endif /* defined(__AdjustDemo__ADJConfig2dx__) */