[英]Flutter app crashes on firebase phone auth in iOS platform
[英]Firebase Phone Auth verificationId never being set. (Flutter iOS)
好的,希望是快速的問題,但由於某些原因,在我當前的項目中,從 firebase_auth 實際創建和設置我的 verifyId 的調用似乎從未被調用過。
涉及代碼片段。
final PhoneCodeSent smsCodeSent = (String verID, [int forceCodeResent]) async {
this.verificationId = verID;
print('Setting verificationId');
};
print('Creating Verification Code for: ' + this.phoneNumber);
await _auth.verifyPhoneNumber(
phoneNumber: this.phoneNumber,
codeAutoRetrievalTimeout: timeout,
codeSent: smsCodeSent,
timeout: const Duration(seconds: 20),
verificationCompleted: verificationComplete,
verificationFailed: verificationFailed,
);
print(this.verificationId);
}
我確實看到了電話號碼的打印(無論用戶輸入什么電話號碼),但輸出日志只顯示:
顫振:創建驗證碼:5555555555 顫振:空
這意味着永遠不會調用 smsCodeSent 函數。 任何想法為什么?
(Flutter Doctor 的結果如下)
[✓] Flutter (Channel stable, v1.12.13+hotfix.5, on Mac OS X 10.15.2 19C57, locale en-CA) • Flutter version 1.12.13+hotfix.5 at /Users/iosdev/Developer/flutter •框架修訂版 27321ebbad(3 周前),2019-12-10 18:15:01 -0800 • 引擎修訂版 2994f7e1e6 • Dart 版本 2.7.0
[✓] Android 工具鏈 - 為 Android 設備開發(Android SDK 版本 29.0.2) • Android SDK 位於 /Users/iosdev/Library/Android/sdk • 未配置 Android NDK 位置(可選;對原生分析支持有用) • 平台 android -29,構建工具 29.0.2 • Java 二進制文件位於:/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java 版本 OpenJDK 運行時環境(構建 1.8.0_202-release-1483 -b49-5587405) • 接受所有 Android 許可證。
[✓] Xcode - 為 iOS 和 macOS 開發 (Xcode 10.2.1) • Xcode 位於 /applications/Xcode.app/Contents/Developer • Xcode 10.2.1,構建版本 10E1001 • CocoaPods 版本 1.8.4
[✓] Android Studio(版本 3.5) • Android Studio at /Applications/Android Studio.app/Contents • Flutter 插件版本 42.1.1 • Dart 插件版本 191.8593 • Java 版本 OpenJDK 運行時環境(構建 1.8.0_202-release-1483- b49-5587405)
[✓] VS Code(版本 1.41.1) • VS Code 位於 /Applications/Visual Studio Code.app/Contents • Flutter 擴展版本 3.7.1
[✓] 已連接設備(1 個可用) • iPhone Xʀ • E901CA1F-553F-41E6-864D-57E151B3F39F • ios • com.apple.CoreSimulator.SimRuntime.iOS-12-2(模擬器)
好吧,我找到了我的問題的解決方案。 顯然,iOS 存在一個問題,即它拒絕將模擬器視為真實設備,因此無法正確遵循使用 firebase 的實際身份驗證流程。
因此,對於遇到類似問題的任何人,請確保您在實際設備上進行 firebase_auth 測試。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.