Retrieve messages

This page gives information about how to get an in-app message from TentuPlay database. You will learn the following:

  • The prerequisites that are required

  • Module, classes, and methods that are applicable

  • How to get an in-app message data

Prerequisites

This page assumes that you are finished with the following:

Module, class, and methods in use

When ShowOfferById or ShowLatestOffer is called, TPPersonalizedOffer module will dynamically retrieve offers by player (namely, userId) and returns you the data table for your use.

  • ShowOfferById and ShowLatestOffer are methods of the TPPersonalizedOffer module.

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

Request a message

  1. Call ShowOfferById or ShowLatestOffer by using TPPersonalizedOffer module’s function as shown in the code example.

    Code example
    local ReplicatedStorage = game:GetService("ReplicatedStorage")
    local TentuplaySDKModules = ReplicatedStorage["tentuplay-sdk-modules-ReplicatedStorage"]
    
    local TPPersonalizedOffer = require(TentuplaySDKModules.TPPersonalizedOffer)
    
    function showPersonalizedOffer()
    	while true do
    		wait(5)
    		local response = TPPersonalizedOffer.GetOffersAsync(player.UserId)
    		for _, offer in pairs(response) do
    			local offerByIdCallback = TPPersonalizedOffer.ShowOfferById(player.UserId,"EN", offer.offer_id)
    		end
    	end
    end
    
    local personalizedOfferCoroutine = coroutine.create(showPersonalizedOffer)
    coroutine.resume(personalizedOfferCoroutine)
  2. Now, the message appears on the screen

    300