Skip to content

Commit

Permalink
Merge pull request #33 from adjust/v4180
Browse files Browse the repository at this point in the history
Version 4.18.0
  • Loading branch information
uerceg authored Jul 4, 2019
2 parents 65321eb + c2e8ba5 commit 774f13d
Show file tree
Hide file tree
Showing 35 changed files with 200 additions and 60 deletions.
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
### Version 4.18.0 (4th July 2019)
#### Added
- Added `trackAdRevenue` method to `Adjust2dx` interface to allow tracking of ad revenue. With this release added support for `MoPub` ad revenue tracking.
- Added reading of Facebook anonymous ID if available on iOS platform.

#### Native SDKs
- [iOS@v4.18.0][ios_sdk_v4.18.0]
- [Android@v4.18.0][android_sdk_v4.18.0]

---

### Version 4.17.1 (22nd March 2019)
#### Added
- Added support for `Cocos2d-x v2.2.6`.
Expand Down Expand Up @@ -279,6 +290,7 @@
[ios_sdk_v4.14.1]: https://github.com/adjust/ios_sdk/tree/v4.14.1
[ios_sdk_v4.17.1]: https://github.com/adjust/ios_sdk/tree/v4.17.1
[ios_sdk_v4.17.2]: https://github.com/adjust/ios_sdk/tree/v4.17.2
[ios_sdk_v4.18.0]: https://github.com/adjust/ios_sdk/tree/v4.18.0

[android_sdk_v4.0.8]: https://github.com/adjust/android_sdk/tree/v4.0.8
[android_sdk_v4.1.0]: https://github.com/adjust/android_sdk/tree/v4.1.0
Expand All @@ -295,5 +307,6 @@
[android_sdk_v4.13.0]: https://github.com/adjust/android_sdk/tree/v4.13.0
[android_sdk_v4.14.0]: https://github.com/adjust/android_sdk/tree/v4.14.0
[android_sdk_v4.17.0]: https://github.com/adjust/android_sdk/tree/v4.17.0
[android_sdk_v4.18.0]: https://github.com/adjust/android_sdk/tree/v4.18.0

[windows_sdk_v4.0.3]: https://github.com/adjust/windows_sdk/tree/v4.0.3
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.17.1
4.18.0
1 change: 1 addition & 0 deletions dist/ADJAdjust2dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ADJAdjust2dx {
static void removeSessionPartnerParameter(std::string key);
static void resetSessionCallbackParameters();
static void resetSessionPartnerParameters();
static void trackAdRevenue(std::string source, std::string payload);
static bool isEnabled();
static std::string getIdfa();
static std::string getAdid();
Expand Down
4 changes: 4 additions & 0 deletions dist/ADJAdjust2dx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
[Adjust resetSessionPartnerParameters];
}

void ADJAdjust2dx::trackAdRevenue(std::string source, std::string payload) {
NSData *dataPayload = [[NSString stringWithUTF8String:payload.c_str()] dataUsingEncoding:NSUTF8StringEncoding];
[Adjust trackAdRevenue:[NSString stringWithUTF8String:source.c_str()] payload:dataPayload];
}

