您好我正在我的应用程序中实现Facebook Instant Verification
。在我的应用程序中,我正在验证移动号码的客户,我正在发送OTP以获得此验证。
我想改变方法,因为最近Facebook推出了一个概念Facebook Instant Verification
,根据您在Facebook
帐户中配置的任何数字来验证手机号码。
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
我已经完成了文章中所说的内容,但是因为它写的是每当你输入在你的facebook应用程序中配置的相同号码时,facebook帐户工具包将根据你的facebook帐户上的任何内容验证你的手机号码,否则它会发送然后OTP进行验证。
在我的情况下,我输入的相同手机号码在我的脸书帐户上配置并使用最新的Facebook应用程序,但仍然没有根据Facebook应用程序上配置的手机号码验证手机号码,它总是发送OTP。
因为它应该在没有OTP的情况下进行验证。我不确定我的代码和配置中缺少什么,因为它始终使用OTP进行验证。
请支持。提前谢谢。
<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>
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'
}
<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>
@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();
}
}