3

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!

gollyzoom
  • 519
  • 1
  • 6
  • 21

4 Answers4

6

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

enter image description here

Then select All tab and choose your existing project

enter image description here

Then go to API & Services => Library Search for 'Android Device Verification'

enter image description here

Enable it

enter image description here

In Firebase make sure to add SHA-256 In Project Settings

enter image description here enter image description here

Test it on a real device

Ahmed Fathy
  • 166
  • 1
  • 6
1

This happens to be in Android as well. I get the reCaptcha opened before I can enter my verification code.

Ahmed Fathy
  • 166
  • 1
  • 6
  • Same here and I know why is it. It is because of addition of `implementation 'androidx.browser:browser:1.2.0'` in app level build gradle dependencies. BUT for me app crashes on removing it. I don't know why? – Faizan Kamal Nov 23 '20 at 16:58
  • It looks like something they have implemented in their last version. I dont know if someone can revert back to older version and if that will work. Thanks for your reply. I created a ticket with flutter support anyway. – Ahmed Fathy Nov 24 '20 at 09:49
  • hey could you give updates to what happened, what did they say ? is there a way to bypass this? – basudev nayak Dec 06 '20 at 04:17
  • I am still talking to the flutter support and created a MCVE for them and will keep that ticket updated. – Ahmed Fathy Dec 07 '20 at 12:07
  • @FaizanKamal I'm geeting error on removing =>implementation 'androidx.browser:browser:1.2.0' I've already added SHA-1 and SHA-256. Still it's opening recaptcha view in browser. Did you find any solution? Thanks – Jay Mungara Feb 26 '21 at 08:25
  • @AhmedFathy Did you find anything useful? – Jay Mungara Feb 26 '21 at 08:25
0

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:

  1. In Xcode, enable push notifications for your project.
  2. Upload your APNs authentication key to Firebase.
Anraiki
  • 786
  • 1
  • 10
  • 26
  • Thanks but we are more concerned with Android than IOS. I have seen the one about IOS but that behavior with Android is so stange. – Ahmed Fathy Nov 29 '20 at 06:40
0

I had this same issue and was able to solve it by modifying the entitlements. I have added 'Push Notifications' and 'Background Modes'. The background mode is set with "Background fetch" and "Remote notifications" options.

my "Info.plist" looks as follows after the 'Background Modes' change:

<key>UIBackgroundModes</key>
<array>
    <string>fetch</string>
    <string>remote-notification</string>
</array>

Needless to say that you need to configure the push notifications from your developer account and to configure it from the firebase console for you iOS app.

push notifications background mode background mode options

rashidotm
  • 392
  • 2
  • 12