Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fabric Digitsで始めるSMS認証

ogapants
February 01, 2017

Fabric Digitsで始めるSMS認証

・公式ドキュメント
https://docs.fabric.io/android/digits/overview.html
・TwitterCommunity(質問やバグ報告はこちら)
https://twittercommunity.com/c/fabric/digits
・更新情報
http://get.digits.com/blog
・Android公式サンプル(ちょっと古い)
https://github.com/crashlytics/digits-android

ogapants

February 01, 2017
Tweet

More Decks by ogapants

Other Decks in Technology

Transcript

  1. ೝূͷྲྀΕ 1. ి࿩൪߸ΛΞϓϦʹೖྗɾૹ৴ 2. Digitsαʔόܦ༝ͰSMSૹ৴͞ΕΔ 3. SMSͰདྷͨίʔυΛΞϓϦʹೖྗɾૹ৴ 4. Digitsαʔό͔ΒฦͬͨSessionIDΛࣗલͷαʔόʹૹ৴ 5.

    SessionIDΛݩʹDigitsαʔόʹ໰͍߹Θͤ ి࿩൪߸औಘͷύʔϛογϣϯ(READ_PHONE_STATE)Λ ௥ՃɾڐՄͰ͖Ε͹ࣗಈೖྗՄೳ SMSಡΈऔΓͷύʔϛογϣϯ(RECEIVE_SMS)Λ ௥ՃɾڐՄͰ͖Ε͹ࣗಈೖྗՄೳ
  2. ಋೖํ๏(DigitsAuthButton 2/2) • DigitsAuthButtonʹೝূޙͷॲཧ௥Ճ(java) DigitsAuthButton digitsButton = (DigitsAuthButton) findViewById(R.id.auth_button);
 digitsButton.setCallback(new

    AuthCallback() {
 @Override
 public void success(DigitsSession session, String phoneNumber) {
 // TODO: associate the session userID with your user model
 }
 
 @Override
 public void failure(DigitsException exception) {
 Log.d("Digits", "Sign in with Digits failure", exception);
 }
 });
  3. ಋೖํ๏(ΧελϜ) • ೝূޙͷॲཧͱϝιουݺͼग़͠ final AuthConfig authConfig = new AuthConfig.Builder()
 .withAuthCallBack(new

    AuthCallback() {
 @Override
 public void success(DigitsSession session, String phoneNumber) {
 // TODO: associate the session userID with your user model
 }
 
 @Override
 public void failure(DigitsException exception) {
 Log.d("Digits", "Sign in with Digits failure", exception);
 }
 }).build();
 button.setOnClickListener(new View.OnClickListener() {
 @Override
 public void onClick(View view) {
 Digits.authenticate(authConfig);
 }
 });
  4. ϋϚͬͨͱ͜Ζ • ࣗಈೖྗ͞Εͳ͍ʂˠجຊతʹి࿩൪߸ͱSMSಡΈऔΓͷύʔϛογϣϯ͚ͭΔ͚ͩͰOK͕ͩɺϚγϡϚϩҎ߱͸Digitsը໘Λग़͢લʹڐՄ͞ ͤͳ͚Ε͹ͳΒͳ͍ • σόοά࣌ʹຖճೖྗ͢Δͷେมʂˠsandbox͕࢖͑Δ `Digits.getInstance().enableSandbox();` • ೖྗը໘ΛΧελϜ͍ͨ͠ʂˠςʔϚͰݸੑΛग़͔͢͠ͳ͍ɺΧελϜUI͸ϕʔλ൛Ͱఏڙͯ͠ΔͷͰࢼ͔͢ؾ௕ʹ଴͔ͭ •

    SMSͷϝοηʔδΛม͍͑ͨʂˠΞϓϦ໊ͷมߋͰݸੑΛग़͔͢͠ͳ͍ • ΞϓϦ໊ม͑ͯ΋มΘΒͳ͍ʂˠͪΌΜͱίϯιʔϧ্ͷApplicationIDͱϏϧυͨ͠ΞϓϦͷID߹ͬͯΔ͔֬ೝ • SIMͳ͠୺຤ͩͱσϑΥϧτͰΞϝϦΧʹͳΔʂˠ೔ຊΛඪ४ʹ͍ͨ͠ͳΒwithCountry("+81")ΛݺͿ • SMSύʔϛογϣϯ෇͚ΔͱSIMͳ͠୺຤ͰΠϯετʔϧͰ͖ͳ͍ʂˠManifestͷ”android.hardware.telephony"ͷrequiredΛ"false"ʹ • ࣮ࡍͲΕ͘Β͍ͷϢʔβʔ͕ి࿩൪߸ೖΕ͔ͯΒೝূ·ͰߦͬͯΔ͔஌Γ͍ͨʂˠίϯιʔϧͰݟΕΔΑ • ↑͜ΕΛը໘্͡Όͳ͘਺ࣈͰΘ͔ΔΑ͏ʹ͍ͨ͠ʂ→DigitsEventLoggerΛઃఆͯ͠AnalyticsͳͲೖΕͯ෼ੳ • ίʔυͷࣗಈೖྗ͕2ճ໨Ҏ߱Ͱ͖ͳ͍ʂˠεϖʔε͕ͳ͍͍ͤɺใࠂதˠhttps://twittercommunity.com/t/81022 • ϩάΠϯग़དྷͳ͍ͱ͖͕͋ΔʂˠTwitterαʔόͱ࿈ಈͯ͠ΔͷͰಓ࿈ΕʹͳΔ͜ͱ΋ • SMS͕དྷͳ͍ʂˠ΍Γ͗͢Δͱདྷͳ͘ͳΔɺ͕࣌ؒܦͯ͹དྷΔΑ͏ʹͳΔ… • ͦ΋ͦ΋SMSػೳ͕ͳ͍SIMͳΜ͚ͩͲʂˠʮి࿩Λൃ৴ʯΛԡ͢ͱࣗಈԻ੠ి࿩͕͔͔ͬͯ͘ΔͷͰͦΕͰճආ • ͦ΋ͦ΋SMSػೳ΋௨࿩΋Ͱ͖ͳ͍SIMͳΜ͚ͩͲˠ͖͋ΒΊͯ • ͦ΋ͦ΋Ϣʔβʔ͕ి࿩൪߸ೖྗΛݏ͕ΔΜ͚ͩͲʂˠSMSΛϝΠϯʹͤͣଞͷೝূํ๏ͱซͤͯ࢖͏΄͏͕͍͍͔΋͠Εͳ͍ɺ΋͘͠͸લͷ ը໘Ͱ೚ҙͷి࿩൪߸ೖྗը໘࡞ͬͯͦ͜ͰೖΕͯ΋Βͬͨి࿩൪߸ΛDigitsͷը໘ʹ౉͢ͱ͔ • Contactͱ͔Emailͷػೳ΋͋ΔΈ͍͚ͨͩͲͳʹ͜Εʂ→ࢲ͸࢖ͬͨ͜ͱͳ͍ͷͰΘ͔Μͳ͍Ͱ͢… →Qiitaʹ·ͱΊ·͢