Pre-arrangements
The following tasks must be completed in advance to implement coupon functions.
- A chart for using the mail
- Logic of completed login method
- Logic of completed game information management method
- Create a script exclusive to coupons
1. A chart for using the mail
The information from a chart that allows you to use mail functions is required to implement the items provided after claiming the mail.
Go to BACKND Console, and in BACKND Base > DataTable Management
, change the Mail Use status to Enabled for the chart that holds the item to be provided as a coupon reward.
If there are no registered charts, first proceed with 4. Implementing DataTable Functions Step 2. Registering DataTables to the Console.
Click the Edit button on the right of the chart.
Set the Mail Use status to Enabled.
After the change, the mail function is displayed as Enabled.
2. Logic of completed login method
All BACKND functions except login and sign-up require a login process to successfully call their methods.
If the login logic has not been implemented, please fully implement it according to the guidelines in 1. Implementing Login/Sign-up.
3. Logic of completed game information management method
This example shows the process leading up to the logic that saves items returned after using coupons. Therefore, 2. Implementing Game Information Functions, which is used to save data, must first be implemented.
If the game information function logic has not been implemented, please fully implement it according to 2. Implementing Game Information Functions.
4. Create a script exclusive to coupons
Create a new script and change the name to BackndCoupon.
Then, open the BackndCoupon.cs script and change the content according to the following:
BackndCoupon.cs
using System.Collections.Generic;
using System.Text;
using UnityEngine;
// Adds BACKND SDK namespace
using BACKND;
public class BackndCoupon {
private static BackndCoupon _instance = null;
public static BackndCoupon Instance {
get {
if(_instance == null) {
_instance = new BackndCoupon();
}
return _instance;
}
}
public void CouponUse(string couponNumber) {
// Step 3. Using Coupons and Saving Items
}
}
BackndManager.cs
using UnityEngine;
using System.Threading.Tasks;
// Adds BACKND SDK namespace
using BACKND;
public class BackndManager : MonoBehaviour {
void Start() {
var bro = Backnd.Initialize(); // Initialize BACKND
// Response value for BACKND initialization
if(bro.IsSuccess()) {
Debug.Log("Initialization successful : " + bro); // If successful, 'statusCode 204 Success'
} else {
Debug.LogError("Initialization failed : " + bro); // If failed, a 4xx statusCode error occurs
}
Test();
}
// A method that allows synchronous methods to be called from asynchronous methods(cannot be accessed by the Unity UI)
async void Test() {
await Task.Run(() => {
BackndLogin.Instance.CustomSignIn("user1", "1234");
// Adds logic for using coupons
Debug.Log("Test complete.");
});
}
}