I want to use TWO Firebase Analytics for one single app, one single code.
Project 1: Firebase Analytics Test Project
Project 2: Firebase Analytics Prod Project
How can I add two google-services.json file in one single project. Is there any other way to use the same.
Analytics works with only 1 Google App ID in your GoogleService-Info.plist. There is no way to send traffic to both projects. I'd recommend to have 2 separate projects for test and release versions. It's not recommended to mix up Test data with Production data as it is confusing and Production data may not reflect the real behaviors if test data is in it. For example, if you run Test app every night by installing and uninstalling, it may appear that you have a new user every day in your production app.
One thing you can do is having a GoogleService-Info.plist for the release but use the run-time APIs to use the custom FIROptions
-[FIROptions initWithContentsOfFile:(NSString *)plistPath]
where plistPath is the path to the custom GoogleService-Info.plist, say CustomGoogleService-Info.plist. Or
- (instancetype)initWithGoogleAppID:(NSString *)googleAppID
bundleID:(NSString *)bundleID
GCMSenderID:(NSString *)GCMSenderID
APIKey:(NSString *)APIKey
clientID:(NSString *)clientID
trackingID:(NSString *)trackingID
androidClientID:(NSString *)androidClientID
databaseURL:(NSString *)databaseURL
storageBucket:(NSString *)storageBucket
deepLinkURLScheme:(NSString *)deepLinkURLScheme;
In this way, you can put it under the compiler flag for testing version. In the release, the compiler flag will remove that line and use the correct GoogleService-Info.plist for the release version.
For example:
#ifdef TESTING
FIROptions *options = [[FIROptions alloc] initWithContentsOfFile:pathToCustomPlist];
[FIRApp configureWithOptions:options];
#endif // TESTING
Related
I'm trying to setup multiple environments for my Vue / Firebase Project.
I have two Firebase Projects
1.) Dev
2.) Prod
The project utilizes Stripe Extension which pulls the API Key from an auto-generated file called:
firestore-stripe-payments.env
which contains:
STRIPE_API_KEY=projects/${param:PROJECT_NUMBER}/secrets/firestore-stripe-payments-STRIPE_API_KEY-xxxx/versions/latest
Where xxxx is a random 4 character string.
That line pulls the value of the key from Google Secret Manager.
Let's say Dev is 'dddd'
and Prod is: 'pppp'
The issue is that I can only define either:
firestore-stripe-payments-STRIPE_API_KEY-dddd
or
firestore-stripe-payments-STRIPE_API_KEY-pppp
At first I tried to create a new value within Google Secret Manager simply called:
firestore-stripe-payments-STRIPE_API_KEY
The thought was this should be a simple fix, and it would pull the associated API_KEY for the project currently being used.
but this causes the error:
Error: firestore-stripe-payments: Found 'projects/foo/secrets/firestore-stripe-payments-STRIPE_API_KEY/versions/latest' for secret param STRIPE_API_KEY, but this instance was previously using a different secret projects/fooo/secrets/firestore-stripe-payments-STRIPE_API_KEY-dddd.
Changing secrets is not supported. If you want to change the value of this secret, use a new version of projects/foo/secrets/firestore-stripe-payments-STRIPE_API_KEY-dddd.You can create a new version at https://console.cloud.google.com/security/secret-manager?project=fooo
Also, if there is a better place to ask this question please let me know, couldn't find the 'right' room
For this scenario, could you include a separate env (env.dev) file using the following guidelines
.env # loaded in all cases
.env.local # loaded in all cases, ignored by git
.env.[mode] # only loaded in specified mode
.env.[mode].local
For generating separate keys for each environment, I believe from your example you are using a single Stripe Extension on a single project.
Firebase Extensions can support multiple instances of an Extension per project, this will create a separate "dev" secret for you to use.
Additionally, a separate Firebase project with another "Stripe Extension" installation would be recommended to separate any concerns in development.
I have a single .NET Core .proj file and a single Google Cloud project. The .NET Core project is very simple with a single class implementing IHttpFunction and implementing HandleAsync which is the entrypoint. I have a Cloud Build trigger connected to this project's Git repository which is set to run whenever a commit is pushed into main.
I would like to have more functions-- and hoping to not duplicate common functionality between them -- add those functions to the same project. But when I have multiple classes implementing IHttpFunction, Cloud Build fails.
I think there are at least 2 other ways to do this:
Deploy manually and select a function - but can I do this with Cloud Build triggers too?
Have all functions go through a single "dispatcher" endpoint - which seems messy
What's a good way to do this?
I have created a composite project to test rest api using ready api tool and commited to git. Then someone imports that project from git, some api endpoints missed under api section, also some test steps missed under test cases. Here, once I added endpoints under APIs, i renamed services and gave the refering test suite name or meaning full name.
https://support.smartbear.com/readyapi/docs/_images/apis/organize/rest-structure.png
I noticed that if I use the same for in both locations, that means test suite name and service, this error happens. How could I solve this problem?. Because I have already developed this project.
You might want to change the names to a different one instead of using the same in both location and do ensure that you SAVE your entire project before committing to GitHub.
i am trying to deploy my project on firebase hosting. And whenever i am using firebase init it is showing error in terminal as "firebaserc already has a default project " and it exit with that error
i have tried firebase logout and firebase login again . And used "firebase use" command also to change the project but it is still performing the firebase init action on the default project
i want to remove that default project
If you look very carefully at the messaging, it's saying that the name of the file is ".firebaserc" with a leading dot. This file indicates that firebase init was already run in this folder, and the contents of that file describe which project it's connected to (flairboat-48f7b). If you no longer want that file, delete it and start over. Since it starts with a dot, it might be hidden from normal view, but you can be sure that it exists.
you should write:
firebase use --add
and it work! You get the option to choose the preject from firebase.
I ran into the same issue.
Due to a small mistake in setting up the project in firebase, I had to delete it.
But later, I realized that my application NEEDS the default project to be hosted from firebase.
Since I found no shortcuts and running out of time, I did "this" to fix the issue in 10 minutes...with a 5-Step-Process. This is not a "Clever tip". But if you want things up and running soon, you can try this...
Create a new project (in my case, it's React project in VS Code IDE) using - npx create-react-app newprojectname to create a new react project with a different file name.(Don't delete or replace your previous project yet... )
While the new project is being created, create a new project in firebase to host your project.
Copy the folder from your old project that has all your work (it's "src" folder in case of React) and replace the "src" folder in the new project you created in your local machine.
Install all dependencies...Don't forget to add any dependencies you added to you old project. Look at the package.json file of the old project and import all dependencies.
Hit the start command (npm start in my case) and see your project running.
*I'll update if I found some firebase secret to resolve this issue. You can look for the same.
Ensure your firebase project support email and firebase initialize login email are same. If different? It won't be worked. so you must ensure it that two email (firebase project support email and firebase initialize email) are same.
I am trying to figure out how to set up different firebase environments in a flutter project.
I understand how to do this in firebase, I created two projects, one for production, one for the test. Then, in an iOS or Android project, I could use various methods to switch between these two environments using separate google-services.json or GoogleServices-Info.plist files.
In Flutter I found this description of how to separate environments, but it only explains how to differentiate between environments in the flutter code.
How can I get this environment to change what iOS and Android build at compile time? It would even be sufficient simply to allow a file copy hook at build time.
You can switch accounts using FirebaseApp.configure. You can offer your own solution or secret dev panel to switch between them.
The solutions will build flavours and plist implementations will lock you into builds when you deploy for TestFlight + they are messy.
Here's an example: (You could use Assets as well.)
// Load a named file.
let filePath = Bundle.main.path(forResource: "MyGoogleService", ofType: "plist")
guard let fileopts = FirebaseOptions(contentsOfFile: filePath!)
else { assert(false, "Couldn't load config file") }
FirebaseApp.configure(options: fileopts)
I wrote an article about how to do this for Firebase configuration as well as runtime configuration in dart code using flavors and platform channels.
https://medium.com/#matt.goodson.business/separating-build-environment-configurations-in-flutter-with-firebase-doing-it-the-right-way-c72c3ad3621f
Flutter flavors work pretty seamlessly with Android flavors. For iOS you need to create Xcode schemes for each flavor and link them to build configurations.
For dart configuration, you can use platform channels to get the flavor used during the build at runtime. This lets you configure the app without having multiple main.dart files or passing a target argument.
Salvatore Giordano has written a blog post with a detailed description of how to achieve this:
https://medium.com/#salvatoregiordanoo/flavoring-flutter-392aaa875f36
Flutter accepts a parameter --flavor=<flavor> which allows you to select different build flavors. In Android this works as expected, selecting different build flavors. IOS is a little tricker because a scheme is needed for every flavor, and the build configurations in the form of Release-<flavor> are also needed.
Once these parts are in place, they can be used, to select the firebase configuration as you would in any iOS or Android project.
The challenge is getting Dart code to also be aware of the flavor, and the blog post provides no good solution for this. It suggests the standard method of using different entry points can be used, but the correct entry point must be matched to the correct flavor manually by the person invoking the app.
Specifically to Firebase env config you can use this article and this article from CodeMagic which explains how you can set up plist files with build env variables.
If you need to have a different set of values inside your Dart code, like an option you can use this package. It allows to generate Dart class config file from console command params.
Update 12/05/2020
Since Flutter 1.17 you can actually use compile-time variables with --dart-define argument in flutter run and flutter build commands
Here is an article that describes how to specify and use them.
With the release of Flutter for Web to the stable channel, I put together instructions for targeting multiple firebase projects (e.g. dev, staging, prod) from multiple build platforms (i.e. iOS, Android, and Web).