简体   繁体   中英

FirebaseAuth -SmsRetrieverHelper -SMS verification code request failed: unknown status code: 17042 Invalid format

i am following ref

I am using my own phone to test this app. no errors but unable to send sms verifition code. my log is:

    [FirebaseApp] Device unlocked: initializing all Firebase APIs for app [DEFAULT]
[FirebaseInitProvider] FirebaseApp initialization successful
[FirebaseAuth] [FirebaseAuth:] Preparing to create service connection to fallback implementation
[System] Ignoring header X-Firebase-Locale because its value was null.
[System] Ignoring header X-Firebase-Locale because its value was null.
[FirebaseAuth] [SmsRetrieverHelper] SMS verification code request failed: unknown status code: 17042 Invalid format.

Nuget download

xamarin.firebase.core
xamarin.firebase.auth

MainAcivity.cs - set up

   protected override async void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);

        var fb = FirebaseApp.InitializeApp(Application.Context);
        ...

        LoadApplication(new App());
    }

used to send sms code

PhoneAuthOptions options =
                PhoneAuthOptions.NewBuilder(FirebaseAuth.Instance)
                .SetPhoneNumber(myPhonenumber)       // Phone number to verify
                .SetTimeout(num, TimeUnit.Seconds) // Timeout and unit
                .SetActivity(Platform.CurrentActivity)                 // Activity (for callback binding)
                .SetCallbacks(this)          // OnVerificationStateChangedCallbacks
                .Build();
        PhoneAuthProvider.VerifyPhoneNumber(options);

Android project > Manifiest.cs - added network permissions

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="1" android:versionName="1.0" package="com.companyname.testapp_miniapps">
    <uses-sdk android:minSdkVersion="21" android:targetSdkVersion="30" />
    <application android:label="TestApp_MiniApps.Android" android:theme="@style/MainTheme">
      <activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
                            android:theme="@style/Base.Theme.AppCompat"/>
          <provider android:name="androidx.core.content.FileProvider"
                                      android:authorities="${applicationId}.fileprovider"
                                      android:exported="false"
                                      android:grantUriPermissions="true">
            <meta-data android:name="android.support.FILE_PROVIDER_PATHS"
               android:resource="@xml/file_paths"></meta-data>
          </provider>
    </application>
  
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
    ...
</manifest>

Firebase website add google-service file

Firebase website - enable phone / add random phone number / add code

在此处输入图像描述 在此处输入图像描述

fixed, i was passing myPhonenumber without country code. for example for usa it should be in this format +1 655-555-1209

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM