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

Method swizzling problem on firebase_auth phone auth iOS #35267

Closed
Renziera opened this issue Jun 28, 2019 · 38 comments · Fixed by flutter/plugins#1826
Closed

Method swizzling problem on firebase_auth phone auth iOS #35267

Renziera opened this issue Jun 28, 2019 · 38 comments · Fixed by flutter/plugins#1826
Assignees
Labels
c: crash Stack traces logged to the console p: firebase_auth The Firebase Auth plugin package flutter/packages repository. See also p: labels.

Comments

@Renziera
Copy link

I'm having an issue with firebase_auth verifyPhoneNumber on iOS.
I followed all requirements on documentation. APN works fine (FCM can be received). But whenever verifyPhoneNumber called, it always fail with exception message:

If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotification: method

I did pod upgrade to firebase_auth 6.3.0 and flutter to 1.7.11-pre43
still got the same problem. Android build works fine.

@Arno0216
Copy link

+1
In my case, the firebase auth by phone was working perfectly on production for few months. But all of sudden, user reported failed case yesterday.
Also tested other login methods, Android and FCM are working fine and got the same exception message.

@Renziera Renziera closed this as completed Jul 3, 2019
@MustansirZia
Copy link

MustansirZia commented Jul 9, 2019

Why was this issue closed?
I can confirm this happened to me too when I upgraded my flutter to v1.7.8+hotfix.2 from v1.5.4-hotfix.2. As soon as I downgraded the exception vanished. Using firebase_auth 0.11.1+7.

@khainhero
Copy link

Same issue here. I think this is very important as users cannot properly register now.
Just upgraded to v1.7.8+hotfix.3 and still an issue.
Everything was working before.
I double checked my iOS capabilities section for push notification/background fetch/remote notifications and everything seems fine.
firebaseappdelegateproxyenabled in the info.plist was a type STRING with a value NO
I fixed that to type BOOLEAN with value YES
I also did pod update, clean install of the app and flutter clean.
Still an issue.

@gisinator
Copy link

Glad I'm not the only one facing this issue. I upgraded to newest stable 1.7.8 hotfix.3 yesterday and since then it doesnt work anymore. Unfortunately this is a major issue, users cant register any more. Flutter devs, can you help? :)

@collinjackson
Copy link
Contributor

collinjackson commented Jul 10, 2019

Firebase's automatic swizzling code lives here:

https://github.com/firebase/firebase-ios-sdk/blob/7eb1747e4b9be195ea9908b9da28b1d0f818afe3/GoogleUtilities/AppDelegateSwizzler/GULAppDelegateSwizzler.m

It seems likely that some change in the engine broke their swizzling, and it seems like we have two options:

  • We could try to figure out what broke their swizzling and address it.
  • We could always register for notifications (didReceiveRemoteNotification:...) in firebase_auth.

The latter approach is in flutter/plugins#1826 but may result in warning emails being sent to firebase_auth users who aren't actually using the phone auth feature.

@kaumudpa
Copy link

Same problem here when upgraded to newest stable version 1.7.8-hotfix.3.

@kaumudpa
Copy link

The PR by @collinjackson is working, we can use it in the project in the following manner until the PR is merged in the main branch.

firebase_auth:
    git:
      url: https://github.com/collinjackson/plugins.git
      ref: 441417c2fed0ff26bf84a49ab2c5ffd2aa5487de
      path: packages/firebase_auth

@BPHvZ
Copy link

BPHvZ commented Jul 11, 2019

The PR by @collinjackson is working, we can use it in the project in the following manner until the PR is merged in the main branch.

firebase_auth:
    git:
      url: https://github.com/collinjackson/plugins.git
      ref: 441417c2fed0ff26bf84a49ab2c5ffd2aa5487de
      path: packages/firebase_auth

This isn't working for me. I've checked my setting, plist, profiles, I haven't changed anything and it worked before I updated to the new flutter version.

@gisinator
Copy link

@kaumudpa : May I ask you to check on another device on which the sms verification hasnt been tested yet? Reason I'm asking: Collin's PR does work on my testdevices where sms verification had worked before (and then stopped working with upgrade to latest stable). But when I try it on a new device, I get a "token mismatch" error.

I triplechecked all my settings and went over all configuration steps, but with no success: "Token mismatch". I recreated my APNS token in Apple developer portal, so right now I am wondering whether I did something wrong or there is an issue with new devices.

Again, thank you Collin for the PR and everybody involved in investigating this issue. :)

@collinjackson
Copy link
Contributor

collinjackson commented Jul 11, 2019

I appreciate the help testing flutter/plugins#1826. (Unfortunately it's a bit tricky to test automatically.)

The "token mismatch" issues might be due to type:FIRAuthAPNSTokenTypeSandbox versus type:FIRAuthAPNSTokenTypeProd. The official docs suggest always using prod so I've updated my PR to remove the #ifdef DEBUG and always use prod.

