Skip to main content
Version: 5.11.8

Installing 1:1 Inquiry Plugin

1:1 inquiry plugin

Android : BackendQuestion-Android-1.0.0.unitypackage [2024-03-26]
iOS : BackendQuestion-iOS-1.0.0.unitypackage [2024-03-26]

Currently, the 1:1 inquiry function only supports Android and iOS, and does not work in the Unity editor.
For Android, only the versions 7.0(API-24) or higher are supported. For iOS, only the versions 8.0+ or higher are supported. Previous versions are not supported for either.

The 1:1 inquiry function is available when the above plugin is additionally installed in SDK 5.0.3 or later.
If you move the StreamingAssets/TheBackend/QuestionHtml/ folder containing the html and css files for BackendQuestion, it will not function correctly.
Please fix the folder to the path.

Additional matters for each platform

Upon importing, the following files are created in Unity:

Common

  • BackendQuestionMain.html
  • BackendQuestionList.html
  • BackendQuestionStyle.css (Assets/StreamingAssets/TheBackend/QuestionHtml/ - All three files use the same path.)

Android

Note on ProGuard

If you are using ProGuard, the following exception handling is needed.

-keep class io.thebackend.questionwebview.** {*;}
  • io.thebackend.questionwebview.aar(Assets/TheBackend/ToolKit/Question/Android/)
  • TheBackend.ToolKit.Question.Android.dll(Assets/TheBackend/ToolKit/Question/Android/)
  • androidx.core.core-1.0.0.aar(Assets/Plugins/Android/) When building for Android, if there is a different version of androidx.core.core.aar in Assets/Plugin/Android, please maintain the latest version and delete the old version.
    A storage space permission setting is added to the app upon building, and when an attachment is added to the inquiry window, the storage space permission is activated.
    android.permission.WRITE_EXTERNAL_STORAGE and android.permission.READ_EXTERNAL_STORAGE are automatically added to the final AndroidManifest.xml.

iOS

  • BackendQuestionProcessBuildForIOS.cs(Assets/TheBackend/ToolKit/Question/iOS/Editor/)
  • TheBackend.ToolKit.Question.iOS.dll(Assets/TheBackend/ToolKit/Question/iOS/)
  • BackendQuestionViewForIOS.mm(Assets/TheBackend/ToolKit/Question/iOS/) After building, WebKit.framework is added as 'required' to UnityFramework in the generated Xcode Project.
    NSCameraUsageDescription and NSMicrophoneUsageDescription that define the permission messages for using image, camera, and video recording functions are added to info.plist.
    This message is used when selecting the Add Attachment - Take Photo or Video function in the 1:1 inquiry window.
    The message can be changed through cameraMessage and videoMessage in the(Assets/Editor/TheBackend/BackendQuestionProcessBuildForIOS.cs) script.

Error cases

After importing, the following errors may occur when building or running:

duplicateClasses error when building Unity for Android
This error occurs when there are two or more androidx.core.core.aar plugins.
If the GPGS plugin or Admob plugin is imported, the aar file may be duplicated, so please find and remove the old version of androidx.core.core.aar.

There must only be one androidx.core.core.aar file in the project.

An error that causes the game to close when clicking Add Attachment in the Android 1:1 inquiry window
This occurs because androidx.core.core.aar has not been imported into the build.
Please check if androidx.core.core.aar exists in the Plugins folder.


Example code

Loading 1:1 inquiry window authentication information

Description

Issue an authentication code needed for 1:1 inquiries executed in Android and iOS native codes.
This function is included in the BACKND Base and can be called after logging in.

Example

// Synchronous Method
var bro = Backend.Question.GetQuestionAuthorize();
string questionAuthorize = bro.GetReturnValuetoJSON()["authorize"].ToString();

// Asynchronous Method
Backend.Question.GetQuestionAuthorize(callback =>
{
string questionAuthorize = callback.GetReturnValuetoJSON()["authorize"].ToString();
});

Open 1:1 inquiry window

Description

Create 1:1 inquiry view on top of Unity view.

Parameters

ValueTypeDescription
questionAuthorizestringAuthentication code issued via Backend.Question.GetQuestionAuthorize method
myInDatestringSelf User inDate ( Backend.UserInDate fixed)
questionOnErrorCallbackQuestionOnErrorCallbackHandler that operates when an error occurs during creation of inquiry window

public delegate void QuestionOnErrorCallback(string error);

Example

var bro = Backend.Question.GetQuestionAuthorize();
string questionAuthorize = bro.GetReturnValuetoJSON()["authorize"].ToString();

#if UNITY_ANDROID
TheBackend.ToolKit.Question.Android.OpenQuestionView(questionAuthorize, Backend.UserInDate, (error) =>
{
Debug.LogError("An error occurred during creating the 1:1 inquiry window : " + error);
});

#elif UNITY_IOS
TheBackend.ToolKit.Question.iOS.OpenQuestionView(questionAuthorize, Backend.UserInDate, (error) =>
{
Debug.LogError("An error occurred during creating the 1:1 inquiry window : " + error);
});
#endif

Configuring layout of 1:1 inquiry window

Description

