Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug: iOS Phone login on iOS16.1 is not working #341

Closed
yash-278 opened this issue Mar 23, 2023 · 8 comments
Closed

bug: iOS Phone login on iOS16.1 is not working #341

yash-278 opened this issue Mar 23, 2023 · 8 comments

Comments

@yash-278
Copy link

Plugin(s):

firebase/authentication

Platform(s):

iOS 16

Current behavior:

iOS login with Phone Number is working on previous versions. But iOS devices with iOS 16 are giving Internal auth error.

Expected behavior:

It should be able to log in in latest iOS as well.

Steps to reproduce:

Related code:

import { FirebaseAuthentication } from '@capacitor-firebase/authentication'

import { Auth, PhoneAuthProvider, signInWithCredential } from 'firebase/auth'

import { Dialog } from '@capacitor/dialog'

export const signInWithPhoneNumberNative = async (
  phoneNumber: string,
  auth: Auth
) => {
  // 1. Start phone number verification
  const { verificationId } = await FirebaseAuthentication.signInWithPhoneNumber(
    {
      phoneNumber: '+91' + phoneNumber,
    }
  )
  // 2. Let the user enter the SMS code
  // const verificationCode = window.prompt(

  // )

  const { value } = await openDialog()

  // 3. Sign in on the web layer using the verification ID and verification code.
  const credential = PhoneAuthProvider.credential(
    verificationId || '',
    value || ''
  )
  const result = await signInWithCredential(auth, credential)
  return result.user
}

const openDialog = async () => {
  const { value, cancelled } = await Dialog.prompt({
    title: 'OTP Verification',
    message:
      'Please enter the verification code that was sent to your mobile device.',
  })

  if (cancelled) {
    FirebaseAuthentication.removeAllListeners()
    throw new Error('OTP verification cancelled by user.')
  }

  if (!value) {
    FirebaseAuthentication.removeAllListeners()
    throw new Error('OTP verification code cannot be empty.')
  }

  return { value, cancelled } as const
}

Other information:

Capacitor doctor:

Latest Dependencies:

  @capacitor/cli: 4.7.1
  @capacitor/core: 4.7.1
  @capacitor/android: 4.7.1
  @capacitor/ios: 4.7.1

Installed Dependencies:

  @capacitor/cli: 4.4.0
  @capacitor/core: 4.4.0
  @capacitor/android: 4.4.0
  @capacitor/ios: 4.4.0
@yash-278 yash-278 changed the title bug: bug: iOS Phone login on 16.1 is not working Mar 23, 2023
@yash-278 yash-278 changed the title bug: iOS Phone login on 16.1 is not working bug: iOS Phone login on iOS16.1 is not working Mar 23, 2023
@robingenz
Copy link
Member

robingenz commented Mar 23, 2023

What is the error message?

Edit: Please also paste the XCode log.

@yash-278
Copy link
Author

image

This the error message we get. Attaching logs might take sometime, when our iOS dev comes online. I'll reply again once I get them.

@yash-278
Copy link
Author

Hey, so even Xcode is sending the same response in logs.

⚡️  [warn] - Native Signin
⚡️  To Native ->  FirebaseAuthentication signInWithPhoneNumber 19853016
ERROR MESSAGE:  {"errorMessage":"An internal error has occurred, print and inspect the error details for more information.","message":"An internal error has occurred, print and inspect the error details for more information."}
⚡️  [error] - {"errorMessage":"An internal error has occurred, print and inspect the error details for more information.","message":"An internal error has occurred, print and inspect the error details for more information."}

@robingenz
Copy link
Member

robingenz commented Mar 23, 2023

Please try it again with this dev version:

npm i @capacitor-firebase/authentication@1.4.0-dev.bcd3080.1679589381

I improved the error logging. The XCode output should now contain more information.

@robingenz
Copy link
Member

Sorry, i messed up the build.
Please use this dev version:

npm i @capacitor-firebase/authentication@1.4.0-dev.182bc57.1679590798

@yash-278
Copy link
Author

yash-278 commented Mar 24, 2023

Hey @robingenz, Now we got little more stuff in error logs

[warn] - Native Signin
⚡️  To Native ->  FirebaseAuthentication signInWithPhoneNumber 67187681
[ FirebaseAuthentication ]  Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information., NSUnderlyingError=0x281a22d30 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={NSUnderlyingError=0x281a73030 {Error Domain=com.google.HTTPStatus Code=503 "(null)" UserInfo={data={length = 207, bytes = 0x7b0a2020 22657272 6f72223a 207b0a20 ... 5d0a2020 7d0a7d0a }, data_content_type=application/json; charset=UTF-8}}, FIRAuthErrorUserInfoDeserializedResponseKey={
    code = 503;
    errors =     (
                {
            domain = global;
            message = "Error code: 33";
            reason = backendError;
        }
    );
    message = "Error code: 33";
}}}}
[ FirebaseAuthentication ]  Optional(Error Domain=FIRAuthErrorDomain Code=17999 "An internal error has occurred, print and inspect the error details for more information." UserInfo={FIRAuthErrorUserInfoNameKey=ERROR_INTERNAL_ERROR, NSLocalizedDescription=An internal error has occurred, print and inspect the error details for more information., NSUnderlyingError=0x281a22d30 {Error Domain=FIRAuthInternalErrorDomain Code=3 "(null)" UserInfo={NSUnderlyingError=0x281a73030 {Error Domain=com.google.HTTPStatus Code=503 "(null)" UserInfo={data={length = 207, bytes = 0x7b0a2020 22657272 6f72223a 207b0a20 ... 5d0a2020 7d0a7d0a }, data_content_type=application/json; charset=UTF-8}}, FIRAuthErrorUserInfoDeserializedResponseKey={
    code = 503;
    errors =     (
                {
            domain = global;
            message = "Error code: 33";
            reason = backendError;
        }
    );
    message = "Error code: 33";
}}}})
ERROR MESSAGE:  {"message":"An internal error has occurred, print and inspect the error details for more information.","errorMessage":"An internal error has occurred, print and inspect the error details for more information."}
⚡️  [error] - {"message":"An internal error has occurred, print and inspect the error details for more information.","errorMessage":"An internal error has occurred, print and inspect the error details for more information."}

@robingenz
Copy link
Member

As the error message says, it is an internal Firebase error that probably has nothing to do with the plugin itself. You have to try different solutions and see what works. Unfortunately I can't help you much here.
Maybe this SO answer is a start: https://stackoverflow.com/a/71404252

Please let me know if you find a solution.

@yash-278
Copy link
Author

Yes, it seems it was something related to APNs. Not sure what it is, but the Dev mentioned he had used APNs given by Apple while deploying to App Store. He re-added them to Firebase and now it's fine.

Thanks for the help. 🙏

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 21, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants