class Teak

A MonoBehaviour which can be attached to a Unity GameObject to provide access to Teak functionality.

Static Attributes

Name Type Description

OptOutIdfa

const string

Value provided to IdentifyUser to opt out of collecting an IDFA for this specific user.

OptOutPushKey

const string

Value provided to IdentifyUser to opt out of collecting a Push Key for this specific user.

OptOutFacebook

const string

Value provided to IdentifyUser to opt out of collecting a Facebook Access Token for this specific user.

Methods

SetChannelState

Assign the opt-out state for a Teak marketing channel.

IEnumerator SetChannelState(Channel.Type channel,
                            Channel.State state,
                            System.Action<Channel.Reply> callback);

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

Parameters

Name Description

channel

The channel to which the new state is being assigned.

state

The opt-out state to assign to the marketing channel.

callback

A callback by which you will be informed of the result of the method.

SetCategoryState

Assign the opt-out state for a category on a Teak marketing channel.

IEnumerator SetCategoryState(Channel.Type channel,
                             string category,
                             Channel.State state,
                             System.Action<Channel.Reply> callback);

You may only assign the values Teak.Channel.Type.OptOut and Teak.Channel.Type.Available to categories.

Parameters

Name Description

channel

The channel to which the new state is being assigned.

category

The category in the channel to which the new state is being assigned.

state

The opt-out state to assign to the category.

callback

A callback by which you will be informed of the result of the method.

IdentifyUser

Tell Teak how it should identify the current user.

