Increasingly, the phone number is the primary identifier for an individual. In developing markets, it’s the only identifier. Digits is a new way for your users to sign in to their apps and websites without using a password. Simple and safe to use, Digits requires only a phone number. With Friend Finding, Digits is also reinventing social graphs with the one everyone has on their phone: the address book.
40. USE YOUR OWN BUTTON
import TwitterKit
class ViewController: UIViewController {
@IBAction func didTapButton(sender: AnyObject) {
}
}
Digits.sharedInstance().authenticateWithCompletion { (session, error) in
// Inspect the Digits session/error objects.
}
41. THEME YOUR DIGITS EXPERIENCE
import TwitterKit
class ViewController: UIViewController {
@IBAction func didTapButton(sender: AnyObject) {
}
}
let digitsAppearance = DGTAppearance()
digitsAppearance.backgroundColor = UIColor.blackColor()
digitsAppearance.accentColor = UIColor.greenColor()
Digits.sharedInstance().authenticateWithDigitsAppearance(digitsAppearance,
viewController: nil, title: nil) { (session, error) in
// Inspect the Digits session/error objects.
}
45. ADD DIGITS TO YOUR WEB APP
<!DOCTYPE html>
<html>
<head>
<title>Welcome to Cannonball</title>
<meta charset="UTF-8">
</head>
<body>
<button id="digits-btn">Sign In with Phone</button>
<script id="digits-sdk" src="https://cdn.digits.com/1/sdk.js" async></script>
</body>
</html>
46. ADD DIGITS TO YOUR WEB APP
<script>
document.getElementById('digits-sdk').onload = function() {
};
</script>
// Set a click event listener on the button.
document.getElementById('digits-btn').addEventListener("click", onLoginButtonClick);
// Implement the login button callback and handle the response.
function onLoginButtonClick() {
Digits.logIn().done(onLogin).fail(onLoginFailure);
}
// Initialize Digits and check if the user is already logged into Digits.
Digits.init({ consumerKey: "o0gzicSS27GgtEJsu7wT442SG" }).done(function() {
Digits.getLoginStatus().done(onLoginStatus);
});
47. VERIFY A DIGITS TOKEN & RETRIEVE USER INFO
// Parse the OAuth Echo headers.
var oAuthEchoHeaders = loginResponse.oauth_echo_headers;
var verifyData = {
credentials: oAuthEchoHeaders['X-Verify-Credentials-Authorization'],
apiUrl: oAuthEchoHeaders['X-Auth-Service-Provider']
};
// Post this data and from your server, securely request over SSL
// the user information including the phone number.
$.post('/verify', verifyData).done(function() {
// Update the user interface with user information.
});
<script>
// Validate the authentication and sign the user in.
function onLogin(loginResponse) {
}
</script>
58. FIND FRIENDS
// Initialize the Find Friends button from the view.
findFriendsButton = (Button) findViewById(R.id.find_your_friends_button);
// Set a listener on the Find Friends button.
findFriendsButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
// Start uploading the Address Book.
Digits.getInstance().getContactsClient().startContactsUpload();
}
});
59. FIND FRIENDS
// Retrieve the contact matches.
Digits.getInstance().getContactsClient().lookupContactMatches(null, null,
new ContactsCallback<Contacts>() {
});
@Override
public void success(Result<Contacts> result) {
if (result.data.users != null) {
// Process contacts data.
}
}
@Override
public void failure(TwitterException exception) {
// Show error.
}
61. As we continue to grow internationally, Digits
is extremely helpful. Many of our customers
prefer to verify their accounts via phone, so
Digits is the easiest solution for them and us.”
“
- Sean Smith,
Senior Director, Client Engineering, Rdio