C++ Library

Tapjoy provides a C++ API on development environments that use Android NDK and C++, such as Cocos2d-x.

The C++ API which is provided by Tapjoy’s Android SDK is compatible with Tapjoy’s iOS SDK’s C++ API.

NDK Modules

An NDK module which offers C++ header file and library is included in Tapjoy SDK. Please add Tapjoy’s NDK Modules’ path as NDK_MODULE_PATH.

ndk-build NDK_MODULE_PATH=../../TapjoySDK_Android/Library/modules

Cocos2dx

Add NDK_MODULE_PATH separated by colon(:) to proj.android/build_native.sh:

 # proj.android/build_native.sh
...
if [[ "$buildexternalsfromsource" ]]; then
    echo "Building external dependencies from source"
    "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
       "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source:../../TapjoySDK_Android/Library/modules"
else
    echo "Using prebuilt externals"
    "$NDK_ROOT"/ndk-build -C "$APP_ANDROID_ROOT" $* \
       "NDK_MODULE_PATH=${COCOS2DX_ROOT}:${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt:../../TapjoySDK_Android/Library/modules"
fi

Use one of the following modules:

Static Library Module

Link your application library to the Static Library Module.

Add fiverocks_static module:

From the app project, add the tapjoy_static module to Android.mk file that builds Tapjoy API integration source code.

```make
 ...
 include $(CLEAR_VARS)
 ...
 LOCAL_STATIC_LIBRARIES := tapjoy_static
 ...
 include $(BUILD_SHARED_LIBRARY)
 ...
 $(call import-module,tapjoy)
 ...

Provide JavaVM:

`tapjoy_static` module requires a JavaVM object. Find the function definition of `JNI_OnLoad` and add the `Tapjoy::setJavaVM` method:

```java
  #include "TapjoyCpp.h" // Tapjoy C++ API
 ...
 jint JNI_OnLoad(JavaVM *vm, void *reserved) {
     ...
     JniHelper::setJavaVM(vm);
     tapjoy::Tapjoy::setJavaVM(vm);
     ...
 }

Shared Library Module

You can also use the Shared Library Module. This does not require JavaVM.

Add the tapjoy_shared module:

From the app project, add the tapjoy_shared module to Android.mk file that builds Tapjoy API integration source code:

```make
...
include $(CLEAR_VARS)
...
LOCAL_SHARED_LIBRARIES := tapjoy_shared
...
include $(BUILD_SHARED_LIBRARY)
...
$(call import-module,tapjoy)
...

Resolve Shared Library Module’s dependency issue:
Before loading the application library that uses Tapjoy Library, call `Tapjoy.loadSharedLibrary()`:

```java

import com.tapjoy.Tapjoy;

  static {
    Tapjoy.loadSharedLibrary();
    System.loadLibrary("YourAppLibrary");
  }

C++ API

Use the TapjoyCpp.h header file:


 #include "Tapjoy/TapjoyCpp.h" // Tapjoy C++ API

using namespace tapjoy;

  Tapjoy::trackEvent("some event");

Privacy

Full details here.

API

TJPrivacyPolicyHandle policyHandle;
policyHandle = TJPrivacyPolicy::getPrivacyPolicy();
TJPrivacyPolicy::subjectToGDPR(policyHandle,true);
TJPrivacyPolicy::setUserConsent(policyHandle, "1″);
TJPrivacyPolicy::setUSPrivacy(policyHandle, "1YNY");
TJPrivacyPolicy::belowConsentAge(policyHandle, true);