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

onAuthStateChanged not returning any result on iOS Sumulator #1677

Closed
6 of 31 tasks
levani opened this issue Nov 10, 2018 · 10 comments · Fixed by #1698
Closed
6 of 31 tasks

onAuthStateChanged not returning any result on iOS Sumulator #1677

levani opened this issue Nov 10, 2018 · 10 comments · Fixed by #1698
Labels
help: needs-triage Issue needs additional investigation/triaging. plugin: authentication Firebase Authentication

Comments

@levani
Copy link

levani commented Nov 10, 2018

Issue

I just updated to rnfirebase 5.1.0 from 5.0 and noticed that onAuthStateChanged works in a strange way on ios simulator. I need to reload app twice for the method to return a result. The first time I reload the app the callback is never invoked! Then after reloading again it works as expecred. If I reload again it does not work and it repeats.


Project Files

iOS

ios/Podfile:

  • I'm not using Pods
  • I'm using Pods and my Podfile looks like:
pod 'Firebase/Core', '~> 5.11.0'
pod 'Firebase/Auth', '~> 5.11.0'
pod 'Firebase/Firestore', '~> 5.11.0'
pod 'Firebase/Functions', '~> 5.11.0'
pod 'Firebase/Storage', '~> 5.11.0'
pod 'Firebase/Messaging', '~> 5.11.0'
pod 'Firebase/DynamicLinks', '~> 5.11.0'
# N/A

AppDelegate.m:

// N/A

Android

android/build.gradle:

// N/A

android/app/build.gradle:

// N/A

android/settings.gradle:

// N/A

MainApplication.java:

// N/A

AndroidManifest.xml:

<!-- N/A -->

Environment

  • Platform that you're experiencing the issue on:
    • iOS
    • Android
    • iOS but have not tested behavior on Android
    • Android but have not tested behavior on iOS
    • Both
  • If known, the version of the platform are you experiencing the issue on:
    • iOS 12
  • Operating System:
    • MacOS, version: 10.14
    • Windows, version: N/A
    • Other, please specify: N/A
  • Build Tools:
    • Xcode 10
  • React Native version:
    • 0.57.4
  • React Native Firebase library version:
    • 5.1
  • Firebase module(s) you're using that has the issue:
    • N/A
    • Authentication
    • Analytics
    • Cloud Firestore
    • Cloud Messaging (FCM)
    • Crashlytics
    • Dynamic Links
    • Functions Callable
    • Invites
    • Instance ID
    • Notifications
    • Performance Monitoring
    • Realtime Database
    • Remote Config
    • Storage
  • Are you using TypeScript?
    • No
    • Yes, version: N/A
  • Are you using Expo, e.g. ExpoKit?
    • No
    • Yes, I've not ejected
    • Yes, but I have ejected to ExpoKit
    • Yes, but I have ejected to vanilla React Native
    • Expo version: N/A

Think react-native-firebase is great? Please consider supporting the project with any of the below:

@levani levani changed the title onAuthStateChanged not returning any result onAuthStateChanged not returning any result on iOS Sumulator Nov 11, 2018
@facuacostag
Copy link
Contributor

I'm having the same issue. The first time I run the app onAuthStateChanged is triggered properly, If I refresh once, it won't return anything but If I refresh again, It works. And If do it one more time, It happens again and so on.

@georgediaz88
Copy link

The same exact scenario is happening to me as outlined in the issue description and in @FacuAcosta 's comment. Same Firebase versions too.

@Ehesp
Copy link
Member

Ehesp commented Nov 12, 2018

Related? #1619

@Ehesp Ehesp added plugin: authentication Firebase Authentication help: needs-triage Issue needs additional investigation/triaging. labels Nov 13, 2018
@antoinerousseau
Copy link

happens to me too on iOS 12.1 simulator (RN 0.57.5, RNF 5.1.0)

onAuthStateChanged calls its callback every two reloads!

@Salakar
Copy link
Member

Salakar commented Nov 17, 2018

Is anyone having this issue on Android? Or is it just iOS?

Thanks

@xzilja
Copy link
Contributor

xzilja commented Nov 18, 2018

Happening to me on iOS as well after upgrading from 5.0 to 5.1, some additional info

Simulator (Debug)

  1. When I am not logged in at all it works every other reload (gets past initialisation stage)
  2. When I am logged in it works every time (perhaps from cache?) but if I trigger signOut it doesn't seem to trigger auth change, only after reloading

Physical Device (Release)
There seems to be an unusually long delay until onAuthChange is triggered / initialised, but it always works.

@ghsdh3409
Copy link
Contributor

ghsdh3409 commented Nov 20, 2018

For my case, the following code makes onAuthStateChanged broken.

firebase.auth().signOut().then(() => { CodePush.restartApp(false) });

I checked that iOS native callback addAuthStateDidChangeListener is triggered. But, in the sendJSEvent, emitter.bridge is null. This is the reason that JS onAuthStateChanged is not triggered.

ghsdh3409 added a commit to hayanmind/react-native-firebase that referenced this issue Nov 20, 2018
ghsdh3409 added a commit to hayanmind/react-native-firebase that referenced this issue Nov 20, 2018
@ghsdh3409
Copy link
Contributor

ghsdh3409 commented Nov 20, 2018

I make PR for this. Could you check if it resolves this issue?
You can install by modifying package.json like below.

"react-native-firebase": "git+https://github.com/hayanmind/react-native-firebase.git#1b5a9641383f1842d0a439109487c38903d1df2c"

@iljadaderko @levani

ghsdh3409 added a commit to hayanmind/react-native-firebase that referenced this issue Nov 20, 2018
@xzilja
Copy link
Contributor

xzilja commented Nov 20, 2018

@ghsdh3409 Yep, your fix works on my end 👍

@Salakar
Copy link
Member

Salakar commented Nov 20, 2018

@ghsdh3409 just looked at your change and it makes sense - will get your PR merged for a patch release 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help: needs-triage Issue needs additional investigation/triaging. plugin: authentication Firebase Authentication
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants