Set up SDK

This page gives information about how to set up TentuPlay SDK to make an in-app message work. You will learn the following:

  • The prerequisites that are required

  • Controllers, classes, and methods that are applicable

  • How to configure SDK in Unity editor

  • UI components and their scripts for offers

Prerequisites

This page assumes that you are finished with the following:

Controller, class, and methods in use

When ShowOfferById or ShowLatestOffer is called, TPPersonalizedOfferController will dynamically retrieve offers by player (namely, player_uuid) and show them on Scene.

  • ShowOfferById and ShowLatestOffer are methods of the TPPersonalizedOffer class

  • TPPersonalizedOffer is a class for displaying TentuPlay in-app messages and AI In-Game Shop offers

These components (namely, controller, class, and methods) are used commonly by both in-app messages and AI in-game shop offers.

Set up in Unity editor

To make a message appear correctly, you need to work on both Unity editor and your script.

  1. Locate TPPersonalizedOfferController.prefab in Assets/TentuPlay/TPPersonalizedOfferTemplates in Unity editor. It contains its script (TPPersonalizedOfferController.cs) as a component.

    image (8)
    image (9)
  2. Add TPPersonalizedOfferController game object to Scene.

    image (10)
  3. Call ShowOfferById or ShowLatestOffer by using tpPersonalizedOfferController GameObject parameter value as shown in the code example.

    Code example
    public void ShowPersonalizedOffer()
        {
            TPPersonalizedOffer myTPOffer = new TPPersonalizedOffer();
            StartCoroutine(
                myTPOffer.ShowOfferById(tpPersonalizedOfferController, player_uuid, "en", offer_id, (response => { })));
        }

    For more examples, check out Assets/ShingGoongDemo/Scripts/TentuplayRelated/TentuPlayCRMPlayerController.cs and Assets/ShingGoongDemo/Scripts/TentuplayRelated/MailBoxOpen_offer.cs.

  4. Now, an example message appears on on the game screen when it is meant to be shown.

    image (11)
    In-app message on mail box
    image (12)
    In-app message message when opened

The OfferInfo.offerType is the attribute that differentiates between in-app messages and AI in-game shop offers

Message UI

Let’s take a brief look at what the UI components of in-app message are and how they are organized in Unity.

UI templates

When ShowOfferById or ShowLatestOffer is called, either TentuPlayManualOffer_landscape or TentuPlayManualOffer_portrait is generated on Scene depending on screen orientation as a child of TPPersonalizedOfferController (TPPersonalizedOfferController.ShowOffer).

The image entered via the console becomes a Texture/Raw Image of OfferImage.

image (13)
TentuPlayManualOffer_landscape generated as a child of TPPersonalizedOfferController

UI template components

For instance, let’s learn more about TentuPlayManualOffer_landscape.prefab that is one of two assets that contain message UI elements.

06 TentuPlayManualOffer landscape gui

There are two scripts inside TentuPlayManualOffer_landscape.prefab.

  • MessageController: A script to open and close messages

  • TentuPlayManualOffer: A TentuPlay script for in-app messages

07 TentuPlayManualOffer landscape scripts

Message image (OfferImage)

GUI Scripts

08 OfferImage gui

If you have configured a size in the console (for example, 580 x 896px) and then set a new size in OfferImage, the first size will be overriden.

Default size values are as follows:

  • TentuPlayManualOffer_landscape: 640 x 400

  • TentuPlayManualOffer_portrait: 400 x 640

TentuPlayOffer.GoToOfferEvent in On Click()

09 OfferImage Scripts

Close button (CloseButton)

GUI Scripts

10 CloseButton gui

TentuPlayManualOffer.CloseOfferEvent in On Click()

11 CloseButton scripts

Do Not Show Again Today Checkbox

GUI Scripts

12 Toggle gui

TentuPlayOffer.CheckDoNotShowToday in On Value Changed

If you want to use a Do Not Show Again button, edit to use MarkDoNotShowAgain method.

12 Toggle scripts

Verify messages

For security reasons, TentuPlay provides a verification API that enables you to authenticate the offer’s identity and check its integrity without any forgery and corruption.

To learn how to use the verfication API, see Offer verification API.