How to get updated remote config values after setting user properties - firebase

I'm currently running an A/B test on a remote config value in Firebase. The target of the test is for users with a user property X that is contained in a regex.
My problem is that I fetch the remote configs for the user BEFORE setting the user property, so I need to update the remote config when the user property is set. So basically, a force update of a remote config (that is updated because the user is now part of the AB test).
Any ideas?

This article will help you.
Force your users to update your app with using firebase
This code will set app to fetch every minutes.
firebaseRemoteConfig.fetch(60)
But this method does not force update app.
So, I suggest you to all server APIs implement the functionality to do version checking. For example, if your app version was updated, all of APIs will return "You need to update your app" error.

Be careful with Firebase updates on both: iOS and Android. You can read more about it here: https://medium.com/#elye.project/be-careful-when-using-firebase-remote-config-control-for-pre-announced-feature-52f6dd4ecc18
On iOS config can be force updated with following code:
config.fetch(withExpirationDuration: 0, completionHandler: fetchCompletion)

Related

How to set up Firebase Cloud Messaging via APNs using an already registered bundle identifier?

The docs for setting up FCM via APNs state that you should copy the bundle identifier from your application (under the "Registering an App Identifier") section, but when I do that I get the following error when trying to register my new app id:
An attribute in the provided entity has invalid value
An App ID with Identifier '<my app id copied from xcode>' is not
available. Please enter a different string.
The error message does make sense because that app id is already taken (by my app).
Are the Firebase docs wrong or am I missing something?
I think you can check the followings.
make sure if you have already checked an option for push notification on app store. go to developer.apple.com/account/resources/identifiers/list, choose your identifier in the list.
open your project in Xcode. and check like the below screenshot

How to get firebase App Check working with cloud firestore in a web app

I try to get App Check working in my vue.js pwa. Using the latest firebase sdk and by following steps here https://firebase.google.com/docs/app-check/web/recaptcha-provider
My api key (https://console.cloud.google.com/apis/credentials/key..) is not limited to any API restrictions. I did add some Application Restrictions on https tho including my project domains.
Everything works fine till i activate appCheck with recaptcha v3 and i get following console errors:
FirebaseError: [code=unknown]: Fetching auth token failed: AppCheck: Fetch server returned an HTTP error status. HTTP status: 403. (appCheck/fetch-status-error)
Further more the app can't get any firebase data or auth. I tried in several browsers and without any vpn stuff.
In my already installed pwa the App Check error occurs but connection to firebase still works..
Without App Check activated it both works without an issue. Also with an App Check debug token the whole thing just works. I don't understand why it breaks firebase connection even if i haven't enabled enforcement.
I appreciate any tips on how to solve this.
I found the problem i accidently left self.FIREBASE_APPCHECK_DEBUG_TOKEN = true; in my production code.
Remove this line or only use when in development envirement solved the whole problem
if (location.hostname === "localhost") {
self.FIREBASE_APPCHECK_DEBUG_TOKEN = true;
}
I didn't expect this line to impact browsers where i haven't registered a debug token to fail with the regular appCheck but of course it doesn't make sense to use it in production anyways.
Based on your question, you want to enable Firebase App Check for Firestore with Web Application. Currently, Firestore App Check does not support it.
As per this Documentation:
Cloud Firestore support is currently available only for Android and iOS clients. If your project has a web app, don't enable Cloud Firestore enforcement until web client support is available.
I'll leave an answer for people who have problems with the setup. For the more detailed answer, you can check this question.
In short, you need to do a few steps.
Set up a firebase.
Go to how to set up app check.
Register reCAPTCHA here and add the secret_key to the Firebase console, and the site_key to your web code.
Initialize the Firebase in your code based on how to set up app check docs.
Get your debug_key and add it to your firebase console and code.
Finally, the code should look something like this:
Don't forget to save your key to a .env file or firebase.js or somewhere where you won't upload it to git.
if (!process.env.NODE_ENV || process.env.NODE_ENV === 'development') {
window.FIREBASE_APPCHECK_DEBUG_TOKEN = 'your_debug_token';
}
const appCheck = initializeAppCheck(app, {
provider: new ReCaptchaV3Provider('your_site_key_from_register'),
// Optional argument. If true, the SDK automatically refreshes App Check
// tokens as needed.
isTokenAutoRefreshEnabled: true
});

Firestore and data encryption in Flutter

Tl;dr.. I'm making a todo app where I store data in Firestore, and I don't want anyone to see it not even the devs from firebase console. I found many encryption pkgs that do the job, like: encrypt. My problem is how to I handle the 'encryption key'. I don't want to keep it local because in my app user can access it's account from different devices, so if the key is stored locally they cannot decrypt thus retrieve their data (notes) from the other device (i hope this makes sense). So, do I send the 'encryption key' to firestore in a seperate collection or ... how should I approache this ?
You could store the key with Firebase Remote Config and retrieve it in the app when you need it.
Firebase Remote Config is a cloud service that lets you change the
behavior and appearance of your app without requiring users to
download an app update. When using Remote Config, you create in-app
default values that control the behavior and appearance of your app.
Then, you can later use the Firebase console or the Remote Config
backend APIs to override in-app default values for all app users or
for segments of your user base.
Check out the documentation for the flutter_remote_config plugin.

Firebase Remote Config & A/B Testing with real time updates

I've implemented real time remote config updates via the documentation here.
In general, it works as expected, except when it comes to experiments via A/B Testing. Changes to A/B Testing that affect remote config do not fire the update cloud function hook.
Does anyone know if its possible to have the functions.remoteConfig.onUpdate cloud function hook trigger when a change to remote config is made via an A/B Testing experiment change?
The only workaround I can think of is to have a dummy value in remote config itself that I change whenever an experiment is created/updated.
firebaser here
There is nothing built into Remote Config for that at the moment. But thanks to the integration between Cloud Functions and Remote Config, you can build it yourself.
One of our engineers actually just gave a demo for this last week. I recommend you check it out here: https://youtu.be/lIzQJC21uus?t=3351.
In this demo, there are a few steps:
You publish a change from the Remote Config console.
This change triggers Cloud Functions through a functions.remoteConfig.onUpdate event.
The Cloud Function sends an FCM message to all apps through a topic.
When an app receives this message, it shows a prompt that the configuration is out of date.
When the user clicks the "fetch" button, the app fetches the new configuration data from Remote Config.

Do we need to wait or flush user events or property before fetching remote config in Firebase?

Do we need to wait or flush user events or property before fetching remote config in Firebase in order to get the correct one?
Here's my setup:
I have two apps that shares the same Firebase app. The reason they share the same app is that I need to track conversion between the two apps, and can't find any better way!?
So I've created a User Propery, "Is_Lite_Version", and will create an AB for a remote config.
On launch, the app will both set the User Propery and fetch remote config.
My question is, could there be a problem here, due to latency? Where the remote config is fetch before the User Propery has been set, and then not getting the correct value?
Thanks in advance

Resources