Skip to main content
Version: 5.11.4

GetPolicyV2

public BackendReturnObject GetPolicyV2();

Note on GetPolicy method's migration to GetPolicyV2

Following the 2023.03.28 update, developers may now create up to 2 game operation policies.

Some return values have been changed to distinguish the values, and when migrating to GetPolicies, change the according to the following:

  • Before change: Backend.Policy.GetPolicy().GetReturnValuetoJSON()["terms"].ToString();
  • After change: Backend.Policy.GetPolicyV2().GetReturnValuetoJSON()["policy"]["terms"].ToString();

Description

This is a function to load the Terms of Service and Privacy Policies registered in BACKND Console.

  • When the Terms of Service or Privacy Policy are not edited after creating the project, the corresponding values are returned as null.
  • When additional Terms of Service and/or Privacy Policy are unedited, they are not shown in GetPolicyV2's return value.

Example

Synchronous

BackendReturnObject bro = Backend.Policy.GetPolicyV2();

string KoreanPrivacyUrl = bro.GetReturnValuetoJSON()["policy"]["privacyURL"].ToString();

// When an additional policy is edited at least once, policy2 is displayed.
if(bro.GetReturnValuetoJSON().ContainsKey("policy2") {
string EnglishTermsUrl = bro.GetReturnValuetoJSON()["policy2"]["termsURL"].ToString();
}

Asynchronous

Backend.Policy.GetPolicyV2((callback) => {
string KoreanPrivacyUrl = bro.GetReturnValuetoJSON()["policy"]["privacyURL"].ToString();

// When an additional policy was edited at least once
if(bro.GetReturnValuetoJSON().ContainsKey("policy2") {
string EnglishTermsUrl = bro.GetReturnValuetoJSON()["policy2"]["termsURL"].ToString();
}
});

SendQueue

SendQueue.Enqueue(Backend.Policy.GetPolicyV2, (callback) => {
string KoreanPrivacyUrl = bro.GetReturnValuetoJSON()["policy"]["privacyURL"].ToString();

// When an additional policy was edited at least once
if(bro.GetReturnValuetoJSON().ContainsKey("policy2") {
string EnglishTermsUrl = bro.GetReturnValuetoJSON()["policy2"]["termsURL"].ToString();
}
});

Return cases

Success cases

When loaded successfully
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

When the default policy is not registered
statusCode : 200

returnValue : {"policy":{"terms":null,"termsURL":null,"privacy":null,"privacyURL":null}}

GetReturnValuetoJSON

When only the default policy is edited

{
"policy": {
"terms": "Terms of Service",
"termsURL": "storage.alpha.thebackend.io/89abe12345657889901231232876f51145c54724af44d58396694a6fd/terms.html",
"privacy": "Privacy Policy",
"privacyURL": "storage.alpha.thebackend.io/89abe12345657889901231232876f51145c54724af44d58396694a6fd/privacy.html"
}
}

If both default policies and additional policies are edited

{
"policy": {
"terms": "Terms of Service",
"termsURL": "storage.alpha.thebackend.io/89abe12345657889901231232876f51145c54724af44d58396694a6fd/terms.html",
"privacy": "Privacy Policy",
"privacyURL": "storage.alpha.thebackend.io/89abe12345657889901231232876f51145c54724af44d58396694a6fd/privacy.html"
},
"policy2": {
"terms": "Terms of Service",
"termsURL": "storage.thebackend.io/89abe12345657889901231232876f51145c54724af44d58396694a6fd/terms2.html",
"privacy": "Privacy Policy",
"privacyURL": "storage.thebackend.io/89abe12345657889901231232876f51145c54724af44d58396694a6fd/privacy2.html"
}
}

Sample code

public class Policy
{
public string terms;
public string termsURL;
public string privacy;
public string privacyURL;
public override string ToString()
{
string str = $"terms : {terms}\n" +
$"termsURL : {termsURL}\n" +
$"privacy : {privacy}\n" +
$"privacyURL : {privacyURL}\n";
return str;
}
}
public void GetPolicyV2Test() {
var bro = Backend.Policy.GetPolicyV2();

if(!bro.IsSuccess()) {
return;
}

PolicyItem policy = new PolicyItem();

LitJson.JsonData policyJson = bro.GetReturnValuetoJSON()["policy"]; // Accesses with 'policy'

policy.terms = policyJson["terms"]?.ToString(); // 'null' when there is no input
policy.termsURL = policyJson["termsURL"]?.ToString(); // 'null' when there is no input
policy.privacy = policyJson["privacy"]?.ToString(); // 'null' when there is no input
policy.privacyURL = policyJson["privacyURL"]?.ToString(); // 'null' when there is no input
Debug.Log(policy.ToString());


if(bro.GetReturnValuetoJSON().ContainsKey("policy2")) {

LitJson.JsonData policy2Json = bro.GetReturnValuetoJSON()["policy2"]; // Accesses with 'policy2'

PolicyItem policy2 = new PolicyItem();

policy2.terms = policy2Json["terms"]?.ToString(); // 'null' when there is no input
policy2.termsURL = policy2Json["termsURL"]?.ToString(); // 'null' when there is no input
policy2.privacy = policy2Json["privacy"]?.ToString(); // 'null' when there is no input
policy2.privacyURL = policy2Json["privacyURL"]?.ToString(); // 'null' when there is no input

Debug.Log(policy2.ToString());
}
}