-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Multi-App Realtime Database Use on Android doesn't seem to be working. #1160
Comments
This appears to of occurred in the commit cc8799b which adds support for So the previously suggested fix is likely not sufficient. Instead a better solution would be to transform the function to use a different Instead, the easiest solution that should support both would be to change the public static FirebaseDatabase getDatabaseForApp(String appName, String dbURL) {
FirebaseApp firebaseApp = FirebaseApp.getInstance(appName);
FirebaseDatabase firebaseDatabase;
if(dbURL != null && dbURL.length() > 0) {
firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp, dbURL);
} else {
firebaseDatabase = FirebaseDatabase.getInstance(firebaseApp);
}
... Assuming that the Please let me know if you have any questions, or if there's something more I can offer. Thanks, ~ Ayiga |
Created a pull request for this issue here: #1193 |
#1193 merged - should fix Android iOS still to be fixed. Will take a look or PR's welcome. |
@Salakar I don't believe this affects Based on the code in the initial commit, Please let me know if you have any questions, Thanks, ~ Ayiga |
@Ayiga you're right, iOS is setup correctly, will close this issue as Android has been fixed pending release. |
Issue
Greetings,
It seems as though using a secondary app on the
Android
platform causes anyreal-time database
request to fail. Any callbacks used for anyon
, oronce
query do not seem to resolve.Example snippet:
Looking through the code, the primary reason for this behavior on the
Android
side is due to how thedatabase
Object
is retrieved by thenative
side. When adatabase
Object
is retrieved there is logic that prefers to instantiate thedatabase
Object
via thedatabase
URL
(dbURL
) itself. As a result, the resultingdatabase
Object
is associated with the"[DEFAULT]"
app instead of the second app.The resulting
RNFirebaseDatabaseReference
has the correctappName
,dbURL
, andpath
internally, but thedatabase
Object
is associated with the wrongapp
.If I were to comment out the conditional, and always fall into the
else
case instead, I get thedatabase
Object
with the correctly associated app instead. In this case, all of the queries made end up with results.The easiest solution I can think of is to remove the conditional. However, in doing so
dbURL
is no longer used within thestatic
function
. So it may be necessary to review the reasons for having it there, and if perhaps the underlying function's (FirebaseDatabase.getInstance
) behavior has changed or something.Please let me know if you have any questions, or if you need me to provide any more details,
Thanks,
~ Ayiga
Environment
Android
macOS High Sierra
System: MacBook Pro (15-inch, 2017)
Version: 10.13.4 (17E202)
Processor: 2.8 GHz Intel Core i7
Android Studio 3.1.2
Build #AI-173.4720617, built on April 13, 2018
JRE: 1.8.0_152-release-1024-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.13.4
react-native@^0.55.4
react-native-firebase@^4.2.0
(I believe this issue may have been introduced with version 4.0.0)
database
The text was updated successfully, but these errors were encountered: