Documentation

Unity Android

This details the steps that need to be taken once you have access to our Android Cashback Keyboard SDK, in order to have a functional custom keyboard with onboarding sequence integrated into your Unity app.

Before Starting

Please contact Tappa to:

Get your CampaignID, without it, you will not be able to use the framework

1. Add Dependency Repositories

These following repositories must be added:

  1. https://repo.tappa.com/repository/maven-releases/ - artefact repository hosting the Tappa Keyboard SDK
  2. https://adsbynimbus-public.s3.amazonaws.com/android/sdks - Nimbus SDK used by the Tappa Keyboard SDK to deliver ads
  3. https://jitpack.io - public artefact repository which hosts other libraries that the SDK depends on

If dependency repositories in your Android project are set in settings.gradle add the following into it:

dependencyResolutionManagement {
	repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
	repositories {
		google()
		mavenCentral()
		maven { url 'https://jitpack.io' }
		// Tappa SDK
		maven {
			url = uri("https://repo.mocha.global/repository/maven-releases/")
		}
		// Nimbus SDK
		maven {
			url = uri("https://adsbynimbus-public.s3.amazonaws.com/android/sdks")
			credentials {
				username = "*"
			}
			content {
				includeGroup("com.adsbynimbus.openrtb")
				includeGroup("com.adsbynimbus.android")
				includeGroup("com.iab.omid.library.adsbynimbus")
			}
		}
	}
}

Otherwise define the repositories in the project-level build.gradle file:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
        maven {
            url "https://repo.tappa.com/repository/maven-releases/"
        }
        ...
    }
    ...
}

2. Configure Project Settings

  • Open Edit > Project Settings > Player.
  • Set the Minimum API Level to Android 6.0 (API level 23) or higher.
  • Enable Custom Main Manifest under Publishing Settings to ensure the Android manifest can be modified.

3. Set Java 17 Compatibility

android {
    compileSdk 34
    defaultConfig {
        minSdk 23
        targetSdk 33
        ...
    }
    ...
}

4. Enable Android Data Binding

The SDK uses Android data binding, therefore it needs to be enabled in your project in your app build.gradle file:

android {
      buildFeatures {
          dataBinding true
    }
    ...
}

5. Add the Tappa Keyboard SDK Dependency

Add the dependency in your app build.gradle file:

dependencies {
	def SDK_VERSION = "3.+"

	// Tappa Keyboard SDK
	implementation "com.mocha.keyboard:keyboard-sdk:$SDK_VERSION"
	implementation "com.tappa:sdk:$SDK_VERSION"

	// Buttons
	implementation "com.mocha.keyboard:brand-logo-button:$SDK_VERSION"
	implementation "com.mocha.keyboard:clipboard-button:$SDK_VERSION"
	implementation "com.mocha.keyboard:social-hub:$SDK_VERSION"
	implementation "com.mocha.keyboard:themes-button:$SDK_VERSION"
	implementation "com.mocha.keyboard:web-link-button:$SDK_VERSION"
	implementation "com.mocha.keyboard:speech-to-text-button:$SDK_VERSION"
}

The SDK_VERSION is defined separately so it can be conveniently used across multiple dependencies. For example some toolbar buttons are provided as part of their own modules. The version must always be the same as the Cashback Keyboard SDK version.

6. Initialize the SDK

using TappaKeyboard;

public class GameManager : MonoBehaviour
{
    void Start()
    {
        TappaSDK.Initialize("YOUR_CAMPAIGN_ID");
    }
}

Replace "YOUR_CAMPAIGN_ID" with the campaign identifier obtained in step 1.

7. Override Keyboard System Names

Create a new file named tappa_strings.xml in the Assets/Plugins/Android/res/values folder (create the folder structure if it doesn't exist) with the following content:

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="mocha_keyboard_name">Tappa Unity Keyboard</string>
    <string name="mocha_spell_checker_name">Tappa Unity Spell Checker</string>
    <string name="mocha_spell_checker_settings_name">Tappa Unity Spell Checker Settings</string>
</resources>

8. Activate The Keyboard

To start the keyboard activation process, use the following code in your Unity script:

TappaSDK.LaunchActivation();

You can check the keyboard activation state using:

bool isEnabled = TappaSDK.IsKeyboardEnabled();
bool isCurrent = TappaSDK.IsKeyboardCurrent();

9. Building for Android

When building your Unity project for Android:

  1. Go to File > Build Settings > Android.
  2. Click on "Player Settings" and ensure that:
    • Minimum API Level is set to Android 6.0 or higher
    • Scripting Backend is set to IL2CPP
    • Target Architectures include both ARMv7 and ARM64