C. Point Management

Points can be managed by Tnk Server or by your server depending on the 'Point management' setting. When you selected 'Managed by Tnk', all points are managed by Tnk server and you can inquiry and withdraw points of users using APIs described in this chapter. If you selected 'Callback URL', all the point reward events are sent to your server through the callback URL you entered. For callback URL, see 1.6 Callback URL.

1) TnkAd.Plugin - queryPoint()

Inquiry amount of points of a user from Tnk server. Because this method is invoked in async way, you have to define EventHandler to get return values.

Method 
  - void queryPoint(string handlerName)

Description
   This method returns amount of points of a user managed by Tnk server. This method works asynchronously and delivers return values by invoking onReturnQueryPoint() method in the EventHandler.

Parameters
 NameDescription
 handlerName Name of EventHandler object. The result value is return to onReturnQueryPoint(int point) method of the EventHandler.

2) TnkAd.Plugin - purchaseItem()

Use this method to decrease user points managed by Tnk server. Because this method is invoked in async way, you have to define EventHandler to get return values.

Method 
  - void purchaseItem(int pointCost, string itemId, string handlerName)

Description
   Decrease user points in Tnk server. This method works asynchronously and delivers return values by invoking onReturnPurchaseItem() method in the EventHandler.

Parameters
 Name Description
 pointCostamount of points to decrease
 itemIdItem name or Id to purchase. 
This value is used only for logging purpose.
 handlerNameName of EventHandler object. The result value is return to onReturnPurchaseItem(long curPoint, long seqId) method of the EventHandler.
curPoint is amount of points left in server. seqId is a unique transaction Id to distinguish this invocation. If the amount of points of a user is less than pointCost value, points will not be decreased and seqId of negative value is returned. 

Sample Code

using UnityEngine;
using System.Collections;

public class TnkUITest : MonoBehaviour {

    void Start ()
    {
    }
    
    void Update ()
    {
    }
    
    void OnGUI ()
    {
        if (GUI.Button (new Rect (10040015080), "Query point")) {
            Debug.Log("Query point");
            // be sure that put handler object named 'testhandlerin your scene. (It should be named in Unity Inspector)
            TnkAd.Plugin.Instance.queryPoint("testhandler"); 
        }

        if (GUI.Button (new Rect (10050015080), "Purchase Item")) {
            Debug.Log("Purchase Item");
            // be sure that put handler object named 'testhandlerin your scene. (It should be named in Unity Inspector)
            TnkAd.Plugin.Instance.purchaseItem(100"item01""testhandler"); 
        }
    }

}

Comments