androidfacebookaccount-kit

Pass mobile number to Facebook AccountKitActivity


I am using Facebook account kit to verify user mobile number. I have used below code,

final Intent intent = new Intent(MainActivity.this, AccountKitActivity.class);
    AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder =
            new AccountKitConfiguration.AccountKitConfigurationBuilder(
                    LoginType.PHONE,
                    AccountKitActivity.ResponseType.TOKEN); // or .ResponseType.TOKEN
    // ... perform additional configuration ...
    intent.putExtra(
            AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
            configurationBuilder.build());
    startActivityForResult(intent, APP_REQUEST_CODE);

All is doing well. I want to pass user mobile number to AccountKit activity. Is it possible to make it work? How? Actually I want to prevent duplicate mobile verification using Account Kit, is there any other way?


Solution

  • So in the place where it says

    // ... perform additional configuration ...
    

    you can set the initial phone number by doing:

    configurationBuilder.setInitialPhoneNumber(phoneNumber);
    

    where phoneNumber is of type com.facebook.accountkit.PhoneNumber. This class takes 3 parameters: country code (like "+1"), phone number (like "5551234567") and an ISO country code (like "US")

    There's other settings you can do in configurationBuilder as well. See for reference: https://developers.facebook.com/docs/reference/androidsdk/current/AccountKit/com/facebook/accountkit/ui/accountkitconfiguration.accountkitconfigurationbuilder.html/