invertase / react-native-firebase

🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
https://rnfirebase.io
Other
11.71k stars 2.22k forks source link

🔥[🐛] Auth: Phone SMS Auto verification doesn't work on android #4621

Closed hannojg closed 3 years ago

hannojg commented 3 years ago

Issue

I am implementing the firebase auth module to enable phone verification in my app. I set up everything according to the docs and everything works (I receive the SMS). But the "auto sign-in" doesn't work. The android logs say this:

D/Auth: signInWithPhoneNumber
W/FirebaseAuth: [SmsRetrieverHelper] Timed out waiting for SMS.
I/PhoneAuthProvider: Sms auto retrieval timed-out.

I am testing this on a real device with the SIM-Card having the same number as the mobile number used for verification.

The code I used to do the auto verification roughly looks like this:

  //Android: listening to auto verification event
  useEffect(() => {
    auth().onAuthStateChanged((user) => {
      if (user) {
        console.debug("[AUTH] user verification completed automatically!"); //⬅️🐛 This never happens
      }
    });
  }, []);

Project Files

Javascript

Click To Expand

Don't know what to put here? #### `package.json`: ```json { "name": "XXX", "version": "0.0.1", "private": true, "scripts": { "graphql-codegen": "graphql-codegen", "android": "react-native run-android", "ios": "react-native run-ios", "ios-native": "react-native run-ios --device", "pods": "cd ios && pod install && cd ..", "clean": "scripts/clean.sh", "start": "react-native start", "test": "cross-env TZ=UTC jest --forceExit", "e2e": "npm run e2e-prepare.debug && npm run e2e-test.debug", "e2e-prepare.debug": "npx detox build --configuration android.emu.debug", "e2e-test.debug": "npx detox test --configuration android.emu.debug", "e2e-prepare": "npx detox build --configuration android.emu.release", "e2e-test": "npx detox test --configuration android.emu.release", "e2e-setup-cleanup": "ts-node e2e/setupCleaningHelper.js", "lint": "eslint --ext .js,.ts,.jsx,.tsx src", "typescript": "tsc --skipLibCheck", "start-android-emu": "$ANDROID_HOME/emulator/emulator -verbose -dns-server 8.8.8.8 @Pixel_API_28_AOSP &", "postinstall": "cp ios/.netrc ~/.netrc && npx patch-package" }, "husky": { "hooks": { "pre-push": "npm run typescript && npm run lint && npm run test", "pre-merge-commit": "npx npm-merge-driver install" } }, "dependencies": { "@apollo/client": "^3.2.5", "@apollo/link-context": "^2.0.0-beta.3", "@apollo/link-ws": "^2.0.0-beta.3", "@dudigital/react-native-zoomable-view": "^1.0.15", "@gorhom/bottom-sheet": "^1.4.1", "@react-native-async-storage/async-storage": "^1.13.2", "@react-native-community/audio-toolkit": "^2.0.3", "@react-native-community/cameraroll": "^4.0.1", "@react-native-community/netinfo": "^5.9.6", "@react-native-community/push-notification-ios": "^1.7.3", "@react-native-community/viewpager": "^4.0.1", "@react-native-firebase/app": "^9.0.0", "@react-native-firebase/auth": "^10.0.0", "@react-native-firebase/remote-config": "^10.0.1", "@react-native-mapbox-gl/maps": "^8.1.0-rc.6", "@reduxjs/toolkit": "^1.4.0", "@sentry/core": "^5.27.4", "@sentry/react-native": "^2.0.0", "apollo-upload-client": "^14.1.3", "awesome-debounce-promise": "^2.1.0", "babel-plugin-transform-remove-console": "^6.9.4", "buffer": "^5.6.0", "dayjs": "^1.8.28", "eventemitter3": "^4.0.7", "events": "^3.2.0", "fast-copy": "^2.1.0", "fast-deep-equal": "^3.1.3", "getstream": "^6.2.2", "google-libphonenumber": "^3.2.15", "graphql": "^15.4.0", "graphql-anywhere": "^4.2.7", "hash-sum": "^2.0.0", "hermes-engine": "^0.5.2-rc1", "i": "^0.3.6", "lodash.clonedeep": "^4.5.0", "lodash.debounce": "^4.0.8", "lodash.memoize": "^4.1.2", "lodash.zipwith": "^4.2.0", "lottie-react-native": "^3.5.0", "memoize-one": "^5.1.1", "mime-types": "^2.1.27", "nanoid": "^3.1.10", "promise.allsettled": "^1.0.2", "re-reselect": "^4.0.0", "react": "16.13.1", "react-async-hook": "^3.6.1", "react-native": "0.63.3", "react-native-animatable": "^1.3.3", "react-native-animated-pagination-dot": "^0.1.8", "react-native-autogrow-textinput": "^5.4.0", "react-native-blurhash": "^1.0.27", "react-native-camera": "^3.32.0", "react-native-circular-progress": "^1.3.6", "react-native-color-matrix-image-filters": "^5.2.5", "react-native-config": "^1.4.1", "react-native-contacts": "^5.2.3", "react-native-date-picker": "3.2.4", "react-native-device-info": "^5.6.1", "react-native-elements": "^2.2.1", "react-native-emoji-board": "^1.2.1", "react-native-fast-image": "^8.3.2", "react-native-fetch-polyfill": "^1.1.3", "react-native-flipper": "^0.61.0", "react-native-fs": "^2.16.6", "react-native-gallery-swiper": "^1.26.4", "react-native-geolocation-service": "^5.0.0", "react-native-gesture-handler": "^1.8.0", "react-native-gifted-chat": "^0.16.3", "react-native-image-crop-picker": "^0.35.0", "react-native-image-picker": "^2.3.3", "react-native-image-resizer": "^1.3.0", "react-native-inappbrowser-reborn": "^3.5.1", "react-native-iphone-x-helper": "^1.2.1", "react-native-job-queue": "^0.2.5", "react-native-keyboard-aware-scroll-view": "^0.9.2", "react-native-keyboard-spacer": "^0.4.1", "react-native-linear-gradient": "^2.5.6", "react-native-loading-spinner-overlay": "^1.1.0", "react-native-matomo": "github:vinoth-am/react-native-matomo#ios-deprecated-UIWebView-WKWebView", "react-native-matrix-sdk": "1.0.0-alpha70", "react-native-mime-types": "^2.3.0", "react-native-navigation": "^7.2.0", "react-native-navigation-hooks": "^6.2.0", "react-native-notifications": "^3.4.0", "react-native-open-map": "^3.0.2", "react-native-paper": "^4.0.1", "react-native-parsed-text": "^0.0.22", "react-native-path": "0.0.5", "react-native-permissions": "^2.2.0", "react-native-reanimated": "^2.0.0-alpha.9.2", "react-native-responsive-screen": "^1.4.1", "react-native-safe-area-context": "^3.1.9", "react-native-safe-area-view": "^2.0.0", "react-native-share": "^3.7.0", "react-native-splash-screen": "^3.2.0", "react-native-static-safe-area-insets": "^2.1.1", "react-native-svg": "^12.1.0", "react-native-swiper": "^1.6.0-rc.3", "react-native-tab-view": "^2.15.1", "react-native-toasty": "1.0.2", "react-native-uuid": "^1.4.9", "react-native-vector-icons": "^7.1.0", "react-native-video": "5.1.0-alpha8", "react-redux": "^7.2.1", "recyclerlistview": "^3.0.0", "redux": "^4.0.5", "redux-flipper": "^1.4.0", "rn-actionsheet-module": "^1.0.3", "rn-fetch-blob": "^0.12.0", "safe-buffer": "^5.2.1", "set-tz": "^0.2.0", "subscriptions-transport-ws": "^0.9.16", "throttle-debounce": "^2.2.1", "typescript-collections": "^1.3.3", "use-constant": "^1.0.0", "utility-types": "^3.10.0", "uuid": "^8.3.0" }, "devDependencies": { "@babel/core": "^7.11.5", "@babel/runtime": "^7.11.2", "@graphql-codegen/cli": "^1.19.1", "@graphql-codegen/typescript": "^1.17.11", "@jedmao/redux-mock-store": "^3.0.5", "@react-native-community/eslint-config": "^1.1.0", "@react-native-community/eslint-plugin": "^1.1.0", "@storybook/addon-actions": "^5.3.19", "@storybook/addon-links": "^5.3.19", "@storybook/addon-ondevice-actions": "^5.3.19", "@storybook/addons": "^5.3.19", "@storybook/react-native": "^5.3.19", "@testing-library/jest-native": "^3.4.3", "@testing-library/react-native": "7.0.2", "@types/apollo-upload-client": "^8.1.3", "@types/jest": "^26.0.14", "@types/mime-types": "^2.1.0", "@types/node": "^14.6.2", "@types/react": "16.9.49", "@types/react-native": "^0.63.13", "@types/react-native-fs": "^2.13.0", "@types/react-native-push-notification": "^5.0.5", "@types/react-native-video": "^5.0.1", "@types/react-redux": "^7.1.9", "@types/react-test-renderer": "^16.9.3", "@types/redux-mock-store": "^1.0.2", "@types/throttle-debounce": "^2.1.0", "@types/uuid": "^8.3.0", "@typescript-eslint/eslint-plugin": "^2.29.0", "@typescript-eslint/parser": "^2.29.0", "babel-jest": "^26.3.0", "babel-plugin-module-resolver": "^4.0.0", "cross-env": "^7.0.2", "cross-fetch": "^3.0.6", "detox": "^17.10.3", "eslint": "^6.8.0", "eslint-config-prettier": "^6.11.0", "eslint-plugin-graphql": "^4.0.0", "eslint-plugin-prettier": "^3.1.4", "esm": "^3.2.25", "fetch-mock": "^9.10.1", "geojson": "^0.5.0", "husky": "^4.2.3", "invariant": "^2.2.4", "jest": "^26.5.3", "jest-circus": "^26.5.3", "jest-diff": "^26.5.2", "metro-config": "^0.58.0", "metro-react-native-babel-preset": "^0.62.0", "mixin-object": "^3.0.0", "mockdate": "^3.0.2", "prop-types": "^15.7.2", "react-app-polyfill": "^1.0.6", "react-native-console-time-polyfill": "^1.2.1", "react-native-svg-transformer": "^0.14.3", "react-test-renderer": "16.13.1", "redux-mock-store": "^1.5.4", "shortid": "^2.2.15", "ts-node": "^8.10.2", "typescript": "^3.9.2" }, "jest": { "preset": "react-native" } } ``` #### `firebase.json` for react-native-firebase v6: ```json # N/A ```

iOS

Click To Expand

#### `ios/Podfile`: - [ ] I'm not using Pods - [x] I'm using Pods and my Podfile looks like: ```ruby # N/A ``` #### `AppDelegate.m`: ```objc // N/A ```


Android

Click To Expand

#### Have you converted to AndroidX? - [x] my application is an AndroidX application? - [x] I am using `android/gradle.properties` `jetifier=true` for Android compatibility? - [ ] I am using the NPM package `jetifier` for react-native compatibility? #### `android/build.gradle`: ```groovy // Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext { RNNKotlinVersion = "1.3.61" buildToolsVersion = "29.0.2" minSdkVersion = 21 compileSdkVersion = 29 targetSdkVersion = 29 playServicesVersion = "17.0.0" // or find latest version androidMapsUtilsVersion = "2.0.3" } repositories { google() jcenter() maven { url "https://plugins.gradle.org/m2/" } } dependencies { classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.61" classpath('com.android.tools.build:gradle:4.0.0') classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$RNNKotlinVersion" classpath "com.google.gms:google-services:4.3.4" classpath "com.mikepenz.aboutlibraries.plugin:aboutlibraries-plugin:8.4.2" } } allprojects { repositories { mavenLocal() maven { // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm url("$rootDir/../node_modules/react-native/android") } maven { // Android JSC is installed from npm url("$rootDir/../node_modules/jsc-android/dist") } maven { url "https://github.com/vector-im/jitsi_libre_maven/raw/master/releases" } // Detox maven { // All of Detox" artifacts are provided via the npm module url "$rootDir/../node_modules/detox/Detox-android" } google() jcenter() maven { url "https://www.jitpack.io" } } } ``` #### `android/app/build.gradle`: ```groovy apply plugin: "com.android.application" apply plugin: 'com.google.gms.google-services' apply plugin: 'com.mikepenz.aboutlibraries.plugin' apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle" apply from: "../../node_modules/react-native-vector-icons/fonts.gradle" project.ext.react = [ enableHermes: true, // clean and rebuild if changing ] apply from: "../../node_modules/react-native/react.gradle" apply from: "../../node_modules/@sentry/react-native/sentry.gradle" /** * Set this to true to create two separate APKs instead of one: * - An APK that only works on ARM devices * - An APK that only works on x86 devices * The advantage is the size of the APK is reduced by about 4MB. * Upload all the APKs to the Play Store and people will download * the correct one based on the CPU architecture of their device. */ def enableSeparateBuildPerCPUArchitecture = false /** * Run Proguard to shrink the Java bytecode in release builds. */ def enableProguardInReleaseBuilds = false /** * The preferred build flavor of JavaScriptCore. * * For example, to use the international variant, you can use: * `def jscFlavor = 'org.webkit:android-jsc-intl:+'` * * The international variant includes ICU i18n library and necessary data * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that * give correct results when using with locales other than en-US. Note that * this variant is about 6MiB larger per architecture than default. */ def jscFlavor = 'org.webkit:android-jsc:+' /** * Whether to enable the Hermes VM. * * This should be set on project.ext.react and mirrored here. If it is not set * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode * and the benefits of using Hermes will therefore be sharply reduced. */ def enableHermes = project.ext.react.get("enableHermes", false); android { compileSdkVersion rootProject.ext.compileSdkVersion dexOptions { javaMaxHeapSize "3g" } compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } defaultConfig { applicationId "xxxxx" minSdkVersion rootProject.ext.minSdkVersion targetSdkVersion rootProject.ext.targetSdkVersion versionCode 415 versionName "1.0.0-${System.env.VERSION_SHA}" multiDexEnabled true testBuildType System.getProperty("testBuildType", "debug") // This will later be used to control the test apk build type testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" //image cropper lib vectorDrawables.useSupportLibrary = true //camera missingDimensionStrategy "react-native-camera", "general" } splits { abi { reset() enable enableSeparateBuildPerCPUArchitecture universalApk false // If true, also generate a universal APK include "armeabi-v7a", "x86", "arm64-v8a", "x86_64" } } signingConfigs { xxxx } buildTypes { debug { signingConfig signingConfigs.debug } release { signingConfig signingConfigs.release minifyEnabled enableProguardInReleaseBuilds proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro" } } testOptions { unitTests.all { useJUnitPlatform() } } packagingOptions { pickFirst "lib/armeabi-v7a/libc++_shared.so" pickFirst "lib/arm64-v8a/libc++_shared.so" pickFirst "lib/x86/libc++_shared.so" pickFirst "lib/x86_64/libc++_shared.so" } // applicationVariants are e.g. debug, release applicationVariants.all { variant -> variant.outputs.each { output -> // For each separate APK per architecture, set a unique version code as described here: // https://developer.android.com/studio/build/configure-apk-splits.html def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4] def abi = output.getFilter(com.android.build.OutputFile.ABI) if (abi != null) { // null for the universal-debug, universal-release variants output.versionCodeOverride = versionCodes.get(abi) * 1048576 + defaultConfig.versionCode } } } } dependencies { implementation project(':react-native-contacts') implementation 'com.android.support:multidex:1.0.3' implementation project(':react-native-matrix-sdk') implementation project(':react-native-config') implementation project(':react-native-navigation') implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation("com.facebook.react:react-native:+") { // From node_modules exclude group: 'com.facebook.soloader' } implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0" // Flipper debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") { exclude group: 'com.facebook.fbjni' exclude group: 'com.facebook.yoga' exclude group: 'com.facebook.flipper', module: 'fbjni' exclude group: 'com.facebook.litho', module: 'litho-annotations' exclude group: 'com.squareup.okhttp3' } debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") { exclude group: 'com.facebook.flipper' exclude group:'com.squareup.okhttp3', module:'okhttp' } debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") { exclude group: 'com.facebook.flipper' } implementation 'com.facebook.soloader:soloader:0.8.2+' releaseImplementation "com.facebook.flipper:flipper-noop:${FLIPPER_VERSION}" //releaseImplementation 'com.github.theGlenn:flipper-android-no-op:0.3.0' implementation project(':react-native-notifications') implementation platform('com.google.firebase:firebase-bom:26.1.0') implementation 'com.google.firebase:firebase-messaging' implementation 'com.google.code.gson:gson:2.8.6' if (enableHermes) { def hermesPath = "../../node_modules/hermes-engine/android/"; debugImplementation files(hermesPath + "hermes-debug.aar") releaseImplementation files(hermesPath + "hermes-release.aar") } else { implementation jscFlavor } // Analytics implementation project(':react-native-matomo') // Testing testImplementation "org.junit.jupiter:junit-jupiter-api:5.5.2" testRuntimeOnly "org.junit.jupiter:junit-jupiter-engine:5.5.2" testImplementation "org.junit.jupiter:junit-jupiter-params:5.5.2" androidTestImplementation('com.wix:detox:+') //Licenses: implementation "com.mikepenz:aboutlibraries-core:8.4.2" implementation "com.mikepenz:aboutlibraries:8.4.2" implementation "androidx.appcompat:appcompat:1.2.0" implementation "androidx.cardview:cardview:1.0.0" implementation "androidx.recyclerview:recyclerview:1.1.0" implementation "com.google.android.material:material:1.2.1" } // Run this once to be able to run the application with BUCK // puts all compile dependencies into folder libs for BUCK to use task copyDownloadableDepsToLibs(type: Copy) { from configurations.compile into 'libs' } apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project) ``` #### `android/settings.gradle`: ```groovy rootProject.name = 'XXX' include ':react-native-video' project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer') include ':react-native-splash-screen' project(':react-native-splash-screen').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-splash-screen/android') include ':react-native-config' project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android') include ':@react-native-community_viewpager' project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android') include ':@react-native-community_viewpager' project(':@react-native-community_viewpager').projectDir = new File(rootProject.projectDir, '../node_modules/@react-native-community/viewpager/android') include ':react-native-vector-icons' project(':react-native-vector-icons').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-vector-icons/android') include ':react-native-contacts' project(':react-native-contacts').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-contacts/android') include ':react-native-notifications' project(':react-native-notifications').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-notifications/lib/android/app') include ':react-native-matrix-sdk' project(':react-native-matrix-sdk').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-matrix-sdk/android') include ':react-native-config' project(':react-native-config').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-config/android') include ':react-native-navigation' project(':react-native-navigation').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-navigation/lib/android/app') apply from: file("../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesSettingsGradle(settings) include ':app' include ':react-native-matomo' project(':react-native-matomo').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-matomo/android/') ``` #### `MainApplication.java`: ```java public class MainApplication extends NavigationApplication implements INotificationsApplication { private final ReactNativeHost mReactNativeHost = new NavigationReactNativeHost(this) { @Override public boolean getUseDeveloperSupport() { return BuildConfig.DEBUG; } @Override protected List getPackages() { @SuppressWarnings("UnnecessaryLocalVariable") List packages = new PackageList(this).getPackages(); // Packages that cannot be autolinked yet can be added manually here, for example: // packages.add(new RNNotificationsPackage(MainApplication.this)); packages.add(new AboutLibrariesPackage()); new MatomoPackage(); return packages; } @Override protected String getJSMainModuleName() { return "index"; } @Override protected JSIModulePackage getJSIModulePackage() { return new ReanimatedJSIModulePackage(); } }; @Override public ReactNativeHost getReactNativeHost() { return mReactNativeHost; } @Override public void onCreate() { super.onCreate(); initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); } /** * Loads Flipper in React Native templates. Call this in the onCreate method with something like * initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); * * @param context * @param reactInstanceManager */ private static void initializeFlipper( Context context, ReactInstanceManager reactInstanceManager) { if (BuildConfig.DEBUG) { try { /* We use reflection here to pick up the class that initializes Flipper, since Flipper library is not available in release mode */ Class aClass = Class.forName("XXX.ReactNativeFlipper"); aClass .getMethod("initializeFlipper", Context.class, ReactInstanceManager.class) .invoke(null, context, reactInstanceManager); } catch (ClassNotFoundException e) { e.printStackTrace(); } catch (NoSuchMethodException e) { e.printStackTrace(); } catch (IllegalAccessException e) { e.printStackTrace(); } catch (InvocationTargetException e) { e.printStackTrace(); } } } @Override public IPushNotification getPushNotification(Context context, Bundle bundle, AppLifecycleFacade facade, AppLaunchHelper defaultAppLaunchHelper) { return new PushNotification(context, bundle, facade, defaultAppLaunchHelper, new JsIOHelper()); } } ``` #### `AndroidManifest.xml`: ```xml ```


