IMPLEMENT WITH CONFIDENCE
Simple, secure, safe
We've meticulously optimized the performance, scalability, and availability of our infrastructure by building strong relationships with SMS carriers and adding dynamic SMS routing. We have taken extreme care to ensure your app data is safe and protected. Get all the benefits of Digits with peace of mind - it only takes a few lines of code to get started.
activity_main.xml ViewController.m ViewController.swift
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin" tools:context=".MainActivity">
<com.digits.sdk.android.DigitsAuthButton
android:id="@+id/auth_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
#import "ViewController.h"
#import <DigitsKit/DigitsKit.h>
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
DGTAuthenticateButton *authButton;
authButton = [DGTAuthenticateButton buttonWithAuthenticationCompletion:^(DGTSession *session, NSError *error) {
if (session.userID) {
// TODO: associate the session userID with your user model
NSString *msg = [NSString stringWithFormat:@"Phone number: %@", session.phoneNumber];
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"You are logged in!"
message:msg
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alert show];
} else if (error) {
NSLog(@"Authentication error: %@", error.localizedDescription);
}
}];
authButton.center = self.view.center;
[self.view addSubview:authButton];
}
@end
import UIKit
import DigitsKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
let authButton = DGTAuthenticateButton(authenticationCompletion: { (session: DGTSession?, error: NSError?) in
if (session != nil) {
// TODO: associate the session userID with your user model
let message = "Phone number: \(session!.phoneNumber)"
let alertController = UIAlertController(title: "You are logged in!", message: message, preferredStyle: .Alert)
alertController.addAction(UIAlertAction(title: "Cancel", style: .Cancel, handler: .None))
self.presentViewController(alertController, animated: true, completion: .None)
} else {
NSLog("Authentication error: %@", error!.localizedDescription)
}
})
authButton.center = self.view.center
self.view.addSubview(authButton)
}
}