gpt4 book ai didi

ios - Flutter-Firebase phone Auth 总是在 iOS 上返回 token 不匹配

转载 作者:行者123 更新时间:2023-11-29 13:54:32 24 4
gpt4 key购买 nike

我正在尝试使用电话身份验证,它在 Android 上按预期工作,但在 iOS 上我总是遇到 token 不匹配并且收不到代码。

其他 Firebase 服务,例如 cloud firestore 和 email Auth,在 iOS 上运行良好。

我确定了以下内容:

-在 Firebase 中添加 APN key

-Google 服务文件已更新

-后台模式和推送通知功能开启

错误消息来自 PhoneVerificationFailed

Future<void> _verifyPhoneNumber() async {

setState(() {
_message = '';
});

final PhoneVerificationCompleted verificationCompleted =
(AuthCredential phoneAuthCredential) async {

await _auth.signInWithCredential(phoneAuthCredential);

setState(() {
_message = 'Received phone auth credential: $phoneAuthCredential';

});

};

final PhoneVerificationFailed verificationFailed =
(AuthException authException) {
setState(() {
_message = '********************\n\n'
'Phone number verification failed. Code: ${authException.code}.'
'\n Message: ${authException.message}'
'\n\n********************';
});
};

final PhoneCodeSent codeSent =
(String verificationId, [int forceResendingToken]) async {
_verificationId = verificationId;

setState(() {
_message = 'waiting for code';
//waitingCode = true;
});
};

final PhoneCodeAutoRetrievalTimeout codeAutoRetrievalTimeout =
(String verificationId) {
_verificationId = verificationId;
};

try {
await _auth.verifyPhoneNumber(
phoneNumber: number,
timeout: const Duration(seconds: 30),
verificationCompleted: verificationCompleted,
verificationFailed: verificationFailed,
codeSent: codeSent,
codeAutoRetrievalTimeout: codeAutoRetrievalTimeout);
} catch (e) {
print('Error is $e');
}
}

我从日志中获取这些消息

Userinfo {
"com.google.firebase.auth" = {
warning = "This fake notification should be forwarded to Firebase Auth.";
};
}
UserDate : {
"com.google.firebase.auth" = {
warning = "This fake notification should be forwarded to Firebase Auth.";
};
}
UserDate Json : {
"com.google.firebase.auth" : {
"warning" : "This fake notification should be forwarded to Firebase Auth."
}
}
flutter:


TRUE
flutter: Call Back {
"com.google.firebase.auth" : {
"warning" : "This fake notification should be forwarded to Firebase Auth."
}
}

最佳答案

我知道现在回答这个问题为时已晚。但我最近也遇到了同样的错误。我在 iOS 上解决了这个问题。您的整个配置必须有效。您需要进行两项设置。

  • 从 GoogleService-info.plist 中删除任何方法调配变量即从 plist 中删除 FirebaseAppDelegateProxyEnabled 属性

  • 在 AppDelegate.swift 中,覆盖此方法并设置以下内容

    函数应用程序(应用程序:UIApplication,didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {Messaging.messaging().apnsToken = deviceToken

它在 https://firebase.google.com/docs/cloud-messaging/ios/client#token-swizzle-disabled 中提到

我正在使用 firebase_messaging: ^6.0.16 并且上述设置有效

关于ios - Flutter-Firebase phone Auth 总是在 iOS 上返回 token 不匹配,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57395948/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com