-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Using FirebaseApp.delete() results in unusable Messaging singleton #3411
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
Comments
IIRC this has never been an officially supported use case, though we also don't explicitly label |
Our use case is to have production, staging and sandbox environments for Firebase, with an in-app option to toggle between these environments for debug builds. |
I have managed to workaround this and get it working again, but it's very hacky. When we switch environments we do this:
|
This fixes #3411. Test fails before the code change, and succeeds afterwards.
Thanks @cooksimo for the detailed write-up and investigation into what the cause was! |
Is it intended not taking the delegate into account by recreating the Messaging singleton after a FirebaseApp is deleted and recreated?
|
Describe your environment
Describe the problem
We have several projects set up, representing different environments for remote config. We use Messaging to enable real time remote config updates. When a user switches the firebase environment within the app, we delete the default app, and attempt to recreate it.
Once this has been done any interaction with Messaging will not work. We have encountered this because we were running a very old version of Firebase (4.13.0) & Messaging (2.2.0) and we're trying to update to the latest. This approach worked in those versions.
This problem looks to be in the implementation of
messaging()
, there is adispatch_once
block to actually set everything up, this doesn't make sense if the singleton object can actually be deallocated and recreated.I have attempted to solve this by calling
start
manually, and this seems to fix some things, but the new Messaging instance never gets notified of thefcmToken
being available so cannot subscribe to anything.The text was updated successfully, but these errors were encountered: