Skip to content

Commit

Permalink
Merge pull request #13 from m1ga/master
Browse files Browse the repository at this point in the history
Android: Prevent error when initializing second time
  • Loading branch information
hansemannn authored Apr 19, 2018
2 parents 07d3c8c + 4317544 commit becad1f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
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) {
Log.w(LCAT, "There was a problem initializing FirebaseApp or it was initialized a second time.");
}
} else {
FirebaseApp.initializeApp(getActivity().getApplicationContext());
try {
FirebaseApp.initializeApp(getActivity().getApplicationContext());
} catch (IllegalStateException e) {
Log.w(LCAT, "There was a problem initializing FirebaseApp or it was initialized a second time.");
}
}
}
}

0 comments on commit becad1f

Please sign in to comment.