[[FIRAuth auth] setAPNSToken:deviceToken type:FIRAuthAPNSTokenTypeProd];

I'm happy to go ahead and merge flutter/plugins#1826 if there's a consensus that it's an improvement while we investigate the larger swizzling issues. Or if folks feel that I should revert flutter/plugins@b57627f let me know that too. Thanks.

@gisinator
Copy link

Update: I'm still getting the "token mismatch" error when running "flutter run --release" within AndroidStudio, even with your updated PR.
But, more important: When sending the exact same version to testflight and download it from there, SMS verification works, also on my new device.
By the end of the day that's what counts, so I can definitely live with that.
So, appreciate your support, Collin, and, for my side, go and merge :)

@enzoftware
Copy link
Member

The PR by @collinjackson is working, we can use it in the project in the following manner until the PR is merged in the main branch.

firebase_auth:
    git:
      url: https://github.com/collinjackson/plugins.git
      ref: 441417c2fed0ff26bf84a49ab2c5ffd2aa5487de
      path: packages/firebase_auth

I have the same issue here and this works perfect for me. Thanks @collinjackson.

Im not sure if this is currently working in a version of firebase_auth or fixed in a version of flutter. Because i have troubles using flutter v1.7.8+hotfix.3 and firebase_auth: 0.11.1+7.

@collinjackson
Copy link
Contributor

The PR by @collinjackson is working, we can use it in the project in the following manner until the PR is merged in the main branch.

firebase_auth:
    git:
      url: https://github.com/collinjackson/plugins.git
      ref: 441417c2fed0ff26bf84a49ab2c5ffd2aa5487de
      path: packages/firebase_auth

I have the same issue here and this works perfect for me. Thanks @collinjackson.

Im not sure if this is currently working in a version of firebase_auth or fixed in a version of flutter. Because i have troubles using flutter v1.7.8+hotfix.3 and firebase_auth: 0.11.1+7.

You'll need to update your firebase_auth to version 0.11.1+8 to get the fix.

@emersonsiega
Copy link

I'm having the same problem with firebase_auth: 0.11.1+11

flutter doctor:

[✓] Flutter (Channel stable, v1.7.8+hotfix.4, on Mac OS X 10.14.5 18F132, locale pt-BR)
    • Flutter version 1.7.8+hotfix.4 at /Users/emerson.siega/development/flutter
    • Framework revision 20e59316b8 (7 days ago), 2019-07-18 20:04:33 -0700
    • Engine revision fee001c93f
    • Dart version 2.4.0

 
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
    • Android SDK at /Users/emerson.siega/Library/Android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 10.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 10.2, Build version 10E125
    • CocoaPods version 1.6.1

[✓] iOS tools - develop for iOS devices
    • ios-deploy 1.9.4

[✓] Android Studio (version 3.4)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin version 37.0.1
    • Dart plugin version 183.6270
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1343-b01)

[✓] VS Code (version 1.36.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.2.0

@nizo-m
Copy link

nizo-m commented Sep 19, 2019

Same issue in Flutter v1.9.1+hotfix.2 .
tried with firebase_auth: ^0.14.0+5 and tried the solution @collinjackson made without luck.

@giorgiogross
Copy link

giorgiogross commented Sep 25, 2019

Hi, we are experiencing the same issue and I'm now trying to fix this since two days..
Flutter version: Flutter (Channel stable, v1.9.1+hotfix.2, on Mac OS X 10.14.5 18F132, locale de-DE), firebase_auth: firebase_auth: "^0.14.0+5"

On Android everything seems to work just fine. iOS Simulator enters the reCaptcha verification which also works fine. However, on a real iOS device the verification code is never sent. Disabling background app refresh on iOS and thus forcing reCaptcha verification is also not working. The call to FirebaseAuth.instance.verifyPhoneNumber(...) always triggers the verificationFailed callback and authException.message/authException.code shows Token mismatch/verifyPhoneNumberError.

We use firebase_messaging: "5.1.6" and have set up APNs already some moths ago. Push notifications are working properly, so I initially didn't update any APNs credential files. Anyway, I now tried both renewing the old APNs Credential Keys and using APNs Certificates with no luck. I then tried to downgrade to firebase_auth: 0.11.1+8, which still didn't fix the issue. My next attempt was to fork the flutterfire repo and look into the auth initialization. I thought maybe there is an issue with the APNSTokenType being passed, but with my limited iOS native dev skills I can only roughly estimate that setAPNSToken is always passed FIRAuthAPNSTokenTypeProd which should work with APNs Authentication Key in the Firebase console.. I also tried to change the Runner.entitlements aps-environment from development to production after browsing SO a bit, but that didn't change anything. My last attempt was to ask the user for granting the push notifications permission before signing him up. I thought there might be an issue with the silent push notification not being delivered. But again, no luck with that. Cleaning up and reinstalling pods, clearing pod cache and pod update didn't help neither.

Any help or hints for where to look at next would be appreciated! We are currently moving away from the facebook account kit (already removed the dependencies), but I cannot publish a new release with firebase_auth as long as the sign up does not work seamlessly on all devices.

@Igalsr
Copy link

Igalsr commented Oct 3, 2019

Hi @ordsen @nizo-m ,

Have you found a solution?

@nizo-m
Copy link

nizo-m commented Oct 3, 2019

Hi @ordsen @nizo-m ,

Have you found a solution?

hi @Igalsr ,
I did not find a solution, so I went back to flutter 1.5 for now.

@Igalsr
Copy link

Igalsr commented Oct 3, 2019

Hi @ordsen @nizo-m ,
Have you found a solution?

hi @Igalsr ,
I did not find a solution, so I went back to flutter 1.5 for now.

Thank you, that's really annoying.

@emersonsiega
Copy link

The same for me! I think I'll have to downgrade Flutter version just because of this... Really, really annoying...

@giorgiogross
Copy link

Hi @ordsen @nizo-m ,
Have you found a solution?

hi @Igalsr ,
I did not find a solution, so I went back to flutter 1.5 for now.

Me neither. We added firebase auth to our backlog and will retry it after the next flutter release.

@emersonsiega
Copy link

@collinjackson I think this issue need to be reopened... There's some people with this problem yet...

@emersonsiega
Copy link

After some time, we can solve this issue following this two docs:

We configure the APNs how's described here.
https://firebase.google.com/docs/auth/ios/phone-auth#start-receiving-silent-notifications
But just this doesn't solve the problem.

We also need to add some changes into App's Info.plist and Runner/AppDelegate.m
https://firebase.google.com/docs/auth/ios/phone-auth#appendix:-using-phone-sign-in-without-swizzling

Working with Flutter 1.7.8+hotfix.4

@Igalsr
Copy link

Igalsr commented Oct 9, 2019

@emersonsiega I still get a token mismatch on phone authentication

@emersonsiega
Copy link

@Igalsr maybe we are talking about different errors... For me the error message is:
If app delegate swizzling is disabled, remote notifications received by UIApplicationDelegate need to be forwarded to FIRAuth's canHandleNotificaton: method.

This starts after upgrade from v1.5.4 to v1.7.8.

@Igalsr
Copy link

Igalsr commented Oct 9, 2019

@emersonsiega yes you are right, my error appeared at the same time so I thought I would try your solution as well.

@kroikie
Copy link

kroikie commented Oct 13, 2019

@Renziera

This issue has been moved to firebase/flutterfire#1102. Any further collaboration will be done there.

@19hours
Copy link

19hours commented Nov 16, 2019

@Igalsr @ordsen

I think the token mismatch error happens when you test locally because firebase_auth looks for the production APNs but you are signing the app with a development profile. As a temporary workaround you can set the APNSTokentype for firebase to sandbox or unknown which would detect your APNs type based on your provisioning profile.

You can use my forked fix here:
https://github.com/19hours/flutterfire/commit/3366091101b9e9701d23c49672bf2d9e6135d656

Relevant commit:
flutter/plugins@b57627f

@LeeLoHoon
Copy link

@ordsen
We have same error. Did you solve this problem anyway?
we tried above things but they didn't work.
Do you think this is version problem?

@enzoftware
Copy link
Member

@ordsen
We have same error. Did you solve this problem anyway?
we tried above things but they didn't work.
Do you think this is version problem?

What is your version of flutter and the firebase depedencies?

@LeeLoHoon
Copy link

@enzoftware
My flutter version is v1.12.13+hotfix.5
And my Firebase dependency is firebase_auth: ^0.14.0+8.
I think auth version is meaningful.
Do you have any idea?

@enzoftware
Copy link
Member

Check the recommended versions for each firebase dependecies in https://github.com/FirebaseExtended/flutterfire

For firebase_auth would be 0.15.3+1.

@LeeLoHoon
Copy link

I did that too.. But it still doesn't work..

@LeeLoHoon
Copy link

I solved this problem. It was related APN setting(SandBox Token) not version problem.
Thanks :)

@dryaz
Copy link

dryaz commented Feb 6, 2020

I solved this problem. It was related APN setting(SandBox Token) not version problem.
Thanks :)

@LeeLoHoon could you share what have you done to fix this?

@Abosrie
Copy link

Abosrie commented Feb 11, 2020

I am facing the same problem! Any hint of how to fix it?

@LeeLoHoon
Copy link

@dryaz
@Abosrie
Here is my solution.
firebase/flutterfire#1102
:)

@github-actions
Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2021
@flutter-triage-bot flutter-triage-bot bot added the package flutter/packages repository. See also p: labels. label Jul 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
c: crash Stack traces logged to the console p: firebase_auth The Firebase Auth plugin package flutter/packages repository. See also p: labels.
Projects
None yet
Development

Successfully merging a pull request may close this issue.