NativeScript / NativeScript/firebase

Phone authentication hangs on iOS with @nativescript/firebase 5.0.2

Abierto
#284 3 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Lenguaje dominante
TypeScript
Estrellas
62
Forks
53
Merge medio
8 d 4 h
PR fusionados (30 d)
2

Descripción

I have upgraded my app to the latest version of everything, namely NativeScript 8.9.2, @nativescript/firebase 5.0.2, macOS Sequoia 16.6.1, Xcode 16.4, etc. I can log in on Android devices and simulators (with test numbers) successfully, as I had before the upgrade. On iOS, however, the login hangs after entering the verification code from the SMS message. The Firebase UI completes, in that my login screen is displayed, but control is never returned. This is the code I use to initiate the login:

let idp = await firebase().ui().show({ providers: [new PhoneProvider()] });

In addition to the hang, I also receive the two silent notifications shown below.

app-root.js: handleMsg: message: {
    "foreground": true,
    "data": {
        "com.google.firebase.auth": {
            "warning": "This fake notification should be forwarded to Firebase Auth."
        }
    }
}

app-root.js:61 app-root.js: handleMsg: message: {
    "data": {
        "com.google.firebase.auth": "{\"receipt\":\"AEFDNu9LxA12I0A5Vch7JoTI8XiANEA-viqkiPhRykmcra6aVSCmjVZa5il-Yt4JUh3nbgRzhULnxdKSOEpMQUpcjWr72qkpx3p-ssSSemqDD8l33JdZqN-20Rl5RzU83A\",\"secret\":\"i9pLJ5Ol3WBB17Ol\"}"
    },
    "notification": {
        "apple": {}
    },
    "contentAvailable": 1,
    "foreground": true,
    "messageId": "1757287521614594"
}

I found this information in the Firebase docs:

When you call verifyPhoneNumber(_:uiDelegate:completion:), Firebase sends a silent push notification to your app, or issues a reCAPTCHA challenge to the user. After your app receives the notification or the user completes the reCAPTCHA challenge, Firebase sends an SMS message containing an authentication code to the specified phone number and passes a verification ID to your completion function. You will need both the verification code and the verification ID to sign in the user.

I'm guessing that the secret property is the verification ID, but if so, I don't see how I can couple that with the verification code since they are on different threads.

Is anyone successfully using phone authentication with @nativescript/firebase 5.0.2?

I've included my package.json, build.xcconfig and Podfile contents below.

package.json

{
  "name": "festivelo",
  "main": "app/app.js",
  "version": "1.0.0",
  "private": true,
  "dependencies": {
    "@bradmartin/nativescript-urlhandler": "^2.0.1",
    "@master.technology/permissions": "^2.0.1",
    "@nativescript-community/ui-collectionview": "^6.0.4",
    "@nativescript-community/ui-material-bottom-navigation": "^7.2.71",
    "@nativescript/appversion": "^2.0.0",
    "@nativescript/contacts": "^3.0.0",
    "@nativescript/core": "~8.9.7",
    "@nativescript/email": "^2.1.0",
    "@nativescript/firebase-auth": "^5.0.2",
    "@nativescript/firebase-core": "^5.0.2",
    "@nativescript/firebase-database": "^5.0.2",
    "@nativescript/firebase-messaging": "^5.0.2",
    "@nativescript/firebase-ui": "5.0.2",
    "@nativescript/geolocation": "^9.0.0",
    "@nativescript/google-maps": "1.7.2",
    "@nativescript/iqkeyboardmanager": "^2.1.2",
    "@nativescript/pdf": "^2.0.0",
    "@nativescript/theme": "^3.1.0",
    "@triniwiz/nativescript-toasty": "^4.1.3",
    "@wuilmerj24/store-update": "^1.0.7",
    "assert": "^2.1.0",
    "base-64": "^1.0.0",
    "browserify-zlib": "^0.2.0",
    "buffer": "^6.0.3",
    "crypto-browserify": "^3.12.0",
    "https-browserify": "^1.0.0",
    "nativescript": "^8.9.3",
    "nativescript-app-tour": "^4.0.0",
    "nativescript-bitmap-factory": "^1.8.1",
    "nativescript-clipboard": "^2.1.1",
    "nativescript-danem-google-maps-utils": "^1.0.18",
    "nativescript-drop-down": "6.0.2",
    "nativescript-phone": "^3.0.3",
    "nativescript-screenshot": "^0.0.2",
    "nativescript-sqlite": "^2.8.6",
    "nativescript-ui-listview": "^15.2.3",
    "nativescript-ui-sidedrawer": "^15.2.3",
    "os-browserify": "^0.3.0",
    "patch-package": "^8.0.0",
    "path": "^0.12.7",
    "path-browserify": "^1.0.1",
    "querystring-es3": "^0.2.1",
    "stream-browserify": "^3.0.0",
    "stream-http": "^3.2.0",
    "tty-browserify": "^0.0.1",
    "url": "^0.11.3"
  },
  "devDependencies": {
    "@nativescript/android": "8.9.1",
    "@nativescript/ios": "8.9.2",
    "@nativescript/webpack": "^5.0.18",
    "util": "^0.12.5"
  },
  "scripts": {
    "postinstall": "patch-package"
  }
}

build.xcconfig

