com.digits.sdk.android.Digits Java Examples

The following examples show how to use com.digits.sdk.android.Digits. 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: AboutActivity.java    From cannonball-android with Apache License 2.0 6 votes vote down vote up
private void setUpSignOut() {
    final TextView bt = (TextView) findViewById(R.id.deactivate_accounts);
    bt.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            Twitter.getSessionManager().clearActiveSession();
            Digits.getSessionManager().clearActiveSession();
            SessionRecorder.recordSessionInactive("About: accounts deactivated");
            Answers.getInstance().logLogin(new LoginEvent().putMethod("Twitter").putSuccess(false));
            Answers.getInstance().logLogin(new LoginEvent().putMethod("Digits").putSuccess(false));

            Toast.makeText(getApplicationContext(), "All accounts are cleared",
                    Toast.LENGTH_SHORT).show();
        }
    });
}
 
Example #2
Source File: App.java    From Pharmacy-Android with GNU General Public License v3.0 5 votes vote down vote up
public static void logout() {
    String TAG = BuildConfig.APPLICATION_ID + ".App";
    if (!BuildConfig.DEBUG) {
        if (Digits.getSessionManager() != null) {
            Digits.getSessionManager().clearActiveSession();
            Log.d(TAG, "Logged out from digits");
        }
    }
    FirebaseAuth.getInstance().signOut();
}
 
Example #3
Source File: RNDigits.java    From react-native-digits with MIT License 5 votes vote down vote up
public RNDigits(ReactApplicationContext reactContext) {
  super(reactContext);
  mContext = reactContext;
  
  final TwitterAuthConfig authConfig = getTwitterConfig();
  
  final Fabric fabric = new Fabric.Builder(mContext)
    .kits(new Digits(), new TwitterCore(authConfig))
    .logger(new DefaultLogger(Log.DEBUG))
    .debuggable(true)
    .build();
  
  Fabric.with(fabric);
}
 
Example #4
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 #5
Source File: InitialActivity.java    From cannonball-android with Apache License 2.0 5 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    final Session activeSession = SessionRecorder.recordInitialSessionState(
            Twitter.getSessionManager().getActiveSession(),
            Digits.getSessionManager().getActiveSession()
    );

    if (activeSession != null) {
        startThemeActivity();
    } else {
        startLoginActivity();
    }
}
 
Example #6
Source File: App.java    From cannonball-android with Apache License 2.0 5 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();
    singleton = this;
    extractAvenir();
    authConfig
            = new TwitterAuthConfig(BuildConfig.CONSUMER_KEY, BuildConfig.CONSUMER_SECRET);
    Fabric.with(this, new Crashlytics(), new Digits(), new Twitter(authConfig), new MoPub());

    Crashlytics.setBool(CRASHLYTICS_KEY_CRASHES, areCrashesEnabled());
}
 
Example #7
Source File: RNDigits.java    From react-native-digits with MIT License 4 votes vote down vote up
@ReactMethod
public void logout() {
  Digits.getSessionManager().clearActiveSession(); 
}
 
Example #8
Source File: App.java    From Pharmacy-Android with GNU General Public License v3.0 3 votes vote down vote up
@Override
public void onCreate() {
    super.onCreate();

    final String TWITTER_KEY = getString(R.string.twitter_key);
    final String TWITTER_SECRET = getString(R.string.twitter_secret);

    final TwitterAuthConfig authConfig = new TwitterAuthConfig(TWITTER_KEY, TWITTER_SECRET);
    // Initialize Firebase

    mFirebase = FirebaseDatabase.getInstance();

    mFirebase.setPersistenceEnabled(true);

    mContext = this;

    // Fabric initialization
    Crashlytics crashlyticsKit = new Crashlytics.Builder()
            .core(new CrashlyticsCore.Builder().disabled(BuildConfig.DEBUG).build())
            .build();

    Fabric.with(this, new TwitterCore(authConfig), new Digits(), crashlyticsKit);

    if (BuildConfig.DEBUG) {
        Timber.plant(new Timber.DebugTree());
    }

    Timber.plant(new CrashlyticsTree());

}