# 6. FAQs

# 6.1 Old Version Porting

QIYU SDK architecture has been Restructured from Unity SDK v1.3.0, which decouples the XR SDK and Platform SDK. If you porting from Unity XR sdk v1.2.1 or previous versions and update to Platform v1.0.0, please following the steps below:

# A. Import the new versions of QIYU XR Plugin and QIYU Platform SDK.

Fig 6.1.1 Update QIYU XR Plugin and QIYU Platform SDK

# B. Update QIYU SDK Samples and QIYU Platform Samples

If project has already imported the SDK Sample, there will be a class error message(please refer to Fig 6.1.2), you might need to press the Samples-Update, and re-import the QIYU SDK Samples andQIYU Platform Samples, the error will be fixed automactically.

Fig6.1.2 Class error message
Fig6.1.3 Update QIYU XR Samples
Fig6.1.4 Update QIYU Platform Samples

# C. Modify codes in project

The compiling will be failed if you using the following names of class or APIs. Please update those names to the new ones. Please refer to the following below:

# 1. Class name of Platform APIs

Change the QiyuSDKCorePlugins to QiyuXRPlatformPlugin.

# 2. The APIs of Platform Initialization

The new version of initialization will input the callback function and delete the older way of monitor. Besides, the QiyuPlugin will be changed to QiyuXRPlatform,the QiyuPlugin.MessageResult will be changed to QiyuMessage.GetRequestResult,the QiyuPlugin.SDKInit will be changed to QiyuMessage.SDKInit

  • Unity XR SDK v1.2.1 and previous version:
    //First, you need to monitor the SDK initialization result
QiyuMessageListener.AddListener(MessageCode.QiyuSdkInit, ret =>
{
 QiyuPlugin.MessageResult<QiyuPlugin.SDKInit> msg = ret[0] as QiyuPlugin.MessageResult<QiyuPlugin.SDKInit>;
	if (msg.IsSuccess())
 	{

	}
});
	//Initialize SDK
	QiyuPlugin.InitQiyuSDK(
	 "", //AppId can be gained from the Application information page in QIYU developer Protal
	 ""); //App secret can be gained from the Application information page in QIYU developer Protal
  • Platform v1.0.0 and above version:
  QiyuXRPlatform.InitQiyuSDK(QiyuMessage.GetRequestResult<QiyuMessage.SDKInit>((msg) =>
	{
		if (msg.IsSuccess())
		{
		 Debug.Log($" InitQiyuSDK OK!");
		}
		else
		{
		Debug.Log($" InitQiyuSDK Failed! code:{msg.code}");
		}
	}),
	 "", //AppId can be gained from the Application information page in QIYU developer Protal e.g.:23068292
	 ""); //App security key can be gained from the Application information page in QIYU developer Protal e.g. d4093dadce6fa082d2727ebd7bb9eab1

Tips: In SDK v1.2.1 and above version, the APP secret of initialization API need to be updated, which can be found at "Developer Protal - Manage - My APPs - API".

# 3. Get user information

  • Unity XR SDK v1.2.1 or previous version:
// Get Qiyu Account information
    public void GetIQIYIAccountInfo()
    {
        if (QiyuPlugin.IsQiyuAccountLogin())
        {
            QiyuPlugin.GetQiyuAccountInfo(
           RequestCallbackByJson<QiyuPlugin.MessageResult<QiyuPlugin.QiyuAccountInfo>>.Create((QiyuPlugin.MessageResult<QiyuPlugin.QiyuAccountInfo> msg) =>
           {
               if (msg.IsSuccess())
               {
                   uid.text = msg.data.uid;
                   name.text = msg.data.name;
                   pic.text = msg.data.icon;
               }
           }));
        }
        else
        {
            //turn to Home to login
            QiyuPlugin.LaunchHome("login", "");
        }
    }
  • Platform v1.0.0 or above version:
// Get Qiyu Account information
    public void GetQiyuAccountInfo()
    {
        if (QiyuXRPlatform.IsQiyuAccountLogin())
        {
            QiyuXRPlatform.GetQiyuAccountInfo(QiyuMessage.GetRequestResult<QiyuMessage.QiyuAccountInfo>((msg) =>
            {
                if (msg.IsSuccess())
                {
                    uid.text = msg.data.uid;
                    nickName.text = msg.data.name;
                    pic.text = msg.data.icon;
                    Debug.Log(string.Format( " GetQiyuAccountInfo uid is {0},name is {1}", msg.data.uid, msg.data.name));
                }
            }));
        }
        else
        {
            //Turn to Home to login
            QiyuXRPlatform.LaunchHome("login", "");
        }
    }

# 4. The In-APP Payment initialization

The new version of initialization of IAP has added callback function, and the class name which includes QiyuPlugin has been changed to QiyuPay. The class name of the other APIs are all using QiyuPay.

  • Unity XR SDK v1.2.1 or previous version:
QiyuPlugin.InitQiyuPay();
QiyuPlugin.GetSkuList(QiyuPlugin.GetRequestResult<List<QiyuPlugin.QiyuPaySkuInfo>>(...)QiyuPlugin.PlaceOrder(QiyuPlugin.GetRequestResult<string>(...)
QiyuPlugin.QueryOrderResult(QiyuPlugin.GetRequestResult<QiyuPlugin.QiyuPayOrderResult>(...)
QiyuPlugin.QueryHistoryOrders(QiyuPlugin.GetRequestResult<QiyuPlugin.QiyuPayHistoryOrders>(...)
  • Platform v1.0.0 or above version:
using Qiyu.Sdk.Platform;

QiyuPay.InitQiyuPay(QiyuMessage.GetRequestResult<QiyuMessage.SDKInit>((msg) =>
{
  if (msg.IsSuccess())
  {
   Debug.Log( $" InitQiyuPay OK!");
   textField.text = $"InitQiyuPay OK!";
  }
  else
  {
   Debug.Log( $" InitQiyuPay Failed! code:{msg.code}");
   textField.text = $"InitQiyuPay Failed! code:{msg.code}";
  }
}));
QiyuPay.GetSkuList(QiyuMessage.GetRequestResult<List<QiyuMessage.QiyuPaySkuInfo>>(...)
QiyuPay.PlaceOrder(QiyuMessage.GetRequestResult<string>(...)
QiyuPay.QueryOrderResult(QiyuMessage.GetRequestResult<QiyuMessage.QiyuPayOrderResult>(...)
QiyuPay.QueryHistoryOrders(QiyuMessage.GetRequestResult<QiyuMessage.QiyuPayHistoryOrders>(...)

# 5. QiyuPrefs

The Init() has been deprecated, you do not need to call the APIs at the very beginning. After update to Platform SDK, if the error happened as the following screenshot( Figure 5.1.5), Please reimport Sample as the Fig 6.1.6 shows, and delet the init() in your code.

Fig5.1.5 Error after updated
Fig6.1.6 Reimport Sample
  • Unity XR SDK v1.2.1 or previous version:
public void GetDeeplinkCallBack(QiyuPlugin.MessageResult<QiyuPlugin.DeepLinkParam> ret)
    {
        Debug.Log(string.Format("QVRDemo:GetDeeplinkCallBack key is {0},value is {1}", ret.data.key, ret.data.value));
    }

public void OnApplicationPause(bool pause)
    {
       if (pause == false)
       {
            if (QiyuPlatform.IsAndroid)
                QiyuPlugin.GetDeepLink(RequestCallbackByJson<QiyuPlugin.MessageResult<QiyuPlugin.DeepLinkParam>>.Create(GetDeeplinkCallBack));
        }
    }

public void GoHomeLogin()
    {
        QiyuPlugin.LaunchHome("login", "");
   }
  • Platform v1.0.0 or above version:
void Start()
    {
//Other codes

//Get Deeplink Param
 QiyuXRPlatform.GetDeepLink(QiyuMessage.GetRequestResult<QiyuMessage.DeepLinkParam>(OnGetDeepLink));
}

void OnGetDeepLink(QiyuMessage.MessageResult<QiyuMessage.DeepLinkParam> msg)
    {
        if (msg.IsSuccess() && msg.data != null)
        {
            Debug.Log(string.Format( " OnGetDeepLink key is {0},value is {1}", msg.data.key, msg.data.value));
        }
    }

public void OnApplicationPause(bool pause)
    {
        if (pause == false)
        {
           QiyuXRPlatform.GetDeepLink(QiyuMessage.GetRequestResult<QiyuMessage.DeepLinkParam>(OnGetDeepLink));
       }
    }

public void GoHomeLogin()
    {
       QiyuXRPlatform.LaunchHome("login", "");
    }