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) TnkSession.queryPoint()Inquiry amount of points of a user from Tnk server. Both sync and async invocation are supported. Invoking this method in main UI thread, you have to use async method not to your UI freeze until data arrives from server. But if you are going to invoke this method not in main UI thread but in other threads such as threads in game engine, you have to create a new thread and invoke sync method.
[Async Invocation] Method
- void TnkSession.queryPoint(Context context, boolean showProgress, ServiceCallback callback)
Description
This method returns amount of points of a user managed by Tnk server. This method works asynchronously and delivers return values to ServiceCallback object you passed in. You should invoke this method in main UI thread. Return value is delivered to the second parameter of onReturn(Context context, Object result) method of callback object. Callback is executed in main UI thread.
Parameters
[Sync Invocation] Method
- int TnkSession.queryPoint(Context context)
Description
This method returns amount of points of a user managed by Tnk server. This method blocks until a return value arrives.
Parameters
Return : int Amount of user points in Tnk server. 2) TnkSession.purchaseItem()Use this method to decrease user points managed by Tnk server. Both sync and async invocation are supported.
[Async Invocation]
Method
- void TnkSession.purchaseItem(Context context, int pointCost, String itemId, boolean showProgress, ServiceCallback callback)
Description
Decrease user points in Tnk server. Return value is delivered to the second parameter of onReturn(Context context, Object result) method of callback object. Callback is executed in main UI thread.
Parameters
[Sync Invocation]
Method
- long[] TnkSession.purchaseItem(Context context, int pointCost, String itemId)
Description
Decrease user points in Tnk server. This method blocks until a return value arrives.
Parameters
Return : long[]
- long[0] : amount of points left in Tnk server.
- long[1] : unique transaction Id. Negative value indicate there was an error like 'point not enough'
|