bool ADJAdjust2dx::isEnabled() {
return [Adjust isEnabled];
Expand Down
23 changes: 23 additions & 0 deletions dist/Adjust2dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,29 @@ void Adjust2dx::resetSessionPartnerParameters() {
#endif
}

void Adjust2dx::trackAdRevenue(std::string source, std::string payload) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
ADJAdjust2dx::trackAdRevenue(source, payload);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
cocos2d::JniMethodInfo jmiTrackAdRevenue;
if (!cocos2d::JniHelper::getStaticMethodInfo(jmiTrackAdRevenue, "com/adjust/sdk/Adjust", "trackAdRevenue", "(Ljava/lang/String;Lorg/json/JSONObject;)V")) {
return;
}
cocos2d::JniMethodInfo jmiJsonObjectInit;
if (!cocos2d::JniHelper::getMethodInfo(jmiJsonObjectInit, "org/json/JSONObject", "<init>", "(Ljava/lang/String;)V")) {
return;
}

jstring jSource = jmiTrackAdRevenue.env->NewStringUTF(source.c_str());
jstring jPayload = jmiTrackAdRevenue.env->NewStringUTF(payload.c_str());
jclass clsJsonObject = jmiJsonObjectInit.env->FindClass("org/json/JSONObject");
jmethodID jmidJsonObjectInit = jmiJsonObjectInit.env->GetMethodID(clsJsonObject, "<init>", "(Ljava/lang/String;)V");
jobject jJsonObject = jmiJsonObjectInit.env->NewObject(clsJsonObject, jmidJsonObjectInit, jPayload);
jmiTrackAdRevenue.env->CallStaticVoidMethod(jmiTrackAdRevenue.classID, jmiTrackAdRevenue.methodID, jSource, jJsonObject);
jmiJsonObjectInit.env->DeleteLocalRef(jJsonObject);
#endif
}

