firebase / firebase-cpp-sdk

Firebase C++ SDK
http://firebase.google.com
Apache License 2.0
277 stars 115 forks source link

[FR] Able to create firebase::AppOptions using a path to config file #114

Open nemupm opened 4 years ago

nemupm commented 4 years ago

Is there any way to load configs from GoogleService-Info.plist for multi projects?

Firebase's docs says

If the builds are part of a single target, the best option is to give both configuration files unique names (e.g. GoogleService-Info-Free.plist and GoogleService-Info-Paid.plist). Then choose at runtime which plist to load. at https://firebase.google.com/docs/projects/multiprojects

but firebase cpp sdk supports only json and we cannot download json for ios, so it seems we have to generate json manually, set each properties by setter or replace plist by shell script.

google-oss-bot commented 4 years ago

This issue does not seem to follow the issue template. Make sure you provide all the required information.

chkuang-g commented 4 years ago

@nemupm

I am pretty sure our Firebase C++ SDK supports GoogleServices-Info.plist. Have you tried the instructions in our C++ quickstart? Remote config testapp here for example.

Currently C++ SDK does not have API to load config from a file like iOS SDK. However, you should still be able to create FirebaseApp with given ApiKey, AppId and ProjectId, like the example here.

Let us know if this works for you. If not, please describe your concern.

Shawn

google-oss-bot commented 4 years ago

Hey @nemupm. We need more information to resolve this issue but there hasn't been an update in 5 weekdays. I'm marking the issue as stale and if there are no new updates in the next 5 days I will close it automatically.

If you have more information that will help us get to the bottom of this, just add a comment!

nemupm commented 4 years ago

@chkuang-g Thanks for your reply!

Currently C++ SDK does not have API to load config from a file like iOS SDK. However, you should still be able to create FirebaseApp with given ApiKey, AppId and ProjectId, like the example here.

Yes, I understand that, but I think it is easier to load from plist.

But, I've resolved the problem by the following script in the build phases, so it is ok to close the issue.

origin_plist="${PROJECT_DIR}/plists/firebase/GoogleService-Info-${PRODUCT_BUNDLE_IDENTIFIER}.plist"
if [ -f "${origin_plist}" ]; then
  cp "${origin_plist}" "${BUILT_PRODUCTS_DIR}/${PRODUCT_NAME}.app/GoogleService-Info.plist"
fi
chkuang-g commented 4 years ago

Hmm...I think this is a valid feature request.

iOS has API to load AppOption given a path. https://firebase.google.com/docs/reference/swift/firebasecore/api/reference/Classes/FirebaseOptions#/c:objc(cs)FIROptions(im)initWithContentsOfFile:

Android only have API to load AppOption from a string resource, but not from a path. https://firebase.google.com/docs/reference/android/com/google/firebase/FirebaseOptions#public-static-firebaseoptions-fromresource-context-context

To implement this feature, we will need to figure out the equivalent API in Android SDK side so that C++ SDK can wrap them properly.

I'll keep this as a feature request. Also your workaround is valuable for others in your situation as well.

Please up-vote this feature if this is consider critical to your team.

Thank you for reporting this.