GUAQrCodeResultObservers [MSD only]
[MSDK Only] Callback for the PC registration QR code. The game must handle this callback accordingly.For more about the callback data structure, see GUAQrCodeRet.
note
It is strongly recommended that the game performs the registration in the application startup function.
Data structure
GUAQrCodeRet
| Parameters | Type | Description |
|---|---|---|
| ChannelID | int | Login channel ID |
| Channel | string | Login channel |
| QrCodeUrl | string | QR code address |
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 Example
- Unity
- Unreal Engine
#if GCLOUD_MSDK_WINDOWS
public void OnQrCodeRetEvent (GUAQrCodeRet qrCodeRet)
{
//Login QR code callback (required only for SDK authorization; not required for Web authorization)
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 (required only for SDK authorization; not required for Web authorization)
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