2017-08-28 35 views
1

電話番号認証付きのイオンモバイルアプリ(firebaseを使用)を作成したいだけですが、どのように進めるべきかわかりません。誰かが私を助けることができますか?ありがとうございました。電話番号がionic3のfirebaseの電話番号

Activate Phone Number Authentication in your Firebase Console. 
Set up reCAPTCHA verifier. 
Send the SMS 
Sign the user in. 

.htmlを

<ion-content padding> 
    <div id="recaptcha-container"></div> 

    <ion-item> 
    <ion-label stacked>Phone Number</ion-label> 
    <ion-input type="number" [(ngModel)]="phoneNumber"></ion-input> 
    </ion-item> 

    <button ion-button id="sign-in-button" (click)="signIn(phoneNumber)"> 
    Sign In 
    </button> 

</ion-content> 

.TSここ

signIn(phoneNumber: number){ 
    const appVerifier = this.recaptchaVerifier; 
    const phoneNumberString = "+" + phoneNumber; 
    firebase.auth().signInWithPhoneNumber(phoneNumberString, appVerifier) 
    .then(confirmationResult => { 
     // SMS sent. Prompt user to type the code from the message, then sign the 
     // user in with confirmationResult.confirm(code). 
     let prompt = this.alertCtrl.create({ 
     title: 'Enter the Confirmation code', 
     inputs: [{ name: 'confirmationCode', placeholder: 'Confirmation Code' }], 
     buttons: [ 
     { text: 'Cancel', 
      handler: data => { console.log('Cancel clicked'); } 
     }, 
     { text: 'Send', 
      handler: data => { 
      confirmationResult.confirm(data.confirmationCode) 
      .then(function (result) { 
       // User signed in successfully. 
       console.log(result.user); 
       // ... 
      }).catch(function (error) { 
       // User couldn't sign in (bad verification code?) 
       // ... 
      }); 
      } 
     } 
     ] 
    }); 
    prompt.present(); 
    }) 
    .catch(function (error) { 
    console.error("SMS not sent", error); 
    }); 

} 

からコードの上に抽出Great article about it .Iです:

答えて

1

は、次の手順を実行する必要がありこれはレーキ

Offical doc

+0

ypuの@Sampathに感謝。私はそれを試してみる – user8528238

+0

OK sure.No problem :) – Sampath

+0

それは私にそのエラー(エラー:./node_modules/firebase/utils/promise.js)を与えているIwiilはそれを修正しようとするが、あなたが考えている場合... – user8528238