Skip to main content

Execution

Open the PlayNANOO helpdesk to allow users to submit and check inquiries.

URL Verification

This feature uses the help.playnanoo.com domain.

Feature Overview

The helpdesk operates in two modes:

  • Guest Mode: Allows inquiries from non-logged-in users
  • Player Mode: Registers inquiries with logged-in user information

Authentication Method

Player mode authenticates through the authKey parameter.

AuthKey Generation

using System;
using System.Text;

public static string CreateAuthKey(string gameId, string userId)
{
// AuthKey = Base64(GameId + UserId)
string authKeySource = gameId + userId;
return Convert.ToBase64String(Encoding.UTF8.GetBytes(authKeySource));
}

Unity C# Implementation

HelpDesk Class

using System;
using System.Collections.Generic;
using System.Text;
using UnityEngine;
using UnityEngine.Networking;

public class HelpDesk
{
private static string baseUrl = "https://help.playnanoo.com";
private static Dictionary<string, string> optionalParams = new Dictionary<string, string>();

public static void ClearOptional()
{
optionalParams.Clear();
}

public static void SetOptional(string key, string value)
{
if (optionalParams.ContainsKey(key))
optionalParams[key] = value;
else
optionalParams.Add(key, value);
}

private static string DictionaryToJson(Dictionary<string, string> dict)
{
if (dict.Count == 0) return "{}";

string json = "{";
bool first = true;
foreach (var kvp in dict)
{
if (!first) json += ",";
json += $"\"{kvp.Key}\":\"{kvp.Value}\"";
first = false;
}
json += "}";
return json;
}

private static string CreateAuthKey(string gameId, string userId)
{
string authKeySource = gameId + userId;
return Convert.ToBase64String(Encoding.UTF8.GetBytes(authKeySource));
}

public static void OpenView(string url, Action onClose = null)
{
Debug.Log($"Opening WebView: {url}");
Application.OpenURL(url);

onClose?.Invoke();
}

public static void OpenPlayerMode(Action onClose = null)
{
string uuid = DataManager.Instance.UUID;
string authKey = CreateAuthKey(HttpClient.GameId, uuid);

string url = $"{baseUrl}/{HttpClient.GameId}" +
$"?userId={UnityWebRequest.EscapeURL(uuid)}" +
$"&authKey={UnityWebRequest.EscapeURL(authKey)}";

// Encode optional parameters as Base64 JSON
if (optionalParams.Count > 0)
{
string optionalJson = DictionaryToJson(optionalParams);
string optionalBase64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(optionalJson));
url += $"&optional={UnityWebRequest.EscapeURL(optionalBase64)}";
}

OpenView(url, onClose);
}

public static void OpenGuestMode(Action onClose = null)
{
string url = $"{baseUrl}/{HttpClient.GameId}?mode=guest";

// Encode optional parameters as Base64 JSON
if (optionalParams.Count > 0)
{
string optionalJson = DictionaryToJson(optionalParams);
string optionalBase64 = Convert.ToBase64String(System.Text.Encoding.UTF8.GetBytes(optionalJson));
url += $"&optional={UnityWebRequest.EscapeURL(optionalBase64)}";
}

OpenView(url, onClose);
}
}

Main Methods

ClearOptional()

Removes all optional parameters.

HelpDesk.ClearOptional();

SetOptional(string key, string value)

Sets optional parameters. Used to pass custom information per game.

Parameters:

  • key: Parameter key
  • value: Parameter value
HelpDesk.SetOptional("GAME_SERVER", "ASIA");
HelpDesk.SetOptional("GAME_NICKNAME", "PlayerName");
Base64 JSON Encoding

The set optional parameters are internally converted to JSON and then Base64 encoded before being passed as the optional parameter in the URL.

OpenPlayerMode(Action onClose = null)

Opens the helpdesk in player mode. Logged-in user information is automatically included.

Parameters:

  • onClose: Callback to be invoked when the helpdesk closes (optional)

URL Parameters:

ParameterDescription
userIdUser unique ID (UUID)
authKeyBase64 encoded authentication key

OpenGuestMode(Action onClose = null)

Opens the helpdesk in guest mode. Non-logged-in users can also submit inquiries. No authentication required.

Parameters:

  • onClose: Callback to be invoked when the helpdesk closes (optional)

Usage Examples

Opening in Guest Mode

using PlayNANOO;
using UnityEngine;

public class PlayNANOOExample : MonoBehaviour
{
public void OpenHelpDeskGuestMode()
{
HelpDesk.ClearOptional();
HelpDesk.SetOptional("GAME_SERVER", "ASIA");
HelpDesk.SetOptional("GAME_NICKNAME", "NICKNAME");
HelpDesk.OpenGuestMode(() => {
Debug.Log("HelpDesk Closed");
});
}
}

Opening in Player Mode

using PlayNANOO;
using UnityEngine;

public class PlayNANOOExample : MonoBehaviour
{
public void OpenHelpDeskPlayerMode()
{
HelpDesk.ClearOptional();
HelpDesk.SetOptional("GAME_SERVER", "ASIA");
HelpDesk.SetOptional("GAME_NICKNAME", "NICKNAME");
HelpDesk.OpenPlayerMode(() => {
Debug.Log("HelpDesk Closed");
});
}
}

Connecting to UI Button

using PlayNANOO;
using UnityEngine;
using UnityEngine.UI;

public class HelpDeskUI : MonoBehaviour
{
public Button helpButton;

void Start()
{
helpButton.onClick.AddListener(OnHelpButtonClick);
}

void OnHelpButtonClick()
{
// Check login status
if (DataManager.Instance.IsLoggedIn)
{
OpenHelpDeskWithPlayerInfo();
}
else
{
OpenHelpDeskAsGuest();
}
}

void OpenHelpDeskWithPlayerInfo()
{
HelpDesk.ClearOptional();

// Add game server info
HelpDesk.SetOptional("GAME_SERVER", GetCurrentServer());

// Add player level info
HelpDesk.SetOptional("PLAYER_LEVEL", GetPlayerLevel().ToString());

// Add last play time
HelpDesk.SetOptional("LAST_PLAY_TIME", System.DateTime.Now.ToString());

HelpDesk.OpenPlayerMode(() => {
Debug.Log("Player mode helpdesk closed");
});
}

void OpenHelpDeskAsGuest()
{
HelpDesk.ClearOptional();
HelpDesk.SetOptional("GAME_SERVER", GetCurrentServer());

HelpDesk.OpenGuestMode(() => {
Debug.Log("Guest mode helpdesk closed");
});
}

string GetCurrentServer()
{
// Return current server info
return "ASIA";
}

int GetPlayerLevel()
{
// Return player level
return 50;
}
}

Optional Parameters

You can pass various game information to the helpdesk using the SetOptional method:

Parameter ExampleDescription
GAME_SERVERGame server (e.g., ASIA, NA, EU)
GAME_NICKNAMEIn-game nickname
PLAYER_LEVELPlayer level
CHARACTER_CLASSCharacter class/job
GUILD_NAMEGuild/clan name
LAST_STAGELast played stage
GAME_VERSIONGame version
ERROR_CODEError code (when errors occur)
Utilizing Optional Parameters

By passing game state information along with user inquiries through optional parameters, the customer support team can identify and resolve issues more quickly.

Multi-language Support

The helpdesk automatically detects the browser language settings and displays in the corresponding language.

WebView Recommended

While the helpdesk uses Application.OpenURL by default, using a WebView plugin is recommended for a better user experience.