diff --git a/DemoApp/DemoAppJava/.gitignore b/DemoApp/DemoAppJava/.gitignore
new file mode 100644
index 0000000..d3881ac
--- /dev/null
+++ b/DemoApp/DemoAppJava/.gitignore
@@ -0,0 +1,31 @@
+*.iml
+.gradle
+local.properties
+.idea/caches
+.idea/libraries
+.idea/modules.xml
+.idea/workspace.xml
+.idea/navEditor.xml
+.idea/assetWizardSettings.xml
+.idea/gradle.xml
+.idea/shelf/
+.idea/tasks.xml
+.idea/.name
+.idea/compiler.xml
+.idea/copyright/profiles_settings.xml
+.idea/encodings.xml
+.idea/misc.xml
+.idea/dictionaries
+.idea/vcs.xml
+.idea/jsLibraryMappings.xml
+.idea/datasources.xml
+.idea/dataSources.ids
+.idea/sqlDataSources.xml
+.idea/dynamic.xml
+.idea/uiDesigner.xml
+.idea/modules
+.DS_Store
+build
+captures
+.externalNativeBuild
+.cxx
diff --git a/DemoApp/DemoAppJava/.idea/codeStyles/Project.xml b/DemoApp/DemoAppJava/.idea/codeStyles/Project.xml
new file mode 100644
index 0000000..0d15693
--- /dev/null
+++ b/DemoApp/DemoAppJava/.idea/codeStyles/Project.xml
@@ -0,0 +1,134 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ xmlns:android
+
+ ^$
+
+
+
+
+
+
+
+
+ xmlns:.*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*:id
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ .*:name
+
+ http://schemas.android.com/apk/res/android
+
+
+
+
+
+
+
+
+ name
+
+ ^$
+
+
+
+
+
+
+
+
+ style
+
+ ^$
+
+
+
+
+
+
+
+
+ .*
+
+ ^$
+
+
+ BY_NAME
+
+
+
+
+
+
+ .*
+
+ http://schemas.android.com/apk/res/android
+
+
+ ANDROID_ATTRIBUTE_ORDER
+
+
+
+
+
+
+ .*
+
+ .*
+
+
+ BY_NAME
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/.idea/jarRepositories.xml b/DemoApp/DemoAppJava/.idea/jarRepositories.xml
new file mode 100644
index 0000000..2370474
--- /dev/null
+++ b/DemoApp/DemoAppJava/.idea/jarRepositories.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/.idea/runConfigurations.xml b/DemoApp/DemoAppJava/.idea/runConfigurations.xml
new file mode 100644
index 0000000..7f68460
--- /dev/null
+++ b/DemoApp/DemoAppJava/.idea/runConfigurations.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/.gitignore b/DemoApp/DemoAppJava/app/.gitignore
new file mode 100644
index 0000000..42afabf
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/.gitignore
@@ -0,0 +1 @@
+/build
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/build.gradle b/DemoApp/DemoAppJava/app/build.gradle
new file mode 100644
index 0000000..7b5fd82
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/build.gradle
@@ -0,0 +1,55 @@
+plugins {
+ id("de.nanogiants.android-versioning") version "2.4.0"
+}
+
+apply plugin: 'com.android.application'
+
+android {
+ compileSdkVersion 30
+ buildToolsVersion "30.0.2"
+
+ defaultConfig {
+ applicationId "co.optable.demoappjava"
+ minSdkVersion 16
+ targetSdkVersion 29
+
+ // Here we get version code and version name from latest git release tags:
+ versionCode versioning.getVersionCode()
+ versionName versioning.getVersionName(false)
+ archivesBaseName = "optable-android-sdk-demo-java"
+
+ multiDexEnabled true
+
+ testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
+ }
+
+ buildTypes {
+ release {
+ minifyEnabled false
+ proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
+ }
+ }
+
+ compileOptions {
+ sourceCompatibility JavaVersion.VERSION_1_8
+ targetCompatibility JavaVersion.VERSION_1_8
+ }
+
+}
+
+dependencies {
+ implementation fileTree(dir: "libs", include: ["*.jar"])
+ implementation 'androidx.appcompat:appcompat:1.2.0'
+ implementation 'com.google.android.material:material:1.2.1'
+ implementation 'androidx.constraintlayout:constraintlayout:2.0.2'
+ implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
+ implementation 'androidx.navigation:navigation-fragment:2.3.0'
+ implementation 'androidx.navigation:navigation-ui:2.3.0'
+ implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
+ testImplementation 'junit:junit:4.12'
+ androidTestImplementation 'androidx.test.ext:junit:1.1.2'
+ androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
+
+ implementation 'com.google.android.gms:play-services-ads:19.3.0'
+ implementation "com.github.Optable:optable-android-sdk:2-issue-java-demo-SNAPSHOT" //+ versioning.getVersionName(false)
+}
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/proguard-rules.pro b/DemoApp/DemoAppJava/app/proguard-rules.pro
new file mode 100644
index 0000000..481bb43
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/proguard-rules.pro
@@ -0,0 +1,21 @@
+# Add project specific ProGuard rules here.
+# You can control the set of applied configuration files using the
+# proguardFiles setting in build.gradle.
+#
+# For more details, see
+# http://developer.android.com/guide/developing/tools/proguard.html
+
+# If your project uses WebView with JS, uncomment the following
+# and specify the fully qualified class name to the JavaScript interface
+# class:
+#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
+# public *;
+#}
+
+# Uncomment this to preserve the line number information for
+# debugging stack traces.
+#-keepattributes SourceFile,LineNumberTable
+
+# If you keep the line number information, uncomment this to
+# hide the original source file name.
+#-renamesourcefileattribute SourceFile
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/androidTest/java/co/optable/demoappjava/ExampleInstrumentedTest.java b/DemoApp/DemoAppJava/app/src/androidTest/java/co/optable/demoappjava/ExampleInstrumentedTest.java
new file mode 100644
index 0000000..7698b51
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/androidTest/java/co/optable/demoappjava/ExampleInstrumentedTest.java
@@ -0,0 +1,26 @@
+package co.optable.demoappjava;
+
+import android.content.Context;
+
+import androidx.test.platform.app.InstrumentationRegistry;
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import static org.junit.Assert.*;
+
+/**
+ * Instrumented test, which will execute on an Android device.
+ *
+ * @see Testing documentation
+ */
+@RunWith(AndroidJUnit4.class)
+public class ExampleInstrumentedTest {
+ @Test
+ public void useAppContext() {
+ // Context of the app under test.
+ Context appContext = InstrumentationRegistry.getInstrumentation().getTargetContext();
+ assertEquals("co.optable.demoappjava", appContext.getPackageName());
+ }
+}
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/AndroidManifest.xml b/DemoApp/DemoAppJava/app/src/main/AndroidManifest.xml
new file mode 100644
index 0000000..ab418f8
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/AndroidManifest.xml
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/MainActivity.java b/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/MainActivity.java
new file mode 100644
index 0000000..517e5ce
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/MainActivity.java
@@ -0,0 +1,35 @@
+package co.optable.demoappjava;
+
+import android.os.Bundle;
+
+import com.google.android.material.bottomnavigation.BottomNavigationView;
+
+import androidx.appcompat.app.AppCompatActivity;
+import androidx.navigation.NavController;
+import androidx.navigation.Navigation;
+import androidx.navigation.ui.AppBarConfiguration;
+import androidx.navigation.ui.NavigationUI;
+import co.optable.android_sdk.OptableSDK;
+
+public class MainActivity extends AppCompatActivity {
+ public static OptableSDK OPTABLE;
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+
+ MainActivity.OPTABLE = new OptableSDK(this.getApplicationContext(), "sandbox.optable.co", "android-sdk-demo");
+
+ BottomNavigationView navView = findViewById(R.id.nav_view);
+ NavController navController = Navigation.findNavController(this, R.id.nav_host_fragment);
+ // Passing each menu ID as a set of Ids because each
+ // menu should be considered as top level destinations.
+ AppBarConfiguration appBarConfiguration = new AppBarConfiguration.Builder(
+ R.id.navigation_identify, R.id.navigation_gambanner)
+ .build();
+ NavigationUI.setupActionBarWithNavController(this, navController, appBarConfiguration);
+ NavigationUI.setupWithNavController(navView, navController);
+ }
+
+}
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/GAMBanner/GAMBannerFragment.java b/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/GAMBanner/GAMBannerFragment.java
new file mode 100644
index 0000000..6842c14
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/GAMBanner/GAMBannerFragment.java
@@ -0,0 +1,77 @@
+package co.optable.demoappjava.ui.GAMBanner;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+import com.google.android.gms.ads.doubleclick.PublisherAdRequest;
+import com.google.android.gms.ads.doubleclick.PublisherAdView;
+
+import java.util.HashMap;
+
+import co.optable.android_sdk.OptableSDK;
+import co.optable.demoappjava.MainActivity;
+import co.optable.demoappjava.R;
+
+public class GAMBannerFragment extends Fragment {
+ private PublisherAdView mPublisherAdView;
+ private TextView targetingDataView;
+
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater,
+ ViewGroup container, Bundle savedInstanceState) {
+ View root = inflater.inflate(R.layout.fragment_gambanner, container, false);
+ mPublisherAdView = root.findViewById(R.id.publisherAdView);
+ targetingDataView = root.findViewById(R.id.targetingDataView);
+
+ Button btn = root.findViewById(R.id.loadAdButton);
+ btn.setOnClickListener(view -> {
+ targetingDataView.setText("");
+
+ MainActivity.OPTABLE.targeting().observe(getViewLifecycleOwner(), result -> {
+ PublisherAdRequest.Builder adRequest = new PublisherAdRequest.Builder();
+ final StringBuilder msg = new StringBuilder();
+ msg.append(targetingDataView.getText().toString());
+
+ if (result.getStatus() == OptableSDK.Status.SUCCESS) {
+ msg.append("Loading GAM ad with targeting data:\n\n");
+ result.getData().forEach((key, values) -> {
+ adRequest.addCustomTargeting(key, values);
+ msg.append(key.toString() + " = " + values.toString());
+ });
+ } else {
+ msg.append("OptableSDK Error: " + result.getMessage());
+ }
+
+ targetingDataView.setText(msg.toString());
+ mPublisherAdView.loadAd(adRequest.build());
+ });
+
+ HashMap eventProperties = new HashMap();
+ eventProperties.put("exampleKey", "exampleValue");
+
+ MainActivity.OPTABLE
+ .witness("GAMBannerFragment.loadAdButtonClicked", eventProperties)
+ .observe(getViewLifecycleOwner(), result -> {
+ final StringBuilder msg = new StringBuilder();
+ msg.append(targetingDataView.getText().toString());
+
+ if (result.getStatus() == OptableSDK.Status.SUCCESS) {
+ msg.append("\n\nSuccess calling witness API to log loadAdButtonClicked event.\n\n");
+ } else {
+ msg.append("\n\nOptableSDK Error: " + result.getMessage() + "\n\n");
+ }
+
+ targetingDataView.setText(msg.toString());
+ });
+ });
+
+ return root;
+ }
+}
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/Identify/IdentifyFragment.java b/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/Identify/IdentifyFragment.java
new file mode 100644
index 0000000..85c689b
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/java/co/optable/demoappjava/ui/Identify/IdentifyFragment.java
@@ -0,0 +1,51 @@
+package co.optable.demoappjava.ui.Identify;
+
+import android.os.Bundle;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.Button;
+import android.widget.EditText;
+import android.widget.Switch;
+import android.widget.TextView;
+
+import androidx.annotation.NonNull;
+import androidx.fragment.app.Fragment;
+
+import co.optable.android_sdk.OptableSDK;
+import co.optable.demoappjava.MainActivity;
+import co.optable.demoappjava.R;
+
+public class IdentifyFragment extends Fragment {
+ private TextView identifyView;
+ private EditText emailText;
+ private Switch gaidSwitch;
+
+ @Override
+ public View onCreateView(@NonNull LayoutInflater inflater,
+ ViewGroup container, Bundle savedInstanceState) {
+ View root = inflater.inflate(R.layout.fragment_identify, container, false);
+ identifyView = root.findViewById(R.id.identifyView);
+ emailText = root.findViewById(R.id.editTextTextEmailAddress);
+ gaidSwitch = root.findViewById(R.id.gaidSwitch);
+
+ Button btn = root.findViewById(R.id.identifyButton);
+ btn.setOnClickListener(view ->
+ MainActivity.OPTABLE
+ .identify(emailText.getText().toString(), gaidSwitch.isChecked())
+ .observe(getViewLifecycleOwner(), result -> {
+ String msg = "Calling identify API... ";
+
+ if (result.getStatus() == OptableSDK.Status.SUCCESS) {
+ msg += "Success";
+ } else {
+ msg += "\n\nOptableSDK Error: " + result.getMessage();
+ }
+
+ identifyView.setText(msg);
+ })
+ );
+
+ return root;
+ }
+}
diff --git a/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_gambanner_black_24dp.xml b/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_gambanner_black_24dp.xml
new file mode 100644
index 0000000..46fc8de
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_gambanner_black_24dp.xml
@@ -0,0 +1,9 @@
+
+
+
diff --git a/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_identify_black.xml b/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_identify_black.xml
new file mode 100644
index 0000000..92fcf46
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_identify_black.xml
@@ -0,0 +1,14 @@
+
+
+
+
diff --git a/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_launcher_background.xml b/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_launcher_background.xml
new file mode 100644
index 0000000..07d5da9
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_launcher_background.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_launcher_foreground.xml b/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_launcher_foreground.xml
new file mode 100644
index 0000000..2b068d1
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/drawable/ic_launcher_foreground.xml
@@ -0,0 +1,30 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/layout/activity_main.xml b/DemoApp/DemoAppJava/app/src/main/res/layout/activity_main.xml
new file mode 100644
index 0000000..38c0aa8
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/layout/activity_main.xml
@@ -0,0 +1,33 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/layout/fragment_gambanner.xml b/DemoApp/DemoAppJava/app/src/main/res/layout/fragment_gambanner.xml
new file mode 100644
index 0000000..cd1a0f3
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/layout/fragment_gambanner.xml
@@ -0,0 +1,40 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/layout/fragment_identify.xml b/DemoApp/DemoAppJava/app/src/main/res/layout/fragment_identify.xml
new file mode 100644
index 0000000..3a3f9fb
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/layout/fragment_identify.xml
@@ -0,0 +1,50 @@
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/menu/bottom_nav_menu.xml b/DemoApp/DemoAppJava/app/src/main/res/menu/bottom_nav_menu.xml
new file mode 100644
index 0000000..10eb35f
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/menu/bottom_nav_menu.xml
@@ -0,0 +1,14 @@
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml b/DemoApp/DemoAppJava/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/mipmap-anydpi-v26/ic_launcher.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml b/DemoApp/DemoAppJava/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
new file mode 100644
index 0000000..eca70cf
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/mipmap-anydpi-v26/ic_launcher_round.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-hdpi/ic_launcher.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-hdpi/ic_launcher.png
new file mode 100644
index 0000000..a571e60
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-hdpi/ic_launcher.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-hdpi/ic_launcher_round.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-hdpi/ic_launcher_round.png
new file mode 100644
index 0000000..61da551
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-hdpi/ic_launcher_round.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-mdpi/ic_launcher.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-mdpi/ic_launcher.png
new file mode 100644
index 0000000..c41dd28
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-mdpi/ic_launcher.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-mdpi/ic_launcher_round.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-mdpi/ic_launcher_round.png
new file mode 100644
index 0000000..db5080a
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-mdpi/ic_launcher_round.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xhdpi/ic_launcher.png
new file mode 100644
index 0000000..6dba46d
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..da31a87
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxhdpi/ic_launcher.png
new file mode 100644
index 0000000..15ac681
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..b216f2d
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png
new file mode 100644
index 0000000..f25a419
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png
new file mode 100644
index 0000000..e96783c
Binary files /dev/null and b/DemoApp/DemoAppJava/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png differ
diff --git a/DemoApp/DemoAppJava/app/src/main/res/navigation/mobile_navigation.xml b/DemoApp/DemoAppJava/app/src/main/res/navigation/mobile_navigation.xml
new file mode 100644
index 0000000..c0c1bd1
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/navigation/mobile_navigation.xml
@@ -0,0 +1,20 @@
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/values/colors.xml b/DemoApp/DemoAppJava/app/src/main/res/values/colors.xml
new file mode 100644
index 0000000..4faecfa
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/values/colors.xml
@@ -0,0 +1,6 @@
+
+
+ #6200EE
+ #3700B3
+ #03DAC5
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/values/dimens.xml b/DemoApp/DemoAppJava/app/src/main/res/values/dimens.xml
new file mode 100644
index 0000000..e00c2dd
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/values/dimens.xml
@@ -0,0 +1,5 @@
+
+
+ 16dp
+ 16dp
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/values/strings.xml b/DemoApp/DemoAppJava/app/src/main/res/values/strings.xml
new file mode 100644
index 0000000..1f05d05
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/values/strings.xml
@@ -0,0 +1,6 @@
+
+ DemoAppJava
+ Home
+ Dashboard
+ Notifications
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/main/res/values/styles.xml b/DemoApp/DemoAppJava/app/src/main/res/values/styles.xml
new file mode 100644
index 0000000..fac9291
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/main/res/values/styles.xml
@@ -0,0 +1,10 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/app/src/test/java/co/optable/demoappjava/ExampleUnitTest.java b/DemoApp/DemoAppJava/app/src/test/java/co/optable/demoappjava/ExampleUnitTest.java
new file mode 100644
index 0000000..8450f66
--- /dev/null
+++ b/DemoApp/DemoAppJava/app/src/test/java/co/optable/demoappjava/ExampleUnitTest.java
@@ -0,0 +1,17 @@
+package co.optable.demoappjava;
+
+import org.junit.Test;
+
+import static org.junit.Assert.*;
+
+/**
+ * Example local unit test, which will execute on the development machine (host).
+ *
+ * @see Testing documentation
+ */
+public class ExampleUnitTest {
+ @Test
+ public void addition_isCorrect() {
+ assertEquals(4, 2 + 2);
+ }
+}
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/build.gradle b/DemoApp/DemoAppJava/build.gradle
new file mode 100644
index 0000000..156030a
--- /dev/null
+++ b/DemoApp/DemoAppJava/build.gradle
@@ -0,0 +1,28 @@
+// Top-level build file where you can add configuration options common to all sub-projects/modules.
+buildscript {
+ repositories {
+ google()
+ jcenter()
+ }
+ dependencies {
+ classpath "com.android.tools.build:gradle:4.0.1"
+
+ // NOTE: Do not place your application dependencies here; they belong
+ // in the individual module build.gradle files
+ }
+}
+
+allprojects {
+ repositories {
+ google()
+ jcenter()
+ maven {
+ url "https://jitpack.io"
+ credentials { username authToken }
+ }
+ }
+}
+
+task clean(type: Delete) {
+ delete rootProject.buildDir
+}
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/gradle.properties b/DemoApp/DemoAppJava/gradle.properties
new file mode 100644
index 0000000..2cd1b65
--- /dev/null
+++ b/DemoApp/DemoAppJava/gradle.properties
@@ -0,0 +1,21 @@
+# Project-wide Gradle settings.
+# IDE (e.g. Android Studio) users:
+# Gradle settings configured through the IDE *will override*
+# any settings specified in this file.
+# For more details on how to configure your build environment visit
+# http://www.gradle.org/docs/current/userguide/build_environment.html
+# Specifies the JVM arguments used for the daemon process.
+# The setting is particularly useful for tweaking memory settings.
+org.gradle.jvmargs=-Xmx2048m
+# When configured, Gradle will run in incubating parallel mode.
+# This option should only be used with decoupled projects. More details, visit
+# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
+# org.gradle.parallel=true
+# AndroidX package structure to make it clearer which packages are bundled with the
+# Android operating system, and which are packaged with your app"s APK
+# https://developer.android.com/topic/libraries/support-library/androidx-rn
+android.useAndroidX=true
+# Automatically convert third-party libraries to use AndroidX
+android.enableJetifier=true
+# Jitpack.io authToken for accessing PRIVATE GitHub repo to build co.optable.android_sdk depend:
+authToken=jp_usu041v753rg6asheri00bjihl
\ No newline at end of file
diff --git a/DemoApp/DemoAppJava/gradle/wrapper/gradle-wrapper.jar b/DemoApp/DemoAppJava/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..f6b961f
Binary files /dev/null and b/DemoApp/DemoAppJava/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/DemoApp/DemoAppJava/gradle/wrapper/gradle-wrapper.properties b/DemoApp/DemoAppJava/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..646f74a
--- /dev/null
+++ b/DemoApp/DemoAppJava/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Wed Oct 07 22:02:37 EDT 2020
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
diff --git a/DemoApp/DemoAppJava/gradlew b/DemoApp/DemoAppJava/gradlew
new file mode 100755
index 0000000..cccdd3d
--- /dev/null
+++ b/DemoApp/DemoAppJava/gradlew
@@ -0,0 +1,172 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Gradle start up script for UN*X
+##
+##############################################################################
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ] ; do
+ ls=`ls -ld "$PRG"`
+ link=`expr "$ls" : '.*-> \(.*\)$'`
+ if expr "$link" : '/.*' > /dev/null; then
+ PRG="$link"
+ else
+ PRG=`dirname "$PRG"`"/$link"
+ fi
+done
+SAVED="`pwd`"
+cd "`dirname \"$PRG\"`/" >/dev/null
+APP_HOME="`pwd -P`"
+cd "$SAVED" >/dev/null
+
+APP_NAME="Gradle"
+APP_BASE_NAME=`basename "$0"`
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS=""
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD="maximum"
+
+warn () {
+ echo "$*"
+}
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+}
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "`uname`" in
+ CYGWIN* )
+ cygwin=true
+ ;;
+ Darwin* )
+ darwin=true
+ ;;
+ MINGW* )
+ msys=true
+ ;;
+ NONSTOP* )
+ nonstop=true
+ ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD="$JAVA_HOME/jre/sh/java"
+ else
+ JAVACMD="$JAVA_HOME/bin/java"
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD="java"
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
+ MAX_FD_LIMIT=`ulimit -H -n`
+ if [ $? -eq 0 ] ; then
+ if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
+ MAX_FD="$MAX_FD_LIMIT"
+ fi
+ ulimit -n $MAX_FD
+ if [ $? -ne 0 ] ; then
+ warn "Could not set maximum file descriptor limit: $MAX_FD"
+ fi
+ else
+ warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
+ fi
+fi
+
+# For Darwin, add options to specify how the application appears in the dock
+if $darwin; then
+ GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
+fi
+
+# For Cygwin, switch paths to Windows format before running java
+if $cygwin ; then
+ APP_HOME=`cygpath --path --mixed "$APP_HOME"`
+ CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
+ JAVACMD=`cygpath --unix "$JAVACMD"`
+
+ # We build the pattern for arguments to be converted via cygpath
+ ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
+ SEP=""
+ for dir in $ROOTDIRSRAW ; do
+ ROOTDIRS="$ROOTDIRS$SEP$dir"
+ SEP="|"
+ done
+ OURCYGPATTERN="(^($ROOTDIRS))"
+ # Add a user-defined pattern to the cygpath arguments
+ if [ "$GRADLE_CYGPATTERN" != "" ] ; then
+ OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
+ fi
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ i=0
+ for arg in "$@" ; do
+ CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
+ CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
+
+ if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
+ eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
+ else
+ eval `echo args$i`="\"$arg\""
+ fi
+ i=$((i+1))
+ done
+ case $i in
+ (0) set -- ;;
+ (1) set -- "$args0" ;;
+ (2) set -- "$args0" "$args1" ;;
+ (3) set -- "$args0" "$args1" "$args2" ;;
+ (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
+ (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
+ (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
+ (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
+ (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
+ (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
+ esac
+fi
+
+# Escape application args
+save () {
+ for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
+ echo " "
+}
+APP_ARGS=$(save "$@")
+
+# Collect all arguments for the java command, following the shell quoting and substitution rules
+eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+exec "$JAVACMD" "$@"
diff --git a/DemoApp/DemoAppJava/gradlew.bat b/DemoApp/DemoAppJava/gradlew.bat
new file mode 100644
index 0000000..e95643d
--- /dev/null
+++ b/DemoApp/DemoAppJava/gradlew.bat
@@ -0,0 +1,84 @@
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS=
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto init
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto init
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:init
+@rem Get command-line arguments, handling Windows variants
+
+if not "%OS%" == "Windows_NT" goto win9xME_args
+
+:win9xME_args
+@rem Slurp the command line arguments.
+set CMD_LINE_ARGS=
+set _SKIP=2
+
+:win9xME_args_slurp
+if "x%~1" == "x" goto execute
+
+set CMD_LINE_ARGS=%*
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/DemoApp/DemoAppJava/settings.gradle b/DemoApp/DemoAppJava/settings.gradle
new file mode 100644
index 0000000..a024803
--- /dev/null
+++ b/DemoApp/DemoAppJava/settings.gradle
@@ -0,0 +1,2 @@
+include ':app'
+rootProject.name = "DemoAppJava"
\ No newline at end of file
diff --git a/DemoApp/DemoAppKotlin/app/src/main/java/co/optable/androidsdkdemo/ui/GAMBanner/GAMBannerFragment.kt b/DemoApp/DemoAppKotlin/app/src/main/java/co/optable/androidsdkdemo/ui/GAMBanner/GAMBannerFragment.kt
index 3aee8d5..cb673de 100644
--- a/DemoApp/DemoAppKotlin/app/src/main/java/co/optable/androidsdkdemo/ui/GAMBanner/GAMBannerFragment.kt
+++ b/DemoApp/DemoAppKotlin/app/src/main/java/co/optable/androidsdkdemo/ui/GAMBanner/GAMBannerFragment.kt
@@ -13,7 +13,6 @@ import android.widget.TextView
import androidx.fragment.app.Fragment
import androidx.lifecycle.Observer
import co.optable.android_sdk.OptableSDK
-import co.optable.android_sdk.OptableWitnessProperties
import co.optable.androidsdkdemo.MainActivity
import co.optable.androidsdkdemo.R
import com.google.android.gms.ads.doubleclick.PublisherAdRequest
@@ -32,14 +31,16 @@ class GAMBannerFragment : Fragment() {
val root = inflater.inflate(R.layout.fragment_gambanner, container, false)
mPublisherAdView = root.findViewById(R.id.publisherAdView)
targetingDataView = root.findViewById(R.id.targetingDataView)
+ targetingDataView.setText("")
var btn = root.findViewById(R.id.loadAdButton) as Button
btn.setOnClickListener {
MainActivity.OPTABLE!!.targeting().observe(viewLifecycleOwner, Observer { result ->
- var msg = "Loading GAM ad with targeting data:\n\n"
+ var msg = targetingDataView.text.toString()
var adRequest = PublisherAdRequest.Builder()
if (result.status == OptableSDK.Status.SUCCESS) {
+ msg += "Loading GAM ad with targeting data:\n\n"
result.data!!.forEach { (key, values) ->
adRequest.addCustomTargeting(key, values)
msg += "${key} = ${values}\n"
@@ -60,9 +61,9 @@ class GAMBannerFragment : Fragment() {
.observe(viewLifecycleOwner, Observer { result ->
var msg = targetingDataView.text.toString()
if (result.status == OptableSDK.Status.SUCCESS) {
- msg += "\n\nSuccess calling witness API to log loadAdButtonClicked event.\n"
+ msg += "\n\nSuccess calling witness API to log loadAdButtonClicked event.\n\n"
} else {
- msg += "\n\nOptableSDK Error: ${result.message}\n"
+ msg += "\n\nOptableSDK Error: ${result.message}\n\n"
}
targetingDataView.setText(msg)
})
diff --git a/README.md b/README.md
index 9e450bd..f9b15a7 100644
--- a/README.md
+++ b/README.md
@@ -2,7 +2,18 @@
Kotlin SDK for integrating with optable-sandbox from an Android application.
-## Installation
+## Contents
+
+- [Installing](#installing)
+- [Using](#using)
+ - [Identify API](#identify-api)
+ - [Targeting API](#targeting-api)
+ - [Witness API](#witness-api)
+ - [Integrating GAM360](#integrating-gam360)
+- [Demo Applications](#demo-applications)
+ - [Building](#building)
+
+## Installing
This SDK is published using [JitPack](https://jitpack.io/), so to add it to your application build, follow the [JitPack How To](https://jitpack.io/).
@@ -36,9 +47,11 @@ dependencies {
Remember to replace `VERSION_TAG` with the latest or desired [SDK release](https://github.com/Optable/optable-android-sdk/releases).
-## Using (Kotlin)
+## Using
+
+To configure an instance of the SDK integrating with an [Optable](https://optable.co/) sandbox running at hostname `sandbox.customer.com`, from a configured application origin identified by slug `my-app`, you can instantiate the SDK from an Activity or Application `Context`, such as for example the following application `MainActivity`:
-To configure an instance of the SDK integrating with an [Optable](https://optable.co/) sandbox running at hostname `sandbox.customer.com`, from a configured application origin identified by slug `my-app`, you can instantiate the SDK from an Activity `Context`, such as for example the following application `MainActivity`:
+Kotlin:
```kotlin
import co.optable.android_sdk.OptableSDK
@@ -59,9 +72,30 @@ class MainActivity : AppCompatActivity() {
}
```
+Java:
+
+```java
+import co.optable.android_sdk.OptableSDK;
+...
+
+public class MainActivity extends AppCompatActivity {
+ public static OptableSDK OPTABLE;
+ ...
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_main);
+ ...
+ MainActivity.OPTABLE = new OptableSDK(this.getApplicationContext(),
+ "sandbox.customer.com", "my-app");
+ ...
+ }
+}
+```
+
You can then call various SDK APIs on the instance as shown in the examples below. It's also possible to configure multiple instances of `OptableSDK` in order to connect to other (e.g., partner) sandboxes and/or reference other configured application slug IDs.
-Note that all SDK communication with Optable sandboxes is done over TLS. The only exception to this is if you instantiate the `OptableSDK` class with a fourth optional boolean parameter, `insecure`, set to `true`. For example:
+Note that all SDK communication with Optable sandboxes is done over TLS. The only exception to this is if you instantiate the `OptableSDK` class with a fourth optional boolean parameter, `insecure`, set to `true`. For example, in Kotlin:
```kotlin
MainActivity.OPTABLE = OptableSDK(this, "sandbox.customer.com", "my-app", true)
@@ -73,6 +107,8 @@ However, since production sandboxes only listen to TLS traffic, the above is rea
To associate a user device with an authenticated identifier such as an Email address, or with other known IDs such as the Google Advertising ID, or even your own vendor or app level `PPID`, you can call the `identify` API as follows:
+Kotlin:
+
```kotlin
import co.optable.android_sdk.OptableSDK
import my.org.app.MainActivity
@@ -97,6 +133,31 @@ MainActivity.OPTABLE!!
})
```
+Java:
+
+```java
+import co.optable.android_sdk.OptableSDK;
+import co.optable.demoappjava.MainActivity;
+import android.util.Log;
+...
+
+String emailString = "some.email@address.com";
+Boolean sendGoogleAdIDBoolean = true;
+String ppid = "my-id-123";
+
+MainActivity.OPTABLE
+ .identify(emailString, sendGoogleAdIDBoolean, ppid)
+ .observe(getViewLifecycleOwner(), result -> {
+ if (result.getStatus() == OptableSDK.Status.SUCCESS) {
+ Log.i(null, "Identify API Success");
+ } else {
+ // result.getStatus() is OptableSDK.Status.ERROR
+ // result.getMessage() is the error message
+ Log.e(null, "Identify API Error: " + result.getMessage());
+ }
+ });
+```
+
The SDK `identify()` method will asynchronously connect to the configured sandbox and send IDs for resolution. The second (`sendGoogleAdIDBoolean`) and third (`ppid`) arguments to `identify()` are optional. You can register an observer to understand successful completion or errors.
> :warning: **Client-Side Email Hashing**: The SDK will compute the SHA-256 hash of the Email address on the client-side and send the hashed value to the sandbox. The Email address is **not** sent by the device in plain text.
@@ -109,6 +170,8 @@ The frequency of invocation of `identify` is up to you, however for optimal iden
To get the targeting key values associated by the configured sandbox with the device in real-time, you can call the `targeting` API as follows:
+Kotlin:
+
```kotlin
import co.optable.android_sdk.OptableSDK
import my.org.app.MainActivity
@@ -132,20 +195,45 @@ MainActivity.OPTABLE!!
})
```
+Java:
+
+```java
+import co.optable.android_sdk.OptableSDK;
+import co.optable.demoappjava.MainActivity;
+import android.util.Log;
+...
+MainActivity.OPTABLE
+ .targeting()
+ .observe(getViewLifecycleOwner(), result -> {
+ if (result.getStatus() == OptableSDK.Status.SUCCESS) {
+ Log.i(null, "Targeting API Success... ");
+
+ result.getData().forEach((key, values) -> {
+ Log.i(null, "Targeting KV: " + key.toString() + " = " + values.toString());
+ });
+ } else {
+ // result.getStatus() is OptableSDK.Status.ERROR
+ // result.getMessage() is the error message
+ Log.e(null, "Targeting API Error: " + result.getMessage());
+ }
+ });
+```
+
On success, the resulting key values are typically sent as part of a subsequent ad call. Therefore we recommend that you either call `targeting()` before each ad call, or in parallel periodically, caching the resulting key values which you then provide in ad calls.
### Witness API
To send real-time event data from the user's device to the sandbox for eventual audience assembly, you can call the witness API as follows:
+Kotlin:
+
```kotlin
import co.optable.android_sdk.OptableSDK
-import co.optable.android_sdk.OptableWitnessProperties
import my.org.app.MainActivity
import android.util.Log
...
MainActivity.OPTABLE!!
- .witness("example.event.type", hashMapOf("example" to "value"))
+ .witness("example.event.type", hashMapOf("exampleKey" to "exampleValue"))
.observe(viewLifecycleOwner, Observer { result ->
if (result.status == OptableSDK.Status.SUCCESS) {
Log.i("Witness API Success... ")
@@ -157,14 +245,38 @@ MainActivity.OPTABLE!!
})
```
-The specified event type and properties are associated with the logged event and which can be used for matching during audience assembly.
+Java:
+
+```java
+import co.optable.android_sdk.OptableSDK;
+import co.optable.demoappjava.MainActivity;
+import android.util.Log;
+import java.util.HashMap;
+...
+HashMap eventProperties = new HashMap();
+eventProperties.put("exampleKey", "exampleValue");
+
+MainActivity.OPTABLE
+ .witness("example.event.type", eventProperties)
+ .observe(getViewLifecycleOwner(), result -> {
+ if (result.getStatus() == OptableSDK.Status.SUCCESS) {
+ Log.i(null, "Witness API Success... ");
+ } else {
+ // result.getStatus() is OptableSDK.Status.ERROR
+ // result.getMessage() is the error message
+ Log.e(null, "Witness API Error: " + result.getMessage());
+ }
+ });
+```
-Note that event properties are of type `OptableWitnessProperties` which is an alias for `HashMap`, and should consist only of string keyvalue pairs.
+The specified event type and properties are associated with the logged event and which can be used for matching during audience assembly. The optional witness event properties are of type `OptableWitnessProperties` which is an alias for `HashMap`, and should consist only of string key-value pairs.
### Integrating GAM360
We can further extend the above `targeting` example to show an integration with a [Google Ad Manager 360](https://admanager.google.com/home/) ad server account:
+Kotlin:
+
```kotlin
import co.optable.android_sdk.OptableSDK
import my.org.app.MainActivity
@@ -199,14 +311,48 @@ MainActivity.OPTABLE!!
})
```
-A working example is available in the demo application.
+Java:
+
+```java
+import co.optable.android_sdk.OptableSDK;
+import co.optable.demoappjava.MainActivity;
+import android.util.Log;
+import com.google.android.gms.ads.doubleclick.PublisherAdRequest;
+import com.google.android.gms.ads.doubleclick.PublisherAdView;
+...
+MainActivity.OPTABLE.targeting().observe(getViewLifecycleOwner(), result -> {
+ // Build GAM360 ad request:
+ PublisherAdRequest.Builder adRequest = new PublisherAdRequest.Builder();
+
+ if (result.getStatus() == OptableSDK.Status.SUCCESS) {
+ Log.i(null, "Targeting API Success... ");
+
+ // result.getData() can be iterated to get targeting key values:
+ result.getData().forEach((key, values) -> {
+ // Add key values to GAM360 ad request:
+ adRequest.addCustomTargeting(key, values);
+ Log.i(null, "Targeting KV: " + key.toString() + " = " + values.toString());
+ });
+ } else {
+ // result.getStatus() is OptableSDK.Status.ERROR
+ // result.getMessage() is the error message
+ Log.e(null, "Targeting API Error: " + result.getMessage());
+ }
+
+ // Assuming pubAdView refers to a pre-configured instance of
+ // com.google.android.gms.ads.doubleclick.PublisherAdView:
+ pubAdView.loadAd(adRequest.build());
+});
+```
+
+Working examples are available in the Kotlin and Java SDK demo applications.
-## Demo App
+## Demo Applications
-The demo application shows a working example of both `identify` and `targeting` APIs, as well as an integration with the [Google Ad Manager 360](https://admanager.google.com/home/) ad server, enabling the targeting of ads served by GAM360 to audiences activated in the [Optable](https://optable.co/) sandbox.
+The Kotlin and Java demo applications show a working example of `identify`, `targeting`, and `witness` APIs, as well as an integration with the [Google Ad Manager 360](https://admanager.google.com/home/) ad server, enabling the targeting of ads served by GAM360 to audiences activated in the [Optable](https://optable.co/) sandbox.
-By default, the demo application will connect to the [Optable](https://optable.co/) demo sandbox at `sandbox.optable.co` and reference application slug `android-sdk-demo`. The demo app depends on the [GAM Mobile Ads SDK for Android](https://developers.google.com/ad-manager/mobile-ads-sdk/android/quick-start) and loads ads from a GAM360 account operated by [Optable](https://optable.co/).
+By default, the demo applications will connect to the [Optable](https://optable.co/) demo sandbox at `sandbox.optable.co` and reference application slug `android-sdk-demo`. The demo apps depend on the [GAM Mobile Ads SDK for Android](https://developers.google.com/ad-manager/mobile-ads-sdk/android/quick-start) and load ads from a GAM360 account operated by [Optable](https://optable.co/).
### Building
-From [Android Studio](https://developer.android.com/studio), navigate to `File > Open` and open the `DemoApp/DemoAppKotlin` directory. You should be able to build and run the resulting project directly, since it will automatically download the `co.optable.android_sdk` library from [JitPack](https://jitpack.io/) Maven repository.
+To build the Kotlin demo app, from [Android Studio](https://developer.android.com/studio), navigate to `File > Open` and open the `DemoApp/DemoAppKotlin` directory. To build the Java demo app, open the `DemoApp/DemoAppJava` directory. In both cases, you should be able to build and run the resulting project directly, since it will automatically download the `co.optable.android_sdk` library from the [JitPack](https://jitpack.io/) Maven repository.
diff --git a/android_sdk/src/main/java/co/optable/android_sdk/OptableSDK.kt b/android_sdk/src/main/java/co/optable/android_sdk/OptableSDK.kt
index 7b993e8..e306f1a 100644
--- a/android_sdk/src/main/java/co/optable/android_sdk/OptableSDK.kt
+++ b/android_sdk/src/main/java/co/optable/android_sdk/OptableSDK.kt
@@ -60,7 +60,7 @@ typealias OptableTargetingResponse = HashMap>
* unique to the app across devices.
*/
-class OptableSDK(context: Context, host: String, app: String, insecure: Boolean = false) {
+class OptableSDK @JvmOverloads constructor(context: Context, host: String, app: String, insecure: Boolean = false) {
val config = Config(host, app, insecure)
val client = Client(config, context)
@@ -140,6 +140,7 @@ class OptableSDK(context: Context, host: String, app: String, insecure: Boolean
* comparing result.status to OptableSDK.Status.SUCCESS. Note that result.data!! will point
* to an empty HashMap on success, and can therefore be ignored.
*/
+ @JvmOverloads
fun identify(email: String, gaid: Boolean? = false, ppid: String? = null):
LiveData>
{