Warum funktioniert signInWithPhoneNumber von @capacitor-firebase/authentication nicht mit der Ionic-App für iOS?IOS

Programmierung für iOS
Guest
 Warum funktioniert signInWithPhoneNumber von @capacitor-firebase/authentication nicht mit der Ionic-App für iOS?

Post by Guest »

Ich entwickle eine ionische/Winkelanwendung mit der @capacitor-fireBase/Authentifizierungsbibliothek für die Benutzerauthentifizierung über Telefonnummer. in meinem Dienst: < /p>

Code: Select all

public async signInWithPhoneNumber(options: SignInWithPhoneNumberOptions,
loading: HTMLIonLoadingElement
): Promise {
try {
console.log("Attempting to sign in with phone number:", options.phoneNumber);

const user = await FirebaseAuthentication.signInWithPhoneNumber(options);

console.log('Sign-in successful');
} catch (error) {
console.error('Error during phone number verification:', error);
} finally {
await loading.dismiss();
}
}
< /code>
Mein Dienstkonstruktor: < /p>
constructor(private readonly ngZone: NgZone) {

FirebaseAuthentication.removeAllListeners().then(() => {

FirebaseAuthentication.addListener('phoneCodeSent', async (event) => {
this.ngZone.run(() => {
console.log("phoneCodeSent"+ event.verificationId);
});
});

FirebaseAuthentication.addListener(
'phoneVerificationCompleted',
async (event) => {
this.ngZone.run(() => {
console.log("phoneVerificationCompleted"+ event.user?.uid);
});
},
);

FirebaseAuthentication.addListener(
'phoneVerificationFailed',
async (event) => {
this.ngZone.run(() => {
console.log("phoneVerificationFailed"+ event.message);
});
},
);

});
}
Erwartete Verhalten
Ich erwarte, Code und der SigninWithPhoneNumber (Optionen) Um ein Objekt mit Benutzerinformationen oder einem VerificationId zurückzugeben, mit dem ich den SMS -Code überprüfen kann. Zusammenfassend lässt sich sagen, dass ein Ereignis auftreten. Protokolliert Folgendes: < /p>

Code: Select all

⚡️  [log] - Attempting to sign in with phone number: +573218116768
⚡️  To Native ->  FirebaseAuthentication signInWithPhoneNumber 110818811
⚡️  TO JS undefined
⚡️  [log] - Sign-in successful
< /code>
Die Antwort aus der nativen Schicht (TO JS
) ist undefiniert und es wird kein Fehler geworfen. Auch Firebase sendet keine SMS -Nachricht. Schließlich im Konstruktor meines Dienstes sind die Hörer für alle möglichen Ereignisse, die durch meine Methode erstellt wurden Zusätzliche Details
FireBase -Konfiguration:

[*] Die Telefonauthentifizierung ist in der Firebase-Konsole aktiviert. /ul>
Umgebung: < /p>

Ionic: 8.x < /li>
Angular: ^18 .x
[*]@concacitor fireBase/Authentifizierung: ^6.3.1
[*] Kondensator: 6.x
< /p>

FireBase -Konfiguration ist korrekt (mit Ausnahme von APNs, die ich nicht
eingerichtet habe, weil ich verstehe Die Nummer befindet sich im internationalen Format. BR /> < /ul>
Schlüsselfragen: < /em> < /p>

Was könnte eine SigninwithPhonNumber generieren Sie kein Ereignis und Firebase sendet keinen SMS -Code? Arbeiten Sie an iOS, auch wenn ich nur die Telefonauthentifizierung verwende? Um dieses Problem zu beheben. > < /p>

Code: Select all

import UIKit
import Capacitor
import FirebaseCore

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
FirebaseApp.configure()
return true
}

func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks.  Games should use this method to pause the game.
}

func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {
// Called when the app was launched with a url. Feel free to add additional processing here,
// but if you want the App API to support tracking app url opens, make sure to keep this call
return ApplicationDelegateProxy.shared.application(app, open: url, options: options)
}

func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
// Called when the app was launched with an activity, including Universal Links.
// Feel free to add additional processing here, but if you want the App API to support
// tracking app url opens, make sure to keep this call
return ApplicationDelegateProxy.shared.application(application, continue: userActivity, restorationHandler: restorationHandler)
}

}
Poddatei:

Code: Select all

require_relative '../../node_modules/@capacitor/ios/scripts/pods_helpers'

platform :ios, '13.0'
use_frameworks!

# workaround to avoid Xcode caching of Pods that requires
# Product -> Clean Build Folder after new Cordova plugins installed
# Requires CocoaPods 1.6 or newer
install! 'cocoapods', :disable_input_output_paths => true

def capacitor_pods
pod 'Capacitor', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorCordova', :path => '../../node_modules/@capacitor/ios'
pod 'CapacitorFirebaseAuthentication', :path => '../../node_modules/@capacitor-firebase/authentication'
pod 'CapacitorApp', :path => '../../node_modules/@capacitor/app'
pod 'CapacitorCamera', :path => '../../node_modules/@capacitor/camera'
pod 'CapacitorHaptics', :path => '../../node_modules/@capacitor/haptics'
pod 'CapacitorKeyboard', :path => '../../node_modules/@capacitor/keyboard'
pod 'CapacitorPreferences', :path => '../../node_modules/@capacitor/preferences'
pod 'CapacitorStatusBar', :path => '../../node_modules/@capacitor/status-bar'
end

target 'App' do
capacitor_pods
# Add your Pods here
end

post_install do |installer|
assertDeploymentTarget(installer)
end

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post