本文介绍了从Facebook帐户套件获取电话号码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Account Kit文档指出,如果您使用AccountKitActivity.ResponseType.TOKEN开始登录会话,可以通过调用getCurrentAccount()访问当前帐户的帐户工具包ID,电话号码和电子邮件。

The Account Kit documentation states that if your began the login session with AccountKitActivity.ResponseType.TOKEN, it's possible to access the Account Kit ID, phone number and email of the current account via a call to getCurrentAccount().

如果您开始使用AccountKitActivity.ResponseType.CODE,就像Saavn一样,可以获取用户的电话号码?

Is it possible to get the user's phone number if you began with AccountKitActivity.ResponseType.CODE just like the way Saavn does it?

推荐答案

是的,您可以在配置中使用LoginType.PHONE。

Yes, it's possible provided you use LoginType.PHONE in your configuration.

    AccountKit.getCurrentAccount(new AccountKitCallback<Account>() {
        @Override
        public void onSuccess(final Account account) {
            String accountKitId = account.getId();
            PhoneNumber phoneNumber = account.getPhoneNumber();
            String phoneNumberString = phoneNumber.toString();
        }

        @Override
        public void onError(final AccountKitError error) {
            // Handle Error
        }
    });

这是你的电话号码:phoneNumberString;但是,如果您的配置中使用了LoginType.PHONE,则 account.getEmail()将返回null。

如果您的配置中使用LoginType.EMAIL,反之亦然。

This is your phone number: phoneNumberString; but, account.getEmail() will return null if LoginType.PHONE was used in your configuration.
Vice versa if you use LoginType.EMAIL in your configuration.

这篇关于从Facebook帐户套件获取电话号码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-20 17:13