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

Android: Prevent error when initializing second time #13

Merged
merged 2 commits into from
Apr 19, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion android/manifest
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# this is your module manifest and used by Titanium
# during compilation, packaging, distribution, etc.
#
version: 2.0.0
version: 2.0.1
apiversion: 4
architectures: arm64-v8a armeabi-v7a x86
description: titanium-firebase-core
Expand Down
14 changes: 11 additions & 3 deletions android/src/firebase/core/TitaniumFirebaseCoreModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public TitaniumFirebaseCoreModule()
}

// Public APIs

@Kroll.method
public void configure(@Kroll.argument(optional=true)KrollDict param)
{
Expand All @@ -55,9 +55,17 @@ public void configure(@Kroll.argument(optional=true)KrollDict param)
if (param.containsKey("GCMSenderID")) {
options.setGcmSenderId(param.getString("GCMSenderID"));
}
FirebaseApp.initializeApp(getActivity().getApplicationContext(), options.build());
try {
FirebaseApp.initializeApp(getActivity().getApplicationContext(), options.build());
} catch (IllegalStateException e) {
// error or already initialized
}
} else {
FirebaseApp.initializeApp(getActivity().getApplicationContext());
try {
FirebaseApp.initializeApp(getActivity().getApplicationContext());
} catch (IllegalStateException e) {
// error or already initialized
}
}
}
}