Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting phone number from Facebook Account Kit

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().

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

like image 470
Alex Kombo Avatar asked May 03 '16 15:05

Alex Kombo


1 Answers

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
        }
    });

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.

like image 179
ayz4sci Avatar answered Oct 11 '22 18:10

ayz4sci