TikTok for Developers

Developer Docs

Last updated October 5, 2026

App Lifecycle

Monitor and respond to app lifecycle events such as foreground, background, and exit attempts.

TT.GetAppLifeCycle()

Returns the current application lifecycle state.

Signature

public static string GetAppLifeCycle()

Returns

Type

Description

string

Current lifecycle state (e.g., show, hide)

TT.SetOnBeforeExitAppListener(callback)

Registers a listener that is invoked before the app exits. The callback can influence whether the exit proceeds.

Signature

public static void SetOnBeforeExitAppListener(Action<BeforeExitAppParam> callback)

Parameters

Field

Type

Description

Required

callback

Action<BeforeExitAppParam>

Callback invoked before exit. BeforeExitAppParam contains a cancel field that can be set to true to prevent the exit

Yes

Example

TT.SetOnBeforeExitAppListener(param =>
{
    // Set cancel to true to prevent the app from exiting
    param.cancel = true;
    Debug.Log("Exit prevented by listener");
});
TikTok for Developers