Environment

Click To Expand

**`react-native info` output:** ``` System: OS: macOS 11.0.1 CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz Memory: 20.21 MB / 16.00 GB Shell: 5.8 - /bin/zsh Binaries: Node: 12.19.0 - /usr/local/bin/node Yarn: 1.22.4 - /usr/local/bin/yarn npm: 6.14.8 - /usr/local/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.10.0 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.2, DriverKit 20.0, macOS 11.0, tvOS 14.2, watchOS 7.1 Android SDK: Not Found IDEs: Android Studio: 4.0 AI-193.6911.18.40.6514223 Xcode: 12.2/12B45b - /usr/bin/xcodebuild Languages: Java: 14.0.1 - /usr/bin/javac Python: 2.7.16 - /usr/bin/python npmPackages: @react-native-community/cli: Not Found react: 16.13.1 => 16.13.1 react-native: 0.63.3 => 0.63.3 react-native-macos: Not Found npmGlobalPackages: *react-native*: Not Found ``` - **Platform that you're experiencing the issue on**: - [ ] iOS - [x] Android - [ ] **iOS** but have not tested behavior on Android - [ ] **Android** but have not tested behavior on iOS - [ ] Both - **`react-native-firebase` version you're using that has this issue:** - `e.g. 9.0.0` - **`Firebase` module(s) you're using that has the issue:** - `Auth: ^10.0.0` - **Are you using `TypeScript`?** - `Y` & `3.9.7`


