如何使用Unity从Firebase发送短信

时间:2018-07-27 12:06:46

标签: firebase unity3d firebase-authentication

祝您有美好的一天...我正在学习Firebase。在我的应用程序中,如何从Unity发送短信(密码验证码)。

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:1)

来自Firebase documentation for Unity on sending a SMS verification code

  

呼叫PhoneAuthProvider.VerifyPhoneNumber,并将用户的电话号码传递给它。

PhoneAuthProvider provider = PhoneAuthProvider.GetInstance(firebaseAuth);
provider.VerifyPhoneNumber(phoneNumber, phoneAuthTimeoutMs, null,
  verificationCompleted: (credential) => {
    // Auto-sms-retrieval or instant validation has succeeded (Android only).
    // There is no need to input the verification code.
    // `credential` can be used instead of calling GetCredential().
  },
  verificationFailed: (error) => {
    // The verification code was not sent.
    // `error` contains a human readable explanation of the problem.
  },
  codeSent: (id, token) => {
    // Verification code was successfully sent via SMS.
    // `id` contains the verification id that will need to passed in with
    // the code from the user when calling GetCredential().
    // `token` can be used if the user requests the code be sent again, to
    // tie the two requests together.
  },
  codeAutoRetrievalTimeout: (id) => {
    // Called when the auto-sms-retrieval has timed out, based on the given
    // timeout parameter.
    // `id` contains the verification id of the request that timed out.
  });

有关完整信息,请参见链接的文档。