问题
I am using phone verification in my flutter app. My goal is to have the following flow: 1. user enters phone number 2. user is sent verification code 3. user enters code and is signed in. On android, that is the flow I get. On ios, however, it goes 1. user enters phone number 2. reCAPCHA page opens to make sure I'm not a robot 3. user is sent verification code 4. user enters code and is signed in (this happens on ios emulator). I want to get rid of the reCAPCHA page. Some people recommended that I turn on "remote-notifications", so I tried to do this in Xcode by adding it as a "capability" to my runner, and now my Info.plist includes
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
Which seems right. However, this did not fix the issue, and I am still faced with the capcha.
Version of firebase auth:
firebase_auth: 0.15.4
Output of flutter doctor
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-US)
• Flutter version 1.12.13+hotfix.5 at /Users/gollyzoom/development/flutter
• Framework revision 27321ebbad (3 months ago), 2019-12-10 18:15:01 -0800
• Engine revision 2994f7e1e6
• Dart version 2.7.0
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
• Android SDK at /Users/gollyzoom/Library/Android/sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 28.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS (Xcode 11.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 11.3, Build version 11C29
• CocoaPods version 1.8.4
[✓] Android Studio (version 3.5)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 39.0.3
• Dart plugin version 191.8423
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b49-5587405)
[✓] IntelliJ IDEA Ultimate Edition (version 2019.1.4)
• IntelliJ at /Applications/IntelliJ IDEA.app
• Flutter plugin version 38.1.3
• Dart plugin version 191.8593
[✓] Connected device (2 available)
• Android SDK built for x86 • emulator-5554 • android-x86 • Android 9 (API 28) (emulator)
• iPhone 11 Pro Max • B3536B50-C435-4442-9CF4-69D470B979CA • ios •
com.apple.CoreSimulator.SimRuntime.iOS-13-3 (simulator)
• No issues found!
I would really appreciate if anyone had some advice on this!
回答1:
This happens to be in Android as well. I get the reCaptcha opened before I can enter my verification code.
回答2:
Here is the solution for my problem in Android https://github.com/FirebaseExtended/flutterfire/issues/4189#issuecomment-741711350
Steps made by @Omrankabalan
Go to https://console.cloud.google.com/
If you have a Firebase project you can open in from here
Then select All tab and choose your existing project
Then go to API & Services => Library Search for 'Android Device Verification'
Enable it
In Firebase make sure to add SHA-256 In Project Settings
Test it on a real device
回答3:
You will need to setup Silent Push Notification for iOS.
Referencing this document: https://firebase.google.com/docs/auth/ios/phone-auth
You will see there are 2 strategies when authorizing Phone Numbers: reCaptcha (to verify you are not a robot) and Silent Push Notifications.
There are additional configurations but in summary:
- In Xcode, enable push notifications for your project.
- Upload your APNs authentication key to Firebase.
来源:https://stackoverflow.com/questions/60766258/ios-requires-recapcha-every-time-w-firestore-auth-flutter