mikehardy commented 3 years ago

Hello!

Why you would take the time to include everything except your package.json is difficult to understand? Oversight perhaps

However, assuming you are generally up to date (v10.0.0 at least, but I just published v10.1.0) and with firebase-android-sdk BoM overridden to 26.1.0 (most current) it should be working.

You must test on a real device obviously - looks like you have that

If that's not working then this will be an upstream issue in https://github.com/firebase/firebase-android-sdk/ you should check their issues lists to see if anyone else is reporting, and if not, make a quickstart from their templates to file for attention there - if FirebaseAuth (the native SDK implementation) times out, there's nothing react-native-firebase can do https://github.com/firebase/quickstart-android/tree/master/auth

hannojg commented 3 years ago

Yes, sorry forgot the package.json, I've just added it. I've seen that firebase app v10 is available and I am running on 9, will try to update this and give response here again + checking upstream for issues.

mikehardy commented 3 years ago

even v10.1.0 (just published) you'll want to override the native SDK to 26.1.0 (I had not bumped that yet for the v10.1.0 release - there was already a lot in the release and I'll bump it with v10.2.0 here) here is how to override the firebase-android-sdk https://rnfirebase.io/#android

hannojg commented 3 years ago

Upgraded everything to 10.1.0 and manually set the bom to 26.1.0 -> still the same issue. Will investigate whether it is an upstream issue.