// You can add custom settings here
// for example you can uncomment the following line to force distribution code signing
// CODE_SIGN_IDENTITY = iPhone Distribution 
// To build for device with XCode you need to specify your development team.
DEVELOPMENT_TEAM = xxxxxxxxxx
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
TARGETED_DEVICE_FAMILY = 1;
IPHONEOS_DEPLOYMENT_TARGET = 16.0;

CODE_SIGN_ENTITLEMENTS = festivelo/festivelo.entitlements

// See https://stackoverflow.com/questions/66105038/referenceerror-metadata-for-googlemaps-gmsgeometrydistance-found-but-symbol-n
STRIPFLAGS=$(inherited) -s ${PROJECT_DIR}/../../App_Resources/iOS/exportedSymbols.txt
EXPORTED_SYMBOLS_FILE = ${PROJECT_DIR}/../../App_Resources/iOS/exportedSymbols.txt

// See https://github.com/msywensky/nativescript-phone/issues/51
OTHER_LDFLAGS = $(inherited) -framework MessageUI

// See https://github.com/NativeScript/NativeScript/issues/8860
EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_simulator__NATIVE_ARCH_64_BIT_x86_64=arm64 arm64e armv7 armv7s armv6 armv8
EXCLUDED_ARCHS=$(inherited) $(EXCLUDED_ARCHS__EFFECTIVE_PLATFORM_SUFFIX_$(EFFECTIVE_PLATFORM_SUFFIX)__NATIVE_ARCH_64_BIT_$(NATIVE_ARCH_64_BIT))

Podfile


platform :ios, '15.0'

post_install do |installer|
  installer.pods_project.targets.each do |target|
    puts "Pods target name: " + target.name

    # bypass xcode 16 error
    # see https://stackoverflow.com/questions/78608693/boringssl-grpc-unsupported-option-g-for-target-arm64-apple-ios15-0
    if target.name == 'BoringSSL-GRPC'
      target.source_build_phase.files.each do |file|
        if file.settings && file.settings['COMPILER_FLAGS']
          flags = file.settings['COMPILER_FLAGS'].split
          flags.reject! { |flag| flag == '-GCC_WARN_INHIBIT_ALL_WARNINGS' }
          file.settings['COMPILER_FLAGS'] = flags.join(' ')
        end
      end
    end

    target.build_configurations.each do |config|

      # suppress warnings
      # see https://discord.com/channels/603595811204366337/828973466534936637/1192028592255799317
      config.build_settings['GCC_WARN_INHIBIT_ALL_WARNINGS'] = 'YES'

      # see https://github.com/NativeScript/NativeScript/issues/10034
      if config.build_settings['WRAPPER_EXTENSION'] == 'bundle'
        config.build_settings['DEVELOPMENT_TEAM'] = 'C424ZH53NJ'
      end

      # see https://github.com/NativeScript/NativeScript/issues/8860
      # see https://www.jessesquires.com/blog/2020/07/20/xcode-12-drops-support-for-ios-8-fix-for-cocoapods/
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '16.0'

      # see https://stackoverflow.com/questions/63607158/xcode-building-for-ios-simulator-but-linking-in-an-object-file-built-for-ios-f/63714000#63714000
      config.build_settings["ONLY_ACTIVE_ARCH"] = "YES"

      # see https://github.com/CocoaPods/CocoaPods/issues/12012
      xcconfig_path = config.base_configuration_reference.real_path
      xcconfig = File.read(xcconfig_path)
      xcconfig_mod = xcconfig.gsub(/DT_TOOLCHAIN_DIR/, "TOOLCHAIN_DIR")
      File.open(xcconfig_path, "w") { |file| file << xcconfig_mod }

      if target.name == 'Realm'
        create_symlink_phase = target.shell_script_build_phases.find { |x| x.name == 'Create Symlinks to Header Folders' }
        create_symlink_phase.always_out_of_date = "1"
        puts "target.name = Realm found"
      end
  
      # See https://stackoverflow.com/questions/61980618/getting-a-new-build-error-for-ios-nativescript
      if ['Toast-Swift'].include? target.name
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '5.3'
        end
      end
  
      if ['FirebaseCoreInternal'].include? target.name
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '5.3'
        end
      end
  
      if ['FirebaseStorage'].include? target.name
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '5.3'
        end
      end

      # Hack to see if this works with Firebase 5.0.3
      if ['FirebaseAuth'].include? target.name
        target.build_configurations.each do |config|
          config.build_settings['SWIFT_VERSION'] = '5.3'
        end
      end
  
      if target.name.start_with? "GoogleDataTransport"
        target.build_configurations.each do |config|
          config.build_settings['CLANG_WARN_STRICT_PROTOTYPES'] = 'NO' 
        end
      end

    end
  end
end

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Línea de trabajo

Comienza con el manejo de mensajes de app-root.js y el punto de entrada de @nativescript/firebase-ui para phone-auth; revisa package.json, build.xcconfig y Podfile junto con el flujo de phone-auth de Firebase iOS referenciado. Reproduce el problema en iOS con las versiones proporcionadas y verifica que completar la verificación por SMS regrese desde show() y deje al usuario con la sesión iniciada sin el bloqueo reportado.

Escrito por el modelo de indexación a partir del texto del issue.

Evaluación

Stack tecnológico
firebase, ios, typescript
Área
authentication, mobile
Tipo de issue
Error
Dificultad
4/5
Tiempo estimado
3-5 días
Estado de actividad
Estancado
Claridad
Bastante claro
Aptitud para principiantes
35/100

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.