365bet提前结束投注

电话号码验证失败

电话号码验证失败

我正在实现一个OTP电话验证通过Firebase身份验证与颤振。安卓系统上的--它的工作原理就像一个迷人的,但另一方面,on iOS --我不能让它运行。这是我得到的错误:

注意,我使用的是OneSignal,它在Android和iOS上都运行得很好

颤振:电话号码验证失败。代码: verifyPhoneNumberError.消息:如果禁用了应用程序委托swizzling,则需要将UIApplicationDelegate接收的远程通知转发给FIRAuth的canHandleNotificaton: method。

我的颤栗医生:

我的CocoaPods:

我对颤振的OPT功能:

代码语言:javascript运行复制import 'package:firebase_auth/firebase_auth.dart';

class SMSFunctions {

/// Sends the code to the specified phone number.

static Future sendCodeToPhoneNumber(

String phoneNo, Function onSuccess, Function onFailed) async {

FirebaseAuth.instance.signOut();

final PhoneVerificationCompleted verificationCompleted =

(AuthCredential user) {

print(

'Inside _sendCodeToPhoneNumber: signInWithPhoneNumber auto succeeded: $user');

};

final PhoneVerificationFailed verificationFailed =

(AuthException authException) {

print(

'Phone number verification failed. Code: ${authException.code}. Message: ${authException.message}');

onFailed();

};

final PhoneCodeSent codeSent =

(String verificationId, [int forceResendingToken]) async {

verificationId = verificationId;

print("code sent to " + phoneNo);

onSuccess(verificationId);

};

final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =

(String verificationId) {

verificationId = verificationId;

print("time out");

onFailed();

};

await FirebaseAuth.instance.verifyPhoneNumber(

phoneNumber: phoneNo,

timeout: const Duration(seconds: 5),

verificationCompleted: verificationCompleted,

verificationFailed: verificationFailed,

codeSent: codeSent,

codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);

}

static Future confirmSMS(String smsCode, String verificationId) async {

print(smsCode);

print(verificationId);

final AuthCredential credential = PhoneAuthProvider.getCredential(

verificationId: verificationId,

smsCode: smsCode,

);

AuthResult authResult;

try {

authResult = await FirebaseAuth.instance.signInWithCredential(credential);

print(authResult.user);

final FirebaseUser currentUser = authResult.user;

if (currentUser != null)

return true;

else

return false;

} catch (e) {

print(e);

}

return false;

}

}插件版本:

代码语言:javascript运行复制firebase_auth: ^0.16.1到目前为止,这是我的尝试:

修改了我的AppDelegate.swift,就像在帖子中代码语言:javascript运行复制import UIKit

import Flutter

@UIApplicationMain

@objc class AppDelegate: FlutterAppDelegate {

override func application(

_ application: UIApplication,

didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?

) -> Bool {

GeneratedPluginRegistrant.register(with: self)

return super.application(application, didFinishLaunchingWithOptions: launchOptions)

}

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

// Pass device token to auth

Auth.auth().setAPNSToken(deviceToken, type: .prod)

}

func application(_ application: UIApplication,

didReceiveRemoteNotification notification: [AnyHashable : Any],

fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

if Auth.auth().canHandleNotification(notification) {

completionHandler(.noData)

return

}

// This notification is not auth related, developer should handle it.

}

// For iOS 9+

func application(_ application: UIApplication, open url: URL,

options: [UIApplicationOpenURLOptionsKey : Any]) -> Bool {

if Auth.auth().canHandle(url) {

return true

}

// URL not auth related, developer should handle it.

}

// For iOS 8-

func application(_ application: UIApplication,

open url: URL,

sourceApplication: String?,

annotation: Any) -> Bool {

if Auth.auth().canHandle(url) {

return true

}

// URL not auth related, developer should handle it.

}

func scene(_ scene: UIScene, openURLContexts URLContexts: Set) {

for urlContext in URLContexts {

let url = urlContext.url

Auth.auth().canHandle(url)

}

// URL not auth related, developer should handle it.

}

func application(_ application: UIApplication,

didReceiveRemoteNotification notification: [AnyHashable : Any],

fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {

if Auth.auth().canHandleNotification(notification) {

completionHandler(.noData)

return

}

// This notification is not auth related, developer should handle it.

handleNotification(notification)

}

}尝试更改FirebaseAuth插件版本,如本帖子中所示改变了我的URLSCHEMES,就像在这个帖子中

我的google.services- yellow .yellow(复制黄色条纹)我的info.plist URL方案(粘贴黄色条纹)//注意第二个项目是Facebook方案

更改了我的FirebaseAppDelegateProxyEnabled,就像在这个帖子中​

配置我的Firebase Auth密钥和reCAPTCHA验证,遵循谷歌文档​

配置了我在Xcode上的签名和功能​

相关推荐