Configure layout of 1:1 inquiry window.
Can configure all directions of margins, buttons and ratios of inquiry window. If you want to reduce the size of X button, buttonWeight = 1, and viewWeight must be higher than 11.

QuestionViewLayout Class

ValueTypeDescriptionDefault
leftMarginintAuthentication code issued via Backend.Question.GetQuestionAuthorize method0
topMarginintAuthentication code issued via Backend.Question.GetQuestionAuthorize method0
rightMarginintAuthentication code issued via Backend.Question.GetQuestionAuthorize method0
bottomMarginintAuthentication code issued via Backend.Question.GetQuestionAuthorize method0
buttonWeightintOut of full-vertical ratio (buttonWeight + viewWeight), view ratio of button view included1(1 : 12)
viewWeightintOut of full-vertical ratio (buttonWeight + viewWeight), view ratio of inquiry window view included11(11 : 12)

If buttonWeight = 2, viewWeight = 18, and vertical size of screen is 1800,
vertical of button layout is 1800 x 2 / (2+18), and vertical of inquiry layout is 1800 x 18 / (2+18).

Example


#if UNITY_ANDROID
TheBackend.ToolKit.Question.Android.QuestionViewLayout
questionViewLayout = new Android.QuestionViewLayout();
#elif UNITY_IOS
TheBackend.ToolKit.Question.iOS.QuestionViewLayout
questionViewLayout = new iOS.QuestionViewLayout();
#endif

TheBackend.ToolKit.Question.Android.QuestionViewLayout
questionViewLayout = new Android.QuestionViewLayout();
questionViewLayout.leftMargin = 5; // Left margin
questionViewLayout.topMargin = 5; // Top margin
questionViewLayout.rightMargin = 5; // Right margin
questionViewLayout.bottomMargin = 5; // Bottom margin

// black layout with button included, and ratio of inquiry layout
// button layout takes up 1/10 of vertical, and inquiry layout takes up 9/10
// If vertical size of the screen is 1,000, button layout’s vertical is 100, and inquiry layout is 900
questionViewLayout.buttonWeight = 1;
questionViewLayout.viewWeight = 9;

#if UNITY_ANDROID
TheBackend.ToolKit.Question.Android.SetQuestionViewLayout(questionViewLayout);
#elif UNITY_IOS
TheBackend.ToolKit.Question.iOS.SetQuestionViewLayout(questionViewLayout);
#endif

Close 1:1 inquiry window

Description

Close the 1:1 inquiry window.

Example

#if UNITY_ANDROID
TheBackend.ToolKit.Question.Android.CloseQuestionView();
#elif UNITY_IOS
TheBackend.ToolKit.Question.iOS.CloseQuestionView();
#endif

Close 1:1 inquiry window handler

Description

Add an action of closing handler that is called upon closing 1:1 inquiry window.

Example

#if UNITY_ANDROID
TheBackend.ToolKit.Question.Android.SetCloseQuestionViewCallback(() =>
{
Debug.Log("The window has been closed.");
});

#elif UNITY_IOS
TheBackend.ToolKit.Question.iOS.SetCloseQuestionViewCallback(() =>
{
Debug.Log("The window has been closed.");
});
#endif

SampleCode

using UnityEngine;
using BackEnd;
using TheBackend.ToolKit.Question;

public class NewBehaviourScript : MonoBehaviour
{
private string authCode = "";

void Start()
{
if (!Backend.Initialize(true).IsSuccess())
{
Debug.LogError("Failed to reset.");
}

var bro = Backend.BMember.CustomLogin("test1", "test2");

if (bro.IsSuccess())
{
var bro2 = Backend.Question.GetQuestionAuthorize();
authCode = bro2.GetReturnValuetoJSON()["authorize"].ToString();
}
}

void OpenQuestionView()
{
#if UNITY_ANDROID
TheBackend.ToolKit.Question.Android.QuestionViewLayout
questionViewLayout = new Android.QuestionViewLayout();
#elif UNITY_IOS
TheBackend.ToolKit.Question.iOS.QuestionViewLayout
questionViewLayout = new iOS.QuestionViewLayout();
#endif

questionViewLayout.buttonWeight = 1;
questionViewLayout.viewWeight = 9;

#if UNITY_ANDROID
TheBackend.ToolKit.Question.Android.SetQuestionViewLayout(questionViewLayout);
TheBackend.ToolKit.Question.Android.SetCloseQuestionViewCallback(() =>
{
Debug.Log("The window has been closed. Game will resume.");
});
TheBackend.ToolKit.Question.Android.OpenQuestionView(authCode, Backend.UserInDate, (error) =>
{
Debug.LogError("An error occurred during creating the 1:1 inquiry window : " + error);
});

#elif UNITY_IOS
TheBackend.ToolKit.Question.iOS.SetQuestionViewLayout(questionViewLayout);
TheBackend.ToolKit.Question.iOS.SetCloseQuestionViewCallback(() =>
{
Debug.Log("The window has been closed. Game will resume.");
});
TheBackend.ToolKit.Question.iOS.OpenQuestionView(authCode, Backend.UserInDate, (error) =>
{
Debug.LogError("An error occurred during creating the 1:1 inquiry window : " + error);
});
#endif
}
}