efstathiosntonas commented 3 years ago

Hey @hannojg did you found a solution?

hannojg commented 3 years ago

Not yet, didn't have the time to look into it. It once worked when I put this into the AndroidManifest:

        <receiver
                android:name=".GcmBroadcastReceiver"
                android:permission="com.google.android.c2dm.permission.SEND">
            <intent-filter>
                <action android:name="com.google.android.c2dm.intent.RECEIVE"/>
                <category android:name="com.your.package"/>
            </intent-filter>
        </receiver>
        <service android:name=".GcmIntentService"/>

I just found it through googling around. I don't know what it does, didn't find any documentation for it, and it sometimes caused crashes in the production app, so I removed it.

//Edit: Maybe it just caused a crash because of the service part, which I haven't created anywhere in my code, maybe the receiver is enough? 🤷

kperreau commented 3 years ago

I'm on last version rnfirebase 10.2.0, firebase-android-sdk 26.1.0 and it's still an issue. Timeout without Auto-retrieval.

Logs:

Auth: verifyPhoneNumber:+336********
Auth: verifyPhoneNumber:verification:onCodeSent
Auth: verifyPhoneNumber:verification:onCodeAutoRetrievalTimeOut
mikehardy commented 3 years ago

@hannojg have you ever used Android Studio to just open your .apk file? It should contain those things in the merged (from all included library sources') AndroidManifest.xml, mine contains a similar chunk though it is not in my AndroidManifest.xml


        <receiver
            android:name="io.invertase.firebase.messaging.ReactNativeFirebaseMessagingReceiver"
            android:permission="com.google.android.c2dm.permission.SEND"
            android:exported="true">

            <intent-filter>

                <action
                    android:name="com.google.android.c2dm.intent.RECEIVE" />
            </intent-filter>
        </receiver>
efstathiosntonas commented 3 years ago

@mikehardy @hannojg i think you've might want to see this: https://github.com/firebase/firebase-android-sdk/issues/2318#issuecomment-778086782

[edited by @mikehardy to add: it appears that having an unlocked bootloader may be the/a root cause of SMS autoverify failure here - if you experience this perhaps test devices with locked and unlocked bootloader and report upstream. Watch logcat for possibly interesting messages]

mikehardy commented 3 years ago

Just a note to say that v11.2.0 with firebase-android-sdk 26.8.0 that OTP / SMS Auto Verification can work - it is working from one group I've communicated with for one of their environments, however it was not working immediately for another environment (using same code) which simply points to how fussy it is to set up correctly

webtaculars commented 3 years ago

@mikehardy I have tried with v11.2.0 with firebase-android-sdk 26.8.0. Still I am unable to make auto verify work. I understand that for some groups it might be working but many have failed too. Probably as you mentioned, it is kind of fussy to set up correctly.

mikehardy commented 3 years ago

@webtaculars there are debug logging flags you may enable for firebase, documented in firebase-android-sdk documents upstream. When you turn those on and watch adb logcat, what do you see? Also, we are on v12+ now, only troubleshoot on current versions is a general rule so no one chases ghosts

kevin-mcs commented 2 years ago

@mikehardy - In my case I able to make it work on android device but in iOS device it not working.

mikehardy commented 2 years ago

This is an issue with a last update more than a year ago :thinking: That said, there is no expectation that auto-verification will work on iOS. iOS does not have a facility from this, that I know of, and I don't believe the documents indicate it is a feature. Users will have to type the code on iOS.

item 3 and 4 here, the user enters it manually https://firebase.google.com/docs/auth/ios/phone-auth#sign-in-the-user-with-the-verification-code