I managed to integrate twitter digits and the authentication is working, but I want to check if the user already added his number and code.
For now I only have the authentication part:
final TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
Fabric.with(this, new Crashlytics(), new Twitter(authConfig));
And the button event:
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();
}
});
-
How can I check if the user already made these steps?
You can save the fact that an authentication was successful by storing the data somewhere. Storage Options
Using SharedPreferences, to check if an authentication was successful you would use isAuthenticated below:
SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
boolean isAuthenticated = settings.getBoolean("ALREADY_AUTHENTICATED", false);
And to set that an authentication was successful (true), you could put this in the callback's success method
// 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();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.