4

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?

Exigente05
  • 2,161
  • 3
  • 22
  • 42

2 Answers2

8

You can use this

PhoneNumber phoneNumber = new PhoneNumber("+880","16XXXXXXXX","BD"); // country code, phone number, country code 

 final Intent intent = new Intent(context, AccountKitActivity.class);
    AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder(
                    LoginType.PHONE,
                    AccountKitActivity.ResponseType.CODE);

    configurationBuilder.setReadPhoneStateEnabled(true)
            .setReceiveSMS(true);

    intent.putExtra(
            AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION,
            configurationBuilder
                    .setInitialPhoneNumber(phoneNumber)
                    .build());
Nazmus Saadat
  • 973
  • 9
  • 22
4

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/

Pouya Larjani
  • 408
  • 3
  • 8