Go To Console

TPPersonalizedOffer

TPPersonalizedOffer

Class in TentuPlay.CRM / Implemented in:TentuPlay.CRM

Description

Class to show in-game offer messages.

GetOfferAsync Request the player’s Offer information asynchronously and save at the client-side DB.
SelectOfferInfo Request valid information of Offer in client-side DB sort from the most recent to oldest.
ShowOffer ShowOffer is a method for displaying a Offer to player.
AddOfferClosedCount Check if the Offer has been opened by adding 1 to closed_count.
OfferOpened Call when the player opens the Offer.

GetOfferAsync

public void GetOfferAsync(string player_uuid, Action<int> callback);

Description

Request the player’s Offer information asynchronously and save at the client-side DB. You can use it when loading game.

You need to wait at least TentuPlaySettings.offersGetInterval before the next GetOfferAsync call. If not, you will see the following message in the Unity Editor Console in TentuPlay debug mode: TPDebug||GetOffersAsync started but too soon to send : GetOffersAsyncTs

If GetOffersAsync has failed, you will see the following message in the Unity Editor Console in TentuPlay debug mode: TPError||Error while getting offer: ERROR_MESSAGE

Parameter

player_uuid

Player’s unique lD (Not a character's ID).

e.g. Steam User ID, Google Play User ID ..

callback

1 if succeeded, -1 if failed.

SelectOfferInfo

public List<OfferInfo> SelectOfferInfo(string player_uuid, string language, [int maximum_closed_count = 10000]);

Description

Request valid information of Offer in client-side DB sort from the most recent to oldest.

Returns

OfferInfo: Information of Offer

public class OfferInfo
{
    public int offer_id;
    public int closed_count;
    public string expires_in;
    public string title;
}

If the call fails, null will be returned and you will see the following message in the Unity Editor Console in TentuPlay debug mode: TPError||ERROR select from Offer: EXCEPTION_ERROR_MESSAGE

※ Note

The language codes you set on the console and those on the script should be equal to use personalized offers. - For example, if you add language codes "ko" "en" to your offers through the console, - you need to set your script to `ShowOffer(language="ko")` `ShowOffer(language="en")` so that personalized offers will be shown. Likewise, when you call language codes that you haven't set at the console, there will be an error. - For example, if you create an offer called offer1 with language two codes - "en," "ko" - and another offer called offer2 with one language code ("ko"), then call personalized offer through script with `SelectOfferInfo(language="en")` or `ShowOffer(language="en")`, an error will occur since there is no language code "en" for offer2.

Parameter

player_uuid

Player’s unique lD (Not a character's ID).

e.g. Steam User ID, Google Play User ID ..

language

Language code you set up in personalized offer console.

maximum_closed_count

The maximum limit of closed_count for Advice.

ShowOffer

public IEnumerator ShowOffer(GameObject tpPersonalizedOfferControllerGameObject, string player_uuid, string language, Action<int> callback, [maximum_closed_count = 10000], [int? offer_id = null]);

Description

ShowOffer is a method for displaying the Offer to player. If optional parameter offer_id is null, it shows the latest offer.

ShowOffer calls TentuPlayOffer.PlaceOffer, which shows TentuPlayOffer_landscape.prefab or TentuPlayOffer_portrait.prefab in Assets/TentuPlay/TPPersonalizedOfferTemplates/Resources dynamically. If there is nothing to offer for the player, no window will be shown. For more details, refer to TentuPlayOffer and you can modify the script.

※ Note

The language codes you set on the console and those on the script should be equal to use personalized offers. - For example, if you add language codes "ko" "en" to your offers through the console, - you need to set your script to `ShowOffer(language="ko")` `ShowOffer(language="en")` so that personalized offers will be shown. Likewise, when you call language codes that you haven't set at the console, there will be an error. - For example, if you create an offer called offer1 with language two codes - "en," "ko" - and another offer called offer2 with one language code ("ko"), then call personalized offer through script with `SelectOfferInfo(language="en")` or `ShowOffer(language="en")`, an error will occur since there is no language code "en" for offer2.

Parameter

tpPersonalizedOfferControllerGameObject

Game object of TPOfferController

player_uuid

Player’s unique lD (Not a character's ID).

e.g. Steam User ID, Google Play User ID ..

language

Language code you set up in personalized offer console.

callback

1 if succeeded, -1 if failed.

maximum_closed_count

The maximum limit of closed_count for Advice.

offer_id

Unique ID assigned to the offer.

AddOfferClosedCount

public int AddOfferClosedCount(int offer_id);

Description

Check if the Offer has been opened by adding 1 to closed_count. Since the method is called when Offer is closed, it is already called in TentuPlayOffer.cs.

It returns 1 for success and -1 for failure. When -1 is returned, you will see the following message in the Unity Editor Console in TentuPlay debug mode: TPError||ERROR updating closed_count in offer: EXCEPTION_ERROR_MESSAGE

Parameter

offer_id

Unique ID assigned to the offer.

OfferOpened

public void OfferOpened(int offer_id, Action<int> callback);

Description

Call when the player opens the Offer. It is necessary for the expiration date of the personalized offer promotion, and it is already called in TentuPlayOffer.cs.

Parameter

offer_id

Unique ID assigned to the offer.

callback

1 if succeeded, -1 if failed.