Skip to main content

Embedded Moments Guide

In this article, we will introduce how you can add TapTap Embedded Moments to your game. Embedded Moments depends on TapTap Login, which requires the TapMoment module.

Installing SDK


If you are coming from TapSDK Quickstart and have already initialized the SDK, you can add the TapMoment module of the TapSDK obtained from the Downloads page:

// Embedded Moments

Setting up Callbacks

You can set up a callback to capture status updates:

TapMoment.SetCallback((code, msg) => {
Debug.Log(code + "---" + msg);

The code in the callback function refers to the type of the event. The following types of events are supported:

CALLBACK_CODE_PUBLISH_SUCCESS10000Moment posted successfully.
CALLBACK_CODE_PUBLISH_FAIL10100Failed to post the moment.
CALLBACK_CODE_PUBLISH_CANCEL10200The page for posting moments is closed.
CALLBACK_CODE_GET_NOTICE_SUCCESS20000Notifications retrieved successfully.
CALLBACK_CODE_GET_NOTICE_FAIL20100Failed to retrieve notifications.
CALLBACK_CODE_MOMENT_APPEAR30000Embedded Moments is opened.
CALLBACK_CODE_MOMENT_DISAPPEAR30100Embedded Moments is closed.
CALLBACK_CODE_CLOSE_CANCEL50000The user refused to close all the Embedded Moments pages (the “Cancel” button on the pop-up is tapped).
CALLBACK_CODE_CLOSE_CONFIRM50100The user confirmed to close all the Embedded Moments pages (the “Confirm” button on the pop-up is tapped).
CALLBACK_CODE_LOGIN_SUCCESS60000Logged in successfully.
CALLBACK_CODE_SCENE_EVENT70000Callback for scenario-based portals.

Retrieving Notifications

You can periodically call the API to retrieve unread notifications. When there are unread notifications available, you can display a badge on the button for Embedded Moments to remind the player to check the notifications.


The result of retrieving unread notifications will be available in the callback function mentioned earlier. If you get CALLBACK_CODE_GET_NOTICE_SUCCESS (20000) for the code, that means the notifications are retrieved successfully. CALLBACK_CODE_GET_NOTICE_FAIL (20100) means the SDK failed to retrieve the notifications. If the notifications are retrieved successfully, msg will be the number of unread notifications. When msg is 0, it means there are no unread notifications.


To make it easier for the player to view what you and their friends have posted, we suggest that you put the button for Embedded Moments on a prominent position in your game and retrieve unread notifications once a minute.

When retrieving notifications, if there are no unread notifications (msg equals 0), you can remove the badge displayed on the button. You should also remove the badge once the player opens Embedded Moments.

Displaying Embedded Moments

You can call the following API to display Embedded Moments in your game. Here the player can view the moments posted by other players and post their own as well.


Embedded Moments might contain videos that have sounds. Therefore, please mute the sounds from the game itself when the Embedded Moments is opened.

To make Embedded Moments rotate along with the device, your game has to support rotation as well.

Don’t forget to remove the badge after the player opens the Embedded Moments.

The following picture shows how you can customize the background image of the Embedded Moments page in your game. The background image will be reviewed before the players can see them.

Scenario-Based Portals

With Scenario-Based Portals, the player can be taken to specific pages when they open Embedded Moments through them. Make sure to set up Scenario-Based Portals in TapTap Developer Center before you use this feature.

var sceneDic = new Dictionary<string, object>() { { TapMomentConstants.TapMomentPageShortCutKey, sceneId } };
// sceneId is the “portal ID” generated when you create a scenario-based portal in TapTap Developer Center
TapMoment.DirectlyOpen(Orientation.ORIENTATION_DEFAULT, TapMomentConstants.TapMomentPageShortCut, sceneDic);


orientationThe screen orientation for displaying the Embedded Moments.
pageShould be TapMomentConstants.TapMomentPageShortCut.
DictionaryLeave TapMomentConstants.TapMomentPageShortCutKey as it is and change the third argument to the ID of the target page.

Callbacks for Scenario-Based Portals


Field nameTypeRequiredDescription
sceneIdStringYesThe ID of the scenario-based portal.
eventTypeStringYesThe type of the event, like VIEW, FORWARD, and VOTE.
eventPayloadStringYesCustom JSON string depending on the event type.
timestampIntegerYesUNIX timestamp in ms.

Event types

eventTypeeventPayload (unserialized)Description
READY{}The DOM has been mounted and the data is pending.
REPOST{}The user reposts a post.
VOTE{ isCancel: boolean }The user likes (or removes their like on) a post.
FOLLOW{ isCancel: boolean }The user follows (or unfollows) a post.
COMMENT{}The user comments on a post.

Closing Embedded Moments

The player can close the Embedded Moments at any time to return to the game. In certain scenarios, the game itself can also request to close the Embedded Moments.

A case for the game to initiate a request to close the Embedded Moments is when the player is matched with another player to start a battle. Here you can confirm with the player whether they want to stay in the Embedded Moments or return to the game immediately.

TapMoment.Close("Are you ready?", "The game is ready to start.");

The player’s selection will be returned with a callback:

  • CALLBACK_CODE_CLOSE_CANCEL (50000) means the player selected “Cancel” and wants to stay in Embedded Moments.
  • CALLBACK_CODE_CLOSE_CONFIRM (50100) means the player selected “Confirm” and wants to return to the game.

To close the Embedded Moments without confirming:


Quick Sharing


This feature is optional. You can choose whether or not to enable this feature in your game.

In general, the play can post their moments on the Embedded Moments page. But if you’d like, you can also allow the player to post moments containing images and texts without leaving the game.

string content = "This is the content";
string[] images = {"imgpath01","imgpath02","imgpath03"};
TapMoment.Publish(Orientation.ORIENTATION_LANDSCAPE, images, content);

The player can post texts, images, and videos on the Embedded Moments page. However, they can only post texts and images with quick sharing.

Using Embedded Moments Without TDS Cloud Services

See the following instructions if you are using TapTap Login without TDS cloud services.

  1. Please first download the TapSDK and add the required dependencies. Embedded Moments depends on TapLogin, TapCommon, and TapMoment.

If you use TapSDK Unity v3.7.1 or a higher version, make sure that you add the module.

"": "",
  1. Make sure you have finished initializing TapTap Login.

  2. To initialize Embedded Moments:

TapMoment.Init(string clientID, boolean isCN);


clientIDThe Client ID of your game.
isCNtrue for Mainland China; false for other countries/regions.
  1. Now you’re good to use the other interfaces mentioned on this page.