Message Subscription
Request the player's permission to subscribe to notifications from your mini game.
TT.RequestSubscribeMessage(param)
Shows a prompt asking the player to subscribe to notifications from your mini game. Requires TikTok version 44.9.0 or later. Before calling this method, check CanIUse.RequestSubscribeMessage.
Signature
public static void RequestSubscribeMessage(TTRequestSubscribeMessageParam param = null)Parameters
Field | Type | Description | Required |
|
| Whether the player explicitly chose to subscribe, for example by tapping a subscribe button. Defaults to | No |
|
| Called when the API call succeeds. | No |
|
| Called when the API call fails. | No |
|
| Called after | No |
TTRequestSubscribeMessageResult
Field | Type | Description |
|
| The player's choice: |
Note: A success or complete callback doesn't mean the player accepted. Check isSubscribeConfirmed.
Example
The following handler requests a subscription when the player taps a subscribe button:
public void OnSubscribeButtonClicked()
{
if (!CanIUse.RequestSubscribeMessage)
{
Debug.LogWarning("Message subscription is unavailable.");
return;
}
TT.RequestSubscribeMessage(new TTRequestSubscribeMessageParam
{
isManualSubscribe = true,
success = result =>
{
switch (result?.isSubscribeConfirmed)
{
case "accept":
Debug.Log("User accepted the subscription request.");
break;
case "reject":
Debug.Log("User declined the subscription request.");
break;
default:
Debug.LogWarning("Unknown subscription result.");
break;
}
},
fail = error => Debug.LogError(error.ErrMsg),
complete = result => Debug.Log("Subscription request finished.")
});
}For version details, see the SDK 0.21.0 / TikTok 44.9.0 changelog entry.