如何立即从Google Play服务Unity插件获取ID令牌 [英] How to immediately get id token from google play services Unity Plugin

查看:265
本文介绍了如何立即从Google Play服务Unity插件获取ID令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用 https://github.com/playgameservices/play- games-plugin-for-unity 插件使用他的google帐户登录用户,然后我想获取ID令牌并将其发送到我的服务器,并在我自己的数据库中为此用户注册一个帐户.这是我的获取ID令牌的代码:

I'm using https://github.com/playgameservices/play-games-plugin-for-unity plugin to sign in user with his google account , and then i want to get Id Token and send it to my server and register an account for this user in my own database.this is my code to get Id token :

PlayGamesPlatform.Instance.Authenticate(success =>
{
    if (success)
    {
        Debug.Log("Id Token :");
        Debug.LogFormat("{0}", PlayGamesPlatform.Instance.GetIdToken());
        Debug.Log("End Of Id Token");
    }
});

问题是它第一次只打印空字符串,当我第二次(或稍后)调用它时,它打印令牌.我想立即获取令牌,或通过回调获取令牌,以确保收到令牌.

The problem is the first time it prints just empty string , when i call this for the second time (or a moment later) it prints the token. I want to get token immediately or with a callback to make sure that token is recieved .

如何确保收到令牌?有回调吗?

How to make sure that token is recieved? is there any callback for this?

谢谢

推荐答案

他们更改了新版本的插件

They changed the plugin in new version and now

PlayGamesPlatform.Instance.GetIdToken(Callback)

具有回调函数.

这篇关于如何立即从Google Play服务Unity插件获取ID令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