LoginSignup
1
4

More than 5 years have passed since last update.

Digitsを使ってWebで電話番号認証

Last updated at Posted at 2016-12-17

2017/06/19 追記
DigitsはFirebaseの電話番号認証機能に統合
http://get.digits.com/blog/introducing-firebase-phone-authentication

Digitsとは

Twitterが開発した、電話番号認証を行うライブラリ。iOS、Android、Webで使える。
https://get.digits.com/
https://docs.fabric.io/web/digits/overview.html

導入

FabricからTwitterアプリを追加してCONSUMER KEYを取得

HTMLにDigitsのSDKを埋め込む

<head>
  <script id="digits-sdk" src="https://cdn.digits.com/1/sdk.js" async></script>
</head>

Digitsの初期化処理

/* Initialize Digits for Web using your application's consumer key that Fabric generated */
document.getElementById('digits-sdk').onload = function() {
  Digits.init({ consumerKey: 'yourConsumerKey' });
};

ボタンをクリックした時の挙動を作成する

/* Launch the Login to Digits flow. */
function onLoginButtonClick(event){
  Digits.logIn()
    .done(onLogin) /*handle the response*/
    .fail(onLoginFailure);
}

実行結果

ログイン.jpg

ログイン_and_chatcenter_io_and_新規投稿_-_Qiita.jpg

1
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
4