std::string Adjust2dx::getAdid() {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
return ADJAdjust2dx::getAdid();
Expand Down
1 change: 1 addition & 0 deletions dist/Adjust2dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Adjust2dx {
static void removeSessionPartnerParameter(std::string key);
static void resetSessionCallbackParameters();
static void resetSessionPartnerParameters();
static void trackAdRevenue(std::string source, std::string payload);
static std::string getAdid();
static std::string getSdkVersion();
static AdjustAttribution2dx getAttribution();
Expand Down
2 changes: 1 addition & 1 deletion dist/AdjustConfig2dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "AdjustConfig2dx.h"
USING_NS_CC;

const std::string AdjustSdkPrefix2dx = "cocos2d-x4.17.1";
const std::string AdjustSdkPrefix2dx = "cocos2d-x4.18.0";

void AdjustConfig2dx::initConfig(std::string appToken, std::string environment, bool allowSuppressLogLevel) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
Expand Down
2 changes: 1 addition & 1 deletion doc/migrate.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Migrate your adjust SDK for Cocos2d-x to 4.17.1 from 4.0.x
## Migrate your adjust SDK for Cocos2d-x to 4.18.0 from 4.0.x

### SDK initialization

Expand Down
Binary file modified ext/android/proxy/adjust-android.jar
Binary file not shown.
Binary file modified ext/android/proxy/adjust-test.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion ext/android/sdk
Submodule sdk updated 82 files
+3 −3 Adjust/build.gradle
+1 −1 Adjust/example-app-java/build.gradle
+2 −2 Adjust/gradle/wrapper/gradle-wrapper.properties
+16 −87 Adjust/sdk-core/build.gradle
+3 −13 Adjust/sdk-core/src/main/AndroidManifest.xml
+27 −0 Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityHandler.java
+5 −1 Adjust/sdk-core/src/main/java/com/adjust/sdk/ActivityKind.java
+14 −1 Adjust/sdk-core/src/main/java/com/adjust/sdk/Adjust.java
+19 −0 Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustConfig.java
+2 −2 Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustEvent.java
+15 −0 Adjust/sdk-core/src/main/java/com/adjust/sdk/AdjustInstance.java
+1 −1 Adjust/sdk-core/src/main/java/com/adjust/sdk/Constants.java
+4 −0 Adjust/sdk-core/src/main/java/com/adjust/sdk/IActivityHandler.java
+63 −0 Adjust/sdk-core/src/main/java/com/adjust/sdk/PackageBuilder.java
+14 −0 Adjust/sdk-core/src/main/java/com/adjust/sdk/UtilNetworking.java
+4 −35 Adjust/sdk-plugin-criteo/build.gradle
+4 −35 Adjust/sdk-plugin-imei/build.gradle
+4 −35 Adjust/sdk-plugin-sociomantic/build.gradle
+4 −35 Adjust/sdk-plugin-trademob/build.gradle
+4 −35 Adjust/sdk-plugin-webbridge/build.gradle
+1 −1 Adjust/sdk-plugin-webbridge/src/main/assets/adjust.js
+4 −0 Adjust/test-app-core/src/main/AndroidManifest.xml
+15 −0 Adjust/test-app-core/src/main/java/com/adjust/testapp/AdjustCommandExecutor.java
+5 −3 Adjust/test-app-core/src/main/java/com/adjust/testapp/MainActivity.java
+4 −2 Adjust/test-app-webbridge/src/main/java/com/example/testappwebbridge/TestLibraryBridge.java
+32 −16 Adjust/test-library/build.gradle
+12 −12 Adjust/test-library/src/main/java/com/adjust/test/Constants.java
+0 −81 Adjust/test-library/src/main/java/com/adjust/test/ControlChannel.java
+111 −87 Adjust/test-library/src/main/java/com/adjust/test/TestLibrary.java
+50 −0 Adjust/test-library/src/main/java/com/adjust/test/ws/ControlSignal.java
+84 −0 Adjust/test-library/src/main/java/com/adjust/test/ws/ControlWebSocketClient.java
+13 −0 Adjust/test-library/src/main/java/com/adjust/test/ws/SignalType.java
+1 −1 Adjust/test-unit/src/androidTest/java/com/adjust/sdk/TestActivityPackage.java
+6 −0 CHANGELOG.md
+1,412 −485 README.md
+1 −1 VERSION
+1,353 −463 doc/chinese/README.md
+0 −970 doc/chinese/imei_plugin.md
+1 −1 doc/chinese/misc/fb-pixel.md
+31 −0 doc/chinese/misc/multiple-receivers.md
+0 −0 doc/chinese/misc/pre-install-tracker-tool.md
+62 −0 doc/chinese/plugins/imei.md
+0 −55 doc/english/activity_resume_pause.md
+0 −69 doc/english/eclipse.md
+0 −19 doc/english/gps_adid.md
+0 −975 doc/english/imei_plugin.md
+44 −90 doc/english/migration/migrate.md
+44 −0 doc/english/misc/eclipse.md
+2 −3 doc/english/misc/fb-pixel.md
+9 −14 doc/english/misc/multi-process-app.md
+30 −0 doc/english/misc/multiple-receivers.md
+4 −5 doc/english/misc/pre-install-tracker-tool.md
+15 −51 doc/english/plugins/criteo.md
+61 −0 doc/english/plugins/imei.md
+49 −77 doc/english/plugins/sociomantic.md
+8 −25 doc/english/plugins/trademob.md
+0 −44 doc/english/referrer.md
+7 −9 doc/english/sdk-to-sdk/adobe.md
+11 −7 doc/english/sdk-to-sdk/batch.md
+10 −23 doc/english/sdk-to-sdk/mixpanel.md
+24 −0 doc/english/sdk-to-sdk/mopub.md
+0 −947 doc/english/web_views.md
+1,396 −459 doc/japanese/README.md
+0 −54 doc/japanese/activity_resume_pause_ja.md
+0 −19 doc/japanese/gps_adid_ja.md
+0 −0 doc/japanese/migration/migrate.md
+0 −0 doc/japanese/misc/eclipse.md
+1 −1 doc/japanese/misc/fb-pixel.md
+0 −0 doc/japanese/misc/multi-process-app.md
+30 −0 doc/japanese/misc/multiple-receivers.md
+0 −0 doc/japanese/misc/pre-install-tracker-tool.md
+0 −0 doc/japanese/plugins/criteo.md
+0 −0 doc/japanese/plugins/sociomantic.md
+0 −0 doc/japanese/plugins/trademob.md
+0 −41 doc/japanese/referrer_ja.md
+0 −0 doc/japanese/sdk-to-sdk/mixpanel.md
+0 −584 doc/japanese/web_views_ja.md
+1,372 −475 doc/korean/README.md
+1 −1 doc/korean/misc/fb-pixel.md
+31 −0 doc/korean/misc/multiple-receivers.md
+0 −2 doc/web_views.md
+0 −2 doc/web_views_ja.md
2 changes: 1 addition & 1 deletion ext/ios/sdk
Submodule sdk updated 118 files
Binary file modified libs/android/adjust-android.jar
Binary file not shown.
Binary file modified libs/ios/AdjustSdk.framework/Versions/A/AdjustSdk
Binary file not shown.
34 changes: 33 additions & 1 deletion libs/ios/AdjustSdk.framework/Versions/A/Headers/Adjust.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// Adjust.h
// Adjust
//
// V4.17.2
// V4.18.0
// Created by Christian Wellenbrock (wellle) on 23rd July 2013.
// Copyright © 2012-2017 Adjust GmbH. All rights reserved.
//
Expand Down Expand Up @@ -34,6 +34,28 @@
extern NSString * __nonnull const ADJEnvironmentSandbox;
extern NSString * __nonnull const ADJEnvironmentProduction;

/**
* Constants for supported ad revenue sources.
*/
extern NSString * __nonnull const ADJAdRevenueSourceMopub;
extern NSString * __nonnull const ADJAdRevenueSourceAdmob;
extern NSString * __nonnull const ADJAdRevenueSourceFbNativeAd;
extern NSString * __nonnull const ADJAdRevenueSourceIronsource;
extern NSString * __nonnull const ADJAdRevenueSourceFyber;
extern NSString * __nonnull const ADJAdRevenueSourceAerserv;
extern NSString * __nonnull const ADJAdRevenueSourceAppodeal;
extern NSString * __nonnull const ADJAdRevenueSourceAdincube;
extern NSString * __nonnull const ADJAdRevenueSourceFusePowered;
extern NSString * __nonnull const ADJAdRevenueSourceAddaptr;
extern NSString * __nonnull const ADJAdRevenueSourceMillennialMeditation;
extern NSString * __nonnull const ADJAdRevenueSourceFlurry;
extern NSString * __nonnull const ADJAdRevenueSourceAdmost;
extern NSString * __nonnull const ADJAdRevenueSourceDeltadna;
extern NSString * __nonnull const ADJAdRevenueSourceUpsight;
extern NSString * __nonnull const ADJAdRevenueSourceUnityads;
extern NSString * __nonnull const ADJAdRevenueSourceAdtoapp;
extern NSString * __nonnull const ADJAdRevenueSourceTapdaq;

/**
* @brief The main interface to Adjust.
*
Expand Down Expand Up @@ -229,6 +251,14 @@ extern NSString * __nonnull const ADJEnvironmentProduction;
*/
+ (void)gdprForgetMe;

/**
* @brief Track ad revenue for given source.
*
* @param source Ad revenue source.
* @param payload Ad revenue payload.
*/
+ (void)trackAdRevenue:(nonnull NSString *)source payload:(nonnull NSData *)payload;

/**
* Obtain singleton Adjust object.
*/
Expand Down Expand Up @@ -272,6 +302,8 @@ extern NSString * __nonnull const ADJEnvironmentProduction;

- (void)gdprForgetMe;

- (void)trackAdRevenue:(nonnull NSString *)source payload:(nonnull NSData *)payload;

- (BOOL)isEnabled;

- (nullable NSString *)adid;
Expand Down
3 changes: 2 additions & 1 deletion scripts/build_sdk_android.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ def build_test(root_dir, android_submodule_dir, configuration, app_path):
copy_file('{0}/adjust-android.jar'.format(android_libs_dir), '{0}/proj.android/app/libs/adjust-android.jar'.format(app_path))
copy_file('{0}/adjust-test.jar'.format(android_test_libs_dir), '{0}/proj.android/app/libs/adjust-test.jar'.format(app_path))
copy_file('{0}/gson-2.8.1.jar'.format(android_test_libs_dir), '{0}/proj.android/app/libs/gson-2.8.1.jar'.format(app_path))
copy_file('{0}/Java-WebSocket-1.3.9.jar'.format(android_test_libs_dir), '{0}/proj.android/app/libs/Java-WebSocket-1.3.9.jar'.format(app_path))

# ------------------------------------------------------------------
# Updating Adjust SDK C++ source files in ${APP_PATH}/Classes/Adjust folder.
Expand Down Expand Up @@ -108,7 +109,7 @@ def _build_sdk(root_dir, android_submodule_dir, configuration, with_test_lib=Fal
# ------------------------------------------------------------------
# Running clean and makeJar Gradle tasks for Adjust test library project.
debug_green('Running clean and makeJar Gradle tasks for Adjust test library project ...')
gradle_run(['clean', 'adjustMakeJarDebug'])
gradle_run(['clean', 'adjustTestLibraryJarDebug'])
if (configuration == 'release'):
test_libs_in_dir = '{0}/test-library/build/libs'.format(build_dir)
else:
Expand Down
28 changes: 4 additions & 24 deletions scripts/scripting_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -192,15 +192,15 @@ def adb_shell(app_package):

def gradle_make_release_jar(do_clean=False):
if (do_clean):
execute_command(['./gradlew', 'clean', 'adjustSdkNonNativeJarRelease'])
execute_command(['./gradlew', 'clean', 'adjustCoreJarRelease'])
else:
execute_command(['./gradlew', 'adjustSdkNonNativeJarRelease'])
execute_command(['./gradlew', 'adjustCoreJarRelease'])

def gradle_make_debug_jar(do_clean=False):
if (do_clean):
execute_command(['./gradlew', 'clean', 'adjustSdkNonNativeJarDebug'])
execute_command(['./gradlew', 'clean', 'adjustCoreJarDebug'])
else:
execute_command(['./gradlew', 'adjustSdkNonNativeJarDebug'])
execute_command(['./gradlew', 'adjustCoreJarDebug'])

def gradle_run(options):
cmd_params = ['./gradlew']
Expand All @@ -224,23 +224,3 @@ def update_dist(root_dir):

def cocos_new_project(package_name, app_path, name):
execute_command(['cocos', 'new', '-l', 'cpp', '-p', package_name, '-d', app_path, name])

############################################################
### nonsense, eyecandy and such

def waiting_animation(duration, step):
if(duration <= step):
return

line = '-'
line_killer = '\b'
while duration >= 0:
duration -= step
sys.stdout.write(line)
sys.stdout.flush()
sys.stdout.write(line_killer)
line += '-'
line_killer += '\b'
if len(line) > 65:
line = '-'
time.sleep(step)
1 change: 1 addition & 0 deletions src/ADJAdjust2dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class ADJAdjust2dx {
static void removeSessionPartnerParameter(std::string key);
static void resetSessionCallbackParameters();
static void resetSessionPartnerParameters();
static void trackAdRevenue(std::string source, std::string payload);
static bool isEnabled();
static std::string getIdfa();
static std::string getAdid();
Expand Down
4 changes: 4 additions & 0 deletions src/ADJAdjust2dx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,10 @@
[Adjust resetSessionPartnerParameters];
}

void ADJAdjust2dx::trackAdRevenue(std::string source, std::string payload) {
NSData *dataPayload = [[NSString stringWithUTF8String:payload.c_str()] dataUsingEncoding:NSUTF8StringEncoding];
[Adjust trackAdRevenue:[NSString stringWithUTF8String:source.c_str()] payload:dataPayload];
}

bool ADJAdjust2dx::isEnabled() {
return [Adjust isEnabled];
Expand Down
23 changes: 23 additions & 0 deletions src/Adjust2dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,29 @@ void Adjust2dx::resetSessionPartnerParameters() {
#endif
}

void Adjust2dx::trackAdRevenue(std::string source, std::string payload) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
ADJAdjust2dx::trackAdRevenue(source, payload);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
cocos2d::JniMethodInfo jmiTrackAdRevenue;
if (!cocos2d::JniHelper::getStaticMethodInfo(jmiTrackAdRevenue, "com/adjust/sdk/Adjust", "trackAdRevenue", "(Ljava/lang/String;Lorg/json/JSONObject;)V")) {
return;
}
cocos2d::JniMethodInfo jmiJsonObjectInit;
if (!cocos2d::JniHelper::getMethodInfo(jmiJsonObjectInit, "org/json/JSONObject", "<init>", "(Ljava/lang/String;)V")) {
return;
}

jstring jSource = jmiTrackAdRevenue.env->NewStringUTF(source.c_str());
jstring jPayload = jmiTrackAdRevenue.env->NewStringUTF(payload.c_str());
jclass clsJsonObject = jmiJsonObjectInit.env->FindClass("org/json/JSONObject");
jmethodID jmidJsonObjectInit = jmiJsonObjectInit.env->GetMethodID(clsJsonObject, "<init>", "(Ljava/lang/String;)V");
jobject jJsonObject = jmiJsonObjectInit.env->NewObject(clsJsonObject, jmidJsonObjectInit, jPayload);
jmiTrackAdRevenue.env->CallStaticVoidMethod(jmiTrackAdRevenue.classID, jmiTrackAdRevenue.methodID, jSource, jJsonObject);
jmiJsonObjectInit.env->DeleteLocalRef(jJsonObject);
#endif
}

std::string Adjust2dx::getAdid() {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
return ADJAdjust2dx::getAdid();
Expand Down
1 change: 1 addition & 0 deletions src/Adjust2dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class Adjust2dx {
static void removeSessionPartnerParameter(std::string key);
static void resetSessionCallbackParameters();
static void resetSessionPartnerParameters();
static void trackAdRevenue(std::string source, std::string payload);
static std::string getAdid();
static std::string getSdkVersion();
static AdjustAttribution2dx getAttribution();
Expand Down
2 changes: 1 addition & 1 deletion src/AdjustConfig2dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
#include "AdjustConfig2dx.h"
USING_NS_CC;

const std::string AdjustSdkPrefix2dx = "cocos2d-x4.17.1";
const std::string AdjustSdkPrefix2dx = "cocos2d-x4.18.0";

void AdjustConfig2dx::initConfig(std::string appToken, std::string environment, bool allowSuppressLogLevel) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
Expand Down
2 changes: 1 addition & 1 deletion src/test/ATLTestLibrary2dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class ATLTestLibrary2dx {

public:
ATLTestLibrary2dx() {}
ATLTestLibrary2dx(std::string baseUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters));
ATLTestLibrary2dx(std::string baseUrl, std::string controlUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters));

void addTest(std::string testName);
void addTestDirectory(std::string testDirectory);
Expand Down
3 changes: 2 additions & 1 deletion src/test/ATLTestLibrary2dx.mm
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,10 @@
#include "AdjustCommandDelegate2dx.h"
#include <AdjustTestLibrary/ATLTestLibrary.h>

ATLTestLibrary2dx::ATLTestLibrary2dx(std::string baseUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters)) {
ATLTestLibrary2dx::ATLTestLibrary2dx(std::string baseUrl, std::string controlUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters)) {
AdjustCommandDelegate2dx *adjustCommandDelegate = [AdjustCommandDelegate2dx getInstanceWithCommandExecutorCallbackId:executeCommandCallback];
testLibrary = [ATLTestLibrary testLibraryWithBaseUrl:[NSString stringWithUTF8String:baseUrl.c_str()]
andControlUrl:[NSString stringWithUTF8String:controlUrl.c_str()]
andCommandDelegate:adjustCommandDelegate];
}

Expand Down
13 changes: 8 additions & 5 deletions src/test/TestLib2dx.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,21 @@ static jobject testLibrary;
static ATLTestLibrary2dx testLibrary;
#endif

void TestLib2dx::initTestLibrary(std::string baseUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters)) {
void TestLib2dx::initTestLibrary(std::string baseUrl, std::string controlUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters)) {
#if (CC_TARGET_PLATFORM == CC_PLATFORM_ANDROID)
setExecuteTestLibCommandCallbackMethod(executeCommandCallback);

cocos2d::JniMethodInfo jmiInit;
if (!cocos2d::JniHelper::getMethodInfo(jmiInit, "com/adjust/test/TestLibrary", "<init>", "(Ljava/lang/String;Lcom/adjust/test/ICommandJsonListener;)V")) {
if (!cocos2d::JniHelper::getMethodInfo(jmiInit, "com/adjust/test/TestLibrary", "<init>", "(Ljava/lang/String;Ljava/lang/String;Lcom/adjust/test/ICommandJsonListener;)V")) {
return;
}

jclass jclsTestLibrary = jmiInit.env->FindClass("com/adjust/test/TestLibrary");
jmethodID jmidInit = jmiInit.env->GetMethodID(jclsTestLibrary, "<init>", "(Ljava/lang/String;Lcom/adjust/test/ICommandJsonListener;)V");
jmethodID jmidInit = jmiInit.env->GetMethodID(jclsTestLibrary, "<init>", "(Ljava/lang/String;Ljava/lang/String;Lcom/adjust/test/ICommandJsonListener;)V");
// Base URL.
jstring jBaseUrl = jmiInit.env->NewStringUTF(baseUrl.c_str());
// Control URL.
jstring jControlUrl = jmiInit.env->NewStringUTF(controlUrl.c_str());
// Command listener.
cocos2d::JniMethodInfo jmiInitCommJsonListener;
if (!cocos2d::JniHelper::getMethodInfo(jmiInitCommJsonListener, "com/adjust/test/Adjust2dxCommandJsonListenerCallback", "<init>", "()V")) {
Expand All @@ -46,13 +48,14 @@ void TestLib2dx::initTestLibrary(std::string baseUrl, void(*executeCommandCallba
jobject jCommListenerCallbackProxy = jmiInitCommJsonListener.env->NewObject(jclsAdjust2dxCommandJsonListenerCallback, jmidInitCommJsonListener);

// Initialise test library
jobject jTestLib = jmiInit.env->NewObject(jclsTestLibrary, jmidInit, jBaseUrl, jCommListenerCallbackProxy);
jobject jTestLib = jmiInit.env->NewObject(jclsTestLibrary, jmidInit, jBaseUrl, jControlUrl, jCommListenerCallbackProxy);
testLibrary = cocos2d::JniHelper::getEnv()->NewGlobalRef(jTestLib);

jmiInit.env->DeleteLocalRef(jBaseUrl);
jmiInit.env->DeleteLocalRef(jControlUrl);
jmiInit.env->DeleteLocalRef(jCommListenerCallbackProxy);
#elif (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
testLibrary = ATLTestLibrary2dx(baseUrl, executeCommandCallback);
testLibrary = ATLTestLibrary2dx(baseUrl, controlUrl, executeCommandCallback);
#endif
}

Expand Down
6 changes: 3 additions & 3 deletions src/test/TestLib2dx.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@

class TestLib2dx {
private:
void initTestLibrary(std::string baseUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters));
void initTestLibrary(std::string baseUrl, std::string controlUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters));

public:
TestLib2dx(std::string baseUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters)) {
initTestLibrary(baseUrl, executeCommandCallback);
TestLib2dx(std::string baseUrl, std::string controlUrl, void(*executeCommandCallback)(std::string className, std::string methodName, std::string jsonParameters)) {
initTestLibrary(baseUrl, controlUrl, executeCommandCallback);
}

void addTest(std::string testName);
Expand Down
8 changes: 8 additions & 0 deletions test/app/Classes/AdjustCommandExecutor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,8 @@ void AdjustCommandExecutor::executeCommand(Command *command) {
this->sendReferrer();
} else if (command->methodName == "gdprForgetMe") {
this->gdprForgetMe();
} else if (command->methodName == "trackAdRevenue") {
this->trackAdRevenue();
}
}

Expand Down Expand Up @@ -540,3 +542,9 @@ void AdjustCommandExecutor::sendReferrer() {
void AdjustCommandExecutor::gdprForgetMe() {
Adjust2dx::gdprForgetMe();
}

void AdjustCommandExecutor::trackAdRevenue() {
std::string source = command->getFirstParameterValue("adRevenueSource");
std::string payload = command->getFirstParameterValue("adRevenueJsonString");
Adjust2dx::trackAdRevenue(source, payload);
}
Loading

0 comments on commit 774f13d

Please sign in to comment.