Skip to main content
Version: 6.0.0

GetPolicy

public BackndPolicyReturnObject GetPolicy();

Note on GetPolicy method's migration to GetPolicy

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: Backnd.Policy.GetPolicy().GetReturnValuetoJSON()["terms"].ToString();
  • After change: Backnd.Policy.GetPolicy().GetReturnValuetoJSON()["policy"]["terms"].ToString();

BackndPolicyReturnObject

GetReturnValueByPolicyItem

If an error occurred, null is returned.

BackndPolicyReturnObject bro = Backnd.Policy.GetPolicy();

string KoreanPrivacyUrl = bro.GetReturnValueByPolicyItem().privacyURL;

GetReturnValueByExtraPolicyItem

If an error occurred, null is returned.

BackndPolicyReturnObject bro = Backnd.Policy.GetPolicy();

if(bro.GetReturnValueByExtraPolicyItem() == null) {
string EnglishTermsUrl = bro.GetReturnValueByExtraPolicyItem().termsURL;
}

BackndPolicyItem

public class BackndPolicyItem
{
public string terms = string.Empty;
public string termsURL = string.Empty;
public string privacy = string.Empty;
public string privacyURL = string.Empty;
}

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 GetPolicy's return value.

Example

Synchronous

BackndPolicyReturnObject bro = Backnd.Policy.GetPolicy();

string KoreanPrivacyUrl = bro.GetReturnValueByPolicyItem().privacyURL;

// When an additional policy is edited at least once, policy2 is displayed.
if(bro.GetReturnValueByExtraPolicyItem() != null) {
string EnglishTermsUrl = bro.GetReturnValueByExtraPolicyItem().termsURL;
}

Asynchronous

Backnd.Policy.GetPolicy((callback) => {
string KoreanPrivacyUrl = callback.GetReturnValueByPolicyItem().privacyURL;

// When an additional policy was edited at least once
if(callback.GetReturnValueByExtraPolicyItem() != null) {
string EnglishTermsUrl = callback.GetReturnValueByExtraPolicyItem().termsURL;
}
});

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 GetPolicyTest() {
var bro = Backnd.Policy.GetPolicy();

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

PolicyItem policy = new PolicyItem();

BACKND.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")) {

BACKND.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());
}
}