void IdentifyUser(string userIdentifier,
                  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 current user.

IdentifyUser

Tell Teak how it should identify the current user.

void IdentifyUser(string userIdentifier,
                  List<string> optOut,
                  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: OptOutIdfa, OptOutPushKey, OptOutFacebook

email

The email address for the current user.

IdentifyUser

Tell Teak how it should identify the current user.

void IdentifyUser(string userIdentifier,
                  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

Additional configuration for the current user.

Logout

Logout the current user.

void Logout();

RefreshPushTokenIfAuthorized

On iOS, if 'TeakDoNotRefreshPushToken' is set to 'true' then this method will tell Teak that the push token is ready, and that the user has authorized push notifications. If the user has not authorized push notifications, this will have no effect.

void RefreshPushTokenIfAuthorized();

TrackEvent

Track an arbitrary event in Teak.

void TrackEvent(string actionId,
                string objectTypeId,
                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 an arbitrary event in Teak.

void IncrementEvent(string actionId,
                    string objectTypeId,
                    string objectInstanceId,
                    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

RegisterRoute

Method used to register a deep link route.

void RegisterRoute(string route,
                   string name,
                   string description,
                   Action<Dictionary<string, object>> action);

Parameters

Name Description

route

The route for this deep link.

name

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

description

A description for what this deep link does, used in the Teak dashboard.

action

A function, or lambda to execute when this deep link is invoked via a notification or web link.

SetBadgeCount

Method to set the number displayed on the icon of the app on the home screen.

bool SetBadgeCount(int count);

Return

True if Teak was able to set the badge count, false otherwise.

Parameters

Name Description

count

The number to display on the icon of the app on the home screen, or 0 to clear.

OpenSettingsAppToThisAppsSettings

Open the settings for your app.

bool OpenSettingsAppToThisAppsSettings();

Return

false if Teak was unable to open the settings for your app, true otherwise.

OpenNotificationSettings

Open the notification settings for your app.

bool OpenNotificationSettings();

Return

false if Teak was unable to open the notification settings for your app, true otherwise.

DeleteEmail

Delete the email address associated with the current user.

void DeleteEmail();

SetNumericAttribute

Assign a numeric value to a user profile attribute

void SetNumericAttribute(string key,
                         double value);

Parameters

Name Description

key

The name of the numeric attribute.

value

The value for the numeric attribute.

SetStringAttribute

Assign a string value to a user profile attribute

void SetStringAttribute(string key,
                        string value);

Parameters

Name Description

key

The name of the string attribute.

value

The value for the string attribute.

GetDeviceConfiguration

Get Teak’s configuration data about the current device.

Dictionary<string, object> GetDeviceConfiguration();

Return

A dictionary containing device info, or null if it’s not ready

GetNotificationRegistration

Get push notification registration information from Teak.

Dictionary<string, object> GetNotificationRegistration();

Return

A dictionary containing push registration info, or null if it’s not ready

This dictionary is in the the format:

{"key" : <"key as a string>", "type" : "<apns | gcm | adm>", "extras" : {}}

The only current value inside extras is gcm_sender_id if type is 'gcm'

RegisterForProvisionalNotifications

Register for Provisional Push Notifications.

bool RegisterForProvisionalNotifications();

Return

true if the device was an iOS 12+ device

This method only has any effect on iOS devices running iOS 12 or higher.

RegisterForNotifications

Please use RegisterForNotifications(System.Action) instead.

Register for Push Notifications.

void RegisterForNotifications();

This is a compatibility method which simply wraps RegisterForNotifications(System.Action) in a StartCoroutine()

RegisterForNotifications

Register for Push Notifications.

IEnumerator RegisterForNotifications(System.Action<bool> callback);

This is a Coroutine and will not return until the player grants or denies push permissions.

Parameters

Name Description

callback

The callback will be called with true if the player granted push permissions and false if the player denied push permissions.

ProcessDeepLinks

Indicate that your app is ready for deep links.

void ProcessDeepLinks();

Deep links will not be processed sooner than the earliest of:

HandleDeepLinkPath

Manually pass Teak a deep link path to evalute.

bool HandleDeepLinkPath(string url);

Return

true if the deep link was handled by Teak.

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

url

The url to attempt handling.

ReportCanvasPurchase

When using Facebook Payments, call this method from your callback for

void ReportCanvasPurchase(string rawResult);

FB.Canvas.Pay or FB.Canvas.PayWithProductId.

Parameters

Name Description

rawResult

The contents of IPayResult.RawResult

Static Methods

Init

Manually initialize Teak.

Teak Init();

Under normal circumstances it is not necessary to call this, and you can simply use Teak.Instance (which calls this method).

Properties

Name Type Description Access

Instance

Gets the Teak singleton.

Get

Version

string

Teak SDK version.

Get

AppId

string

Teak App Id.

Get/Set

APIKey

string

Teak API Key.

Get/Set

UNIXNow

long

UNIX Timestamp.

Get

UserId

string

The user identifier for the current user.

Get

PushNotificationState

State of push notifications.

Get

AppConfiguration

Dictionary<string, object>

Get Teak’s configuration data about the current app.

Get

Trace

bool

Teak will log all Unity method calls to the Unity log if true.

Get/Set

CanOpenSettingsAppToThisAppsSettings

bool

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

Get

CanOpenNotificationSettings

bool

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

Get

Events

OnLaunchedFromNotification

An event which gets fired when the app is launched via a push notification.

System.Action<TeakNotification> OnLaunchedFromNotification;

OnReward

An event which gets fired when a Teak Reward has been processed (successfully or unsuccessfully).

System.Action<TeakReward> OnReward;

OnForegroundNotification

An event which gets fired when a push notification is received while the app is in the foreground.

System.Action<TeakNotification> OnForegroundNotification;

OnConfigurationData

An event which gets fired when Teak remote configuration is ready.

System.Action<ConfigurationData> OnConfigurationData;

OnLogEvent

An event which is dispatched for each log event from the Teak SDK

System.Action<Dictionary<string, object>> OnLogEvent;

OnAdditionalData

An event which is dispatched when additional data is available for the current user.

System.Action<Dictionary<string, object>> OnAdditionalData;

OnUserData

An event which is dispatched when user data becomes available or is changed.

System.Action<Teak.UserData> OnUserData;

OnLaunchedFromLink

An event which is dispatched when the app is launched from a link created by the Teak dashboard.

System.Action<Dictionary<string, object>> OnLaunchedFromLink;

OnPostLaunchSummary

An event which is dispatched each time the app is launched, with info about the launch.

System.Action<TeakPostLaunchSummary> OnPostLaunchSummary;

OnCallbackError

An event which is dispatched when your code, executed via deep link callback, throws an exception.

System.Action<string, Exception, Dictionary<string, object>> OnCallbackError;

Enums

NotificationState

Possible push notification states.

Name Description

UnableToDetermine

Unable to determine the notification state.

Enabled

Notifications are enabled, your app can display notifications.

Disabled

Notifications are disabled, your app cannot display notifications.

Provisional

Provisional notifications are enabled, your app can receive notifications but they will only display in the Notification Center (iOS 12+ only).

NotRequested

The user has not been asked to authorize notifications (iOS only). On Android the NotificationState will be Disabled if permissions have never been requested, due to OS limitations.