GUAQrCodeResultObservers [MSDK Only]
[MSDK Only] Register the callback of the QR module for the PC client, the game needs to process the callback function. For more information on the callback data structure, see the following GUAQrCodeRet.
note
It is strongly recommended to perform registration in the startup function of the game application.
Data Structures
GUAQrCodeRet
Parameter | Type | Description |
---|---|---|
ChannelID | int | Channel ID of the logged channel |
Channel | string | The logged in channel |
QrCodeUrl | string | QR code URL |
Function Definition
- Unity
- Unreal Engine
// QrCodeRetEvents callback, PC login QR code callback
event OnResultHandler<GUAQrCodeRet> QrCodeRetEvents;
class GUA_EXTERN GUAAccountObserver
{
public:
virtual ~GUAAccountObserver() {};
#if GUA_OS_WINDOWS
virtual void OnQrCodeNotify(const GUAQrCodeResult &qr_code_result) {};
#endif
};
Code Sample
- Unity
- Unreal Engine
#if GCLOUD_MSDK_WINDOWS
public void OnQrCodeRetEvent (GUAQrCodeRet qrCodeRet)
{
//Login QR code callback (For SDK authorization only, not required for Web)
Debug.Log ("OnQrCodeRetEvent in Login." + " channel:" + qrCodeRet.Channel + " qrCodeUrl:" + qrCodeRet.QrCodeUrl);
if (qrCodeRet.Channel == "QQ")
{
StartCoroutine (loadImage (qrCodeRet.QrCodeUrl));
}
else if (qrCodeRet.Channel == "WeChat")
{
if (qrEncodeController != null)
{
qrEncodeController.Encode(qrCodeRet.QrCodeUrl);
}
}
}
#endif
#if MSDK_PLATFORM_WINDOWS
void GUABaseCallBacks::OnQrCodeNotify(const GUA::GUAQrCodeResult &qrCodeRet) {
//Login QR code callback (For SDK authorization only, not required for Web)
std::string url_str = "start ";
if (qrCodeRet.channel == "QQ") {
url_str = url_str + qrCodeRet.qr_code_url;
} else if (qrCodeRet.channel == "WeChat") {
url_str = url_str + "https://cli.im/api/qrcode/code?text=" + qrCodeRet.qr_code_url;
}
system(url_str.c_str());
}
#endif