class Teak

Teak.

Static Attributes

Name Type Description

JOB_ID

final int

The default id Teak uses for android.app.job.JobInfo.

SDKVersion

final String

Version of the Teak SDK.

Version

final Map<String, Object>

Version of the Teak SDK, and Unity/Cocos2dx SDK if applicable.

MajorMinorRevision

final int[]

Version of the Teak SDK, as an array [major, minor, revision].

forceDebug

boolean

Force debug print on/off.

OPT_OUT_IDFA

final String

Value provided to identifyUser(String, String[]) to opt out of collecting an IDFA for this specific user.

OPT_OUT_FACEBOOK

final String

Value provided to identifyUser(String, String[]) to opt out of collecting a Facebook Access Token for this specific user.

OPT_OUT_PUSH_KEY

final String

Value provided to identifyUser(String, String[]) to opt out of collecting a Push Key for this specific user.

TEAK_NOTIFICATIONS_ENABLED

final int

Notifications are enabled.

TEAK_NOTIFICATIONS_DISABLED

final int

Notifications are disabled.

TEAK_NOTIFICATIONS_UNKNOWN

final int

Notification status is not known.

Static Methods

isEnabled

Is Teak enabled?

boolean isEnabled();

Return

True if Teak is enabled; False if Teak has not been initialized, or is disabled.

onCreate

Initialize Teak and tell it to listen to the lifecycle events of Activity.

void onCreate(@NonNull Activity activity);

Call this function from the Activity#onCreate function of your Activity before the call to super.onCreate()

Parameters

Name Description

activity

The main Activity of your app.

identifyUser

Tell Teak how it should identify the current user.

void identifyUser(final String userIdentifier);

This will also begin tracking and reporting of a session, and track a daily active user.

This should be the same way you identify the user in your backend.

Parameters

Name Description

userIdentifier

An identifier which is unique for the current user.

identifyUser

Tell Teak how it should identify the current user.

void identifyUser(final String userIdentifier,
                  final String email);

This will also begin tracking and reporting of a session, and track a daily active user.

This should be the same way you identify the user in your backend.

Parameters

Name Description

userIdentifier

An identifier which is unique for the current user.

email

The email address for the user.

identifyUser

Tell Teak how it should identify the current user, with data collection opt-out.

void identifyUser(final String userIdentifier,
                  final String[] optOut);

This will also begin tracking and reporting of a session, and track a daily active user.

This should be the same way you identify the user in your backend.

Parameters

Name Description

userIdentifier

An identifier which is unique for the current user.

optOut

A list containing zero or more of: OPT_OUT_IDFA, OPT_OUT_FACEBOOK, OPT_OUT_PUSH_KEY

identifyUser

Tell Teak how it should identify the current user, with data collection opt-out and email.

void identifyUser(final String userIdentifier,
                  final String[] optOut,
                  final String email);

This will also begin tracking and reporting of a session, and track a daily active user.

This should be the same way you identify the user in your backend.

Parameters

Name Description

userIdentifier

An identifier which is unique for the current user.

optOut

A list containing zero or more of: OPT_OUT_IDFA, OPT_OUT_FACEBOOK, OPT_OUT_PUSH_KEY

email

The email address for the user.

identifyUser

Tell Teak how it should identify the current user, with additional options and configuration.

void identifyUser(final String userIdentifier,
                  final UserConfiguration userConfiguration);

This will also begin tracking and reporting of a session, and track a daily active user.

This should be the same way you identify the user in your backend.

Parameters

Name Description

userIdentifier

An identifier which is unique for the current user.

userConfiguration

A set of configuration keys and value.

logout

Logout the current user.

void logout();

deleteEmail

Delete any email address associated with the current user.

void deleteEmail();

setChannelState

Set the state of a Teak Marketing Channel.

Future<Channel.Reply> setChannelState(final Channel.Type channel,
                                            final Channel.State state);

You may only assign the values Teak.Channel.State#OptOut and Teak.Channel.State#Available to Push Channels; Channel.State#OptIn is not allowed.

Parameters

Name Description

channel

The channel being modified.

state

The state for the channel.

setCategoryState

Set the state of a Teak Marketing Channel Category.

Future<Channel.Reply> setCategoryState(final Channel.Type channel,
                                             final String category,
                                             final Channel.State state);

You may only assign the values Channel.State#OptOut and Channel.State#Available.

Parameters

Name Description

channel

The channel being modified.

category

The category being modified.

state

The state for the channel.

trackEvent

Track an arbitrary event in Teak.

