Facebook Instant Verification is not verifying mobile number via facebook app
Asked Answered
C

1

6

Hi I am implementing Facebook Instant Verification in my application. In my application, I am verifying mobile number of customers, for which I am sending OTP to get this verified.

I want to change approach as recently Facebook launched a concept Facebook Instant Verification which verify the mobile number on basis of whatever number you have configured on your Facebook account.

https://developers.facebook.com/blog/post/2016/12/20/introducing-instant-verification/

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

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

I have done whatever is said in articles but as it is written that whenever you enter same number which is configured in your facebook app then facebook account kit will verify your mobile number on basis of whatever is on your facebook account otherwise it sends OTP then do verification.

Problem

In my case I am entering same mobile number which is configured on my facebook account and using latest facebook application but still it does not verify the mobile number on basis of mobile number configured on facebook app, it always sends OTP.

As It should do verification without OTP. I am not sure what I am missing in my code and configuration as it always do verification using OTP.

Please support. Thanks in advance.

AndroidManifest.xml

<uses-permission android:name="android.permission.RECEIVE_SMS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.INTERNET" />

<application
    android:allowBackup="true"
    android:icon="@mipmap/ic_launcher"
    android:label="@string/app_name"
    android:supportsRtl="true"
    android:theme="@style/AppTheme">
    <activity android:name=".MainActivity">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <meta-data android:name="com.facebook.accountkit.ApplicationName"
        android:value="@string/app_name" />
    <meta-data android:name="com.facebook.sdk.ApplicationId"
        android:value="@string/FACEBOOK_APP_ID" />
    <meta-data android:name="com.facebook.accountkit.ClientToken"
        android:value="@string/ACCOUNT_KIT_CLIENT_TOKEN" />

    <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>

</application>

build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"
    defaultConfig {
        applicationId "spice.in.accountkitfacebookdemo"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}
repositories {
    jcenter()
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.android.support:appcompat-v7:23.0.1'
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:design:23.0.1'
    compile 'com.facebook.android:account-kit-sdk:4.+'
    compile 'com.google.android.gms:play-services:10.0.1'
}

strings.xml

<string name="app_name">AccountKitDemo</string>
<string name="FACEBOOK_APP_ID">XXX</string>
<string name="ACCOUNT_KIT_CLIENT_TOKEN">YYYY</string>
<string name="ak_login_protocol_scheme">akXXX</string>

MainActivity.java

@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.CODE); // or .ResponseType.TOKEN
    // ... perform additional configuration ...
    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();
    }


}

enter image description here

Craving answered 30/12, 2016 at 6:58 Comment(0)
C
4

You need to add the Android key hashes of your app on their developer portal for Instant Verification to work. Unfortunately this is not make clear in the current Instant Verification docs (we are working on make this clearer).

Right now, a user-app pair can only only do Instant Verification once an hour. We are improving this to allow infinitive attempts if you are an admin or developer of the app, but it will not be ready until the end of the week.

enter image description here

Craving answered 11/1, 2017 at 16:56 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.