com.digits.sdk.android.DigitsException Java Examples

The following examples show how to use com.digits.sdk.android.DigitsException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: LoginActivity.java    From cannonball-android with Apache License 2.0 6 votes vote down vote up
private void setUpDigitsButton() {
    phoneButton = (DigitsAuthButton) findViewById(R.id.phone_button);
    phoneButton.setAuthTheme(R.style.AppTheme);
    phoneButton.setCallback(new AuthCallback() {
        @Override
        public void success(DigitsSession digitsSession, String phoneNumber) {
            SessionRecorder.recordSessionActive("Login: digits account active", digitsSession);
            Answers.getInstance().logLogin(new LoginEvent().putMethod("Digits").putSuccess(true));
            startThemeChooser();
        }

        @Override
        public void failure(DigitsException e) {
            Answers.getInstance().logLogin(new LoginEvent().putMethod("Digits").putSuccess(false));
            Toast.makeText(getApplicationContext(),
                    getResources().getString(R.string.toast_twitter_digits_fail),
                    Toast.LENGTH_SHORT).show();
            Crashlytics.logException(e);
        }
    });
}
 
Example #2
Source File: RNDigits.java    From react-native-digits with MIT License 5 votes vote down vote up
@ReactMethod
public void view(final Callback cb) {

  authCallback = new AuthCallback() {
    @Override
    public void success(DigitsSession session, String phoneNumber){
      WritableMap auth = Arguments.createMap();

      Digits digits = Digits.getInstance();

      TwitterAuthConfig config = digits.getAuthConfig();
      auth.putString("consumerKey", config.getConsumerKey());
      auth.putString("consumerSecret", config.getConsumerSecret());

      TwitterAuthToken token = (TwitterAuthToken)session.getAuthToken();

      auth.putString("authToken", token.token);
      auth.putString("authTokenSecret", token.secret);

      Long id = session.getId();
      auth.putString("userId", String.valueOf(id));
      auth.putString("phoneNumber", session.getPhoneNumber());

      cb.invoke(null, auth);
    }

    @Override
    public void failure(DigitsException error) {
      cb.invoke(error.getLocalizedMessage(), null);
    }
  };  

  int themeId = mContext.getResources().getIdentifier("CustomDigitsTheme", "style", mContext.getPackageName());
  DigitsAuthConfig.Builder digitsAuthConfigBuilder = new DigitsAuthConfig.Builder()
    .withAuthCallBack(authCallback)
    .withPhoneNumber("")
    .withThemeResId(themeId);
  Digits.authenticate(digitsAuthConfigBuilder.build());
}
 
Example #3
Source File: LoginActivity.java    From Pharmacy-Android with GNU General Public License v3.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_login);
    ButterKnife.bind(this);

    mAnalytics = FirebaseAnalytics.getInstance(this);

    mAnimator = new ObjectAnimator();

    mIconAnimation =(Animator) AnimatorInflater.loadAnimator(this, R.animator.icon_loading_rotate);
    mIconAnimation.setTarget(appIconImageView);


   // final DigitsAuthButton authButton = (DigitsAuthButton) findViewById(R.id.button_auth);
    authButton.setAuthTheme(R.style.AppTheme);
    authButton.setText("Login");
    authButton.setBackgroundColor(ContextCompat.getColor(this, R.color.colorPrimary));


    authButton.setCallback(new AuthCallback() {
        @Override
        public void success(DigitsSession session, String phoneNumber) {
           // Log.d(TAG, "success: ph no: " + phoneNumber);
          //  Log.d(TAG, "Auth token" + session.getAuthToken());
            TwitterAuthConfig authConfig = TwitterCore.getInstance().getAuthConfig();
            mPhoneNumber = session.getPhoneNumber();

            DigitsOAuthSigning oAuthSigning = new DigitsOAuthSigning(authConfig,
                    (TwitterAuthToken) session.getAuthToken());
            Map<String, String> authHeaders = oAuthSigning.getOAuthEchoHeadersForVerifyCredentials();

            doLogin(authHeaders);

          //  Toast.makeText(LoginActivity.this, "Phone no: " + session.getPhoneNumber(), Toast.LENGTH_SHORT).show();
        }

        @Override
        public void failure(DigitsException error) {
            showLoginError();
        }
    });
}