我设法整合了推特数字并且身份验证正常,但我想检查用户是否已经添加了他的号码和代码。
现在我只有身份验证部分:
final TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Crashlytics(), new Twitter(authConfig));
按钮事件:
digitsButton = (DigitsAuthButton) findViewById(R.id.auth_button);
digitsButton.setCallback(new AuthCallback() {
@Override
public void success(DigitsSession session,
String phoneNumber) {
// Do something with the session
Toast.makeText(WelcomeActivity.this,"Registration Successful",Toast.LENGTH_SHORT).show();
}
@Override
public void failure(DigitsException exception) {
// Do something on failure
Toast.makeText(WelcomeActivity.this,"Registration Failed",Toast.LENGTH_SHORT).show();
}
});
-
如何检查用户是否已执行这些步骤?
答案 0 :(得分:1)
您可以通过将数据存储在某处来保存身份验证成功的事实。 Storage Options
使用SharedPreferences,要检查身份验证是否成功,您可以使用下面的 isAuthenticated :
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
boolean isAuthenticated = settings.getBoolean("ALREADY_AUTHENTICATED", false);
要设置身份验证成功(true),您可以将其放入回调的成功方法
// We need an Editor object to make preference changes.
// All objects are from android.context.Context
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
SharedPreferences.Editor editor = settings.edit();
editor.putBoolean("ALREADY_AUTHENTICATED", true /** or false */);
// Commit the edits!
editor.commit();