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