"Invalid Token" when trying to authenticate in IOS real device

Par*_*ech 2 ios firebase-authentication flutter

Hi have tried to use the phone authentication from firebase, but it is failing. I have read a lot of question regarding this problem and most of them mentioned to create the apn key in developer.apple.com

Maybe that could work, but the thing is that I have used the phone authentication in another apps that have access to the same firebase project and I didn't add any apn key.

在此输入图像描述

For "Delivery Clientes" I can authenticate using phone number, but for "DeliveryAppRestaurant" not. This is my third app using authentication with phone number, but I don't know what I'm missing (I know that i have never create an apn key, so I think that's not necessary). I think that I'm forgetting something. I already add the URL at info Runner 在此输入图像描述

And I'm still receiving the exception of: [firebase_auth/invalid-app-credential] Invalid token.

And this is only happening when I tested in real device, in the simulators works fine. Any thoughts?

regards,

Par*_*ech 6

如果有人遇到和我一样的问题。看来如果您的应用程序有通知服务:
在此输入图像描述

您应该在 firebase 上添加 apn key:

在此输入图像描述

另外,如果您在连接验证码时遇到问题,您可以在 AppDelegate 上添加以下行

 //Auth
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
           let firebaseAuth = Auth.auth()
           firebaseAuth.setAPNSToken(deviceToken, type: AuthAPNSTokenType.unknown)
 }
 override func application(_ application: UIApplication, didReceiveRemoteNotification userInfo: [AnyHashable : Any], fetchCompletionHandler completionHandler: @escaping (UIBackgroundFetchResult) -> Void) {
           let firebaseAuth = Auth.auth()
           if (firebaseAuth.canHandleNotification(userInfo)){
               print(userInfo)
               return
           }
}
Run Code Online (Sandbox Code Playgroud)