6

In the success method, I've been trying to use the phoneNumber but it's a null object even after successful OTP check on my android app. Please let me know how can I get the phoneNumber after fabric verification to use it for user registration on my app.

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();
        }
    });
ddheader
  • 61
  • 2

1 Answers1

4

I'm not sure if it's a bug, but if there's already an active session the number will not be returned. If you're authenticating anyway, you've probably detected a missing existing session. If you'd like to force this number to show up - call

Digits.getSessionManager().clearActiveSession(); 

before setting callback.

SIr Codealot
  • 5,331
  • 9
  • 33
  • 45
  • 1
    Though I read more into it and this seems to be the way it's supposed to be. Since you should be storing the phone number on the server and query using the token (see documentation: http://docs.fabric.io/android/digits/verify-user.html). – SIr Codealot Jul 31 '15 at 17:57
  • This didnt work for me . It works in Emulator but not in Real device – Suresh Kumar Aug 26 '16 at 06:36