I am experimenting with Digits API by Twitter for registering users on my Android application. Currently in my launching activity I display a button(com.digits.sdk.android.DigitsAuthButton
) that asks for users to enter their phone number so that a confirmation code could be sent. Once they enter the confirmation code and are authenticated, I receive a user_id
in the callback method.
Now, next time if I click on the same button in the launching activity it doesn't display the option to enter the phone number and just returns back the same user_id
which was already registered.
I want to replicate this same thing in my Java code without that extra click of the com.digits.sdk.android.DigitsAuthButton
button. I had a look at some samples and they use the following statement to verify the same:
if (Digits.getSessionManager().getActiveSession() != null) { ... }
Is this sufficient or should I use sharedPreference to store the returned user_id
with the phone number too ?
Update
Personally i'm using sharedpreference
it works well for me..
as for handling "change in phone number later on" you can create a log out Button to turn a preference
from true to false.
Or
you can check change in phone number:
TelephonyManager tMgr = (TelephonyManager)mAppContext.getSystemService(Context.TELEPHONY_SERVICE);
String mPhoneNumber = tMgr.getLine1Number();
//Required Permission:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>