void trackEvent(final String actionId,
                final String objectTypeId,
                final String objectInstanceId);

Parameters

Name Description

actionId

The identifier for the action, e.g. 'complete'.

objectTypeId

The type of object that is being posted, e.g. 'quest'.

objectInstanceId

The specific instance of the object, e.g. 'gather-quest-1'

incrementEvent

Increment the value an arbitrary event in Teak.

void incrementEvent(final String actionId,
                    final String objectTypeId,
                    final String objectInstanceId,
                    final long count);

Parameters

Name Description

actionId

The identifier for the action, e.g. 'complete'.

objectTypeId

The type of object that is being posted, e.g. 'quest'.

objectInstanceId

The specific instance of the object, e.g. 'gather-quest-1'

count

The amount by which to increment.

getNotificationStatus

Has the user disabled notifications for this app.

int getNotificationStatus();

Return

true if the device is above API 19 and the user has disabled notifications, false otherwise.

This will always return false for any device below API 19.

canOpenSettingsAppToThisAppsSettings

Determine if Teak can open the settings app to the settings for this app.

boolean canOpenSettingsAppToThisAppsSettings();

Return

true if Teak will be able to open the settings, false otherwise.

openSettingsAppToThisAppsSettings

Open the settings app to the settings for this app.

boolean openSettingsAppToThisAppsSettings();

Return

true if Teak was (probably) able to open the settings, false if Teak was (probably) not able to open the settings.

This will always return false for any device below API 19.

Be sure to prompt the user to re-enable notifications for your app before calling this function.

canOpenNotificationSettings

Determine if the current device is able to open directly to the notificaton settings for this app.

boolean canOpenNotificationSettings();

Return

true if Teak will be able to open the notification settings, false otherwise.

openNotificationSettings

Open the settings app to the notification settings for this app.

boolean openNotificationSettings();

Return

true if Teak was able to open the notification settings, false if Teak was not able to open the settings.

This will always return false for any device below API 26.

openNotificationSettings

Open the settings app to the notification settings for this app.

boolean openNotificationSettings(String channelId);

Return

true if Teak was able to open the notification settings, false if Teak was not able to open the settings.

This will always return false for any device below API 26.

Parameters

Name Description

channelId

The specific channel id to open the settings to.

setApplicationBadgeNumber

Set the badge number on the icon of the application.

boolean setApplicationBadgeNumber(int count);

Return

true if Teak was able to set the badge number, false otherwise.

Set the count to 0 to remove the badge.

Parameters

Name Description

count

The value to set as the badge number.

setNumericAttribute

Track a numeric player profile attribute.

void setNumericAttribute(final String attributeName,
                         final double attributeValue);

Parameters

Name Description

attributeName

The name of the numeric attribute.

attributeValue

The numeric value to assign.

setStringAttribute

Track a string player profile attribute.

void setStringAttribute(final String attributeName,
                        final String attributeValue);

Parameters

Name Description

attributeName

The name of the string attribute.

attributeValue

The string value to assign.

getDeviceConfiguration

Get Teak’s configuration data about the current device.

String getDeviceConfiguration();

Return

JSON string containing device info, or null if it’s not ready

getAppConfiguration

Get Teak’s configuration data about the current app.

String getAppConfiguration();

Return

JSON string containing device info, or null if it’s not ready

registerDeepLink

Register a deep link route with Teak.

void registerDeepLink(@NonNull String route,
                      @NonNull String name,
                      @NonNull String description,
                      @NonNull Teak.DeepLink call);

Parameters

Name Description

route

A Sinatra-style route, eg /path/:capture

name

The name of the deep link, used in the Teak dashboard

description

The description of the deep link, used in the Teak dashboard

call

The code to invoke when this deep link is received

setLogListener

Listen for Teak SDK log events.

void setLogListener(LogListener logListener);

Parameters

Name Description

logListener

A LogListener that will be called each time Teak would log an internal SDK event.

processDeepLinks

Logging.

void processDeepLinks();

Indicate that your app is ready for deep links.Deep links will not be processed sooner than the earliest of:

handleDeepLinkPath

Manually pass Teak a deep link path to handle.

boolean handleDeepLinkPath(final String path);

Return

true if the deep link was found and handled.

This path should be prefixed with a forward slash, and can contain query parameters, e.g. /foo/bar?fizz=buzz It should not contain a host, or a scheme.This function will only execute deep links that have been defined through Teak. It has no visibility into any other SDKs or custom code.

Parameters

Name Description

path

The deep link path to process.