User mobile number not verifying via Facebook account,only verifying via sms when using Account Facebook kit

432 views Asked by At

I have followed below link for verified user mobile number using facebook account kit SDK.

https://developers.facebook.com/docs/accountkit/android

Add facebook app id, client id and application token, all required permission use in the manifest file like RECEIVE_SMS, READ_PHONE_STATE, INTERNET.

 <activity
        android:name="com.facebook.accountkit.ui.AccountKitActivity">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="@string/ak_login_protocol_scheme" />
        </intent-filter>
    </activity>

FACEBOOK_APP_ID(xxxxxxx), ACCOUNT_KIT_CLIENT_TOKEN(xxxxx),ak_login_protocol_scheme(akxxxxxx) define in the string.xml and use code in the app which is mentioned in the above link. It works for only verified mobile number using SMS not verified direct facebook account.Please provide me any solution for solve this problem.

MainActivity class

public class MainActivity extends AppCompatActivity implements  View.OnClickListener {
    Button send;
    public static int APP_REQUEST_CODE = 99;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        AccountKit.initialize(getApplicationContext());
        send = (Button) findViewById(R.id.send);
        send.setOnClickListener(this);
    }


    @Override
    public void onClick(View v) {
        onLoginPhone();
    }

    public void onLoginPhone() {
        final Intent intent = new Intent(this, AccountKitActivity.class);
        AccountKitConfiguration.AccountKitConfigurationBuilder configurationBuilder = new AccountKitConfiguration.AccountKitConfigurationBuilder(LoginType.PHONE, AccountKitActivity.ResponseType.TOKEN);
        intent.putExtra(AccountKitActivity.ACCOUNT_KIT_ACTIVITY_CONFIGURATION, configurationBuilder.build());
        startActivityForResult(intent, APP_REQUEST_CODE);
    }

    @Override
    protected void onActivityResult(
        final int requestCode,
        final int resultCode,
        final Intent data) {
        super.onActivityResult(requestCode, resultCode, data);
        if (requestCode == APP_REQUEST_CODE) { // confirm that this response matches your request
            AccountKitLoginResult loginResult = data.getParcelableExtra(AccountKitLoginResult.RESULT_KEY);
            String toastMessage;
            if (loginResult.getError() != null) {
                toastMessage = loginResult.getError().getErrorType().getMessage();
                Toast.makeText(this, "Get Error " + loginResult.getError(), Toast.LENGTH_LONG).show();
            } else if (loginResult.wasCancelled()) {
                toastMessage = "Login Cancelled";
            } else {
                if (loginResult.getAccessToken() != null) {
                    toastMessage = "Success:" + loginResult.getAccessToken().getAccountId();
                } else {
                    toastMessage = String.format("Success:%s...", loginResult.getAuthorizationCode().substring(0, 10));
                }
                Toast.makeText(this, "Successfully done", Toast.LENGTH_LONG).show();
            }
            Toast.makeText(this, toastMessage, Toast.LENGTH_LONG).show();
        }
    }
1

There are 1 answers

0
Patient Baïse On

ak_login_protocol_scheme is your id app add "ak" exemple :

<string name="app_id">1455555555555555555/string>
<string name="ACCOUNT_KIT_CLIENT_TOKEN">332555dcdcddccszzd</string>

<string name="ak_login_protocol_scheme">ak1455555555555555555</string>