We are using remote config in our application, and since yesterday our remote value are not reflecting on apps it was working before. Due to this some of over feature breaks and produce crash.
FirebaseRemoteConfig mFirebaseRemoteConfig;
FirebaseRemoteConfigSettings configSettings;
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
mFirebaseRemoteConfig.setConfigSettings(configSettings);
mFirebaseRemoteConfig.setDefaults(R.xml.firebase_remote_config_defaults);
mFirebaseRemoteConfig.fetch(getCacheExpiration(mFirebaseRemoteConfig))
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
// If is successful, activated fetched
if (task.isSuccessful()) {
MyloLogger.e("FIREBASE_REMOTE_CONFIG", "CONFIG_FETCHED");
mFirebaseRemoteConfig.activateFetched();
setFirebaseConfigData(mFirebaseRemoteConfig, false);
} else {
MyloLogger.e("FIREBASE_REMOTE_CONFIG", "ERROR - KILLLLLL MMMMEEEE ");
}
}
});
setFirebaseConfigData(mFirebaseRemoteConfig, true);`
implementation 'com.google.firebase:firebase-config:16.1.3'
This code was working previously, and suddenly not responding.
This was solved, the problem with the A/B testing regex which is fail and not showing any error. I think Firebase should have some kind of process the errors over there.
Related
I'm trying to have a remote config parameter using the Remote Config feature of Firebase so I can get values from Firebase and use it in app. I already use it with no problem but after a Firebase update, I get this warning:
I tried to use getMinimumFetchIntervalInSeconds() instead of isDeveloperModeEnabled() in order to avoid the warning.
Here is my code:
final FirebaseRemoteConfig mFirebaseRemopteconfig = FirebaseRemoteConfig.getInstance();
long cachExpiration = 0;
if (mFirebaseRemopteconfig.getInfo().getConfigSettings().isDeveloperModeEnabled()) {
cachExpiration = 0;
}
mFirebaseRemopteconfig.fetch(cachExpiration)
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
final String funct = mFirebaseRemopteconfig.getString("functionn");
if (getPackageName().compareTo(funct) != 0) {
finish();
}
mFirebaseRemopteconfig.activateFetched();
}
}
});
Any idea how to solve this problem?
About setMinimumFetchIntervalInSeconds, it is officially said:
Keep in mind that this setting should be used for development only,
not for an app running in production. If you're just testing your app
with a small 10-person development team, you are unlikely to hit the
hourly service-side quota limits. But if you pushed your app out to
thousands of test users with a very low minimum fetch interval, your
app would probably hit this quota.
Although you can setMinimumFetchIntervalInSeconds other than the default value (= 12 hours), it's all up to you about whether it would hit the quota or not, and may lead to FirebaseRemoteConfigFetchThrottledException.
Now, the new API requires you to setMinimumFetchIntervalInSeconds for altering the interval. It is a method of FirebaseRemoteConfigSettings.Builder. So you must build a FirebaseRemoteConfigSettings object through the builder after setMinimumFetchIntervalInSeconds, and then setConfigSettingsAsync the built FirebaseRemoteConfigSettings to your FirebaseRemoteConfig.
Here is an example of my own implementation:
if (BuildConfig.DEBUG) {
cacheExpiration = 0;
} else {
cacheExpiration = 43200L; // 12 hours same as the default value
}
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings
.Builder()
.setMinimumFetchIntervalInSeconds(cacheExpiration)
.build();
config = FirebaseRemoteConfig.getInstance();
config.setConfigSettingsAsync(configSettings);
config.fetch(cacheExpiration).addOnCompleteListener(activity, onCompleteListener);
--------------------------- revised ---------------------------
For your porpose
checking if package name is the same
you don't need isDeveloperModeEnabled() or any interval settings. Just fetch() without any settings (but with default settings):
mFirebaseRemopteconfig = FirebaseRemoteConfig.getInstance();
mFirebaseRemopteconfig.fetch()
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
final String funct = mFirebaseRemopteconfig.getString("functionn");
if (getPackageName().compareTo(funct) != 0) {
finish();
}
mFirebaseRemopteconfig.activateFetched();
}
}
});
I'm trying to set up Firebase Remote Config for my project.
I added Firebase via the Assistant. I added values to the server values on Google Cloud Console:
I've created default values xml in res/xml
<defaultsMap>
<!-- Strings-->
<entry >
<key>textView_send_text</key>
<value >your phrase goes here.</value>
</entry>
</defaultsMap>
Thats my MainActivity:
final private FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
protected void onCreate(Bundle savedInstanceState) {
//..code..
//fetch from Firebase
fetchAll();
}
private void fetchAll(){
final FirebaseRemoteConfig mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
mFirebaseRemoteConfig.setConfigSettings(configSettings);
mFirebaseRemoteConfig.setDefaults(R.xml.defaults);
mFirebaseRemoteConfig.fetch()
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if(task.isSuccessful()){
Toast.makeText(MainActivity.this, "Fetch Succeeded",
Toast.LENGTH_SHORT).show();
mFirebaseRemoteConfig.activateFetched();
}else{
Toast.makeText(MainActivity.this, "Fetch Failed",
Toast.LENGTH_SHORT).show();
}
displayWelcomeMessage();
}
});
}
private void displayWelcomeMessage(){
String welcomeMessage = mFirebaseRemoteConfig.getString("textView_send_text");
Toast.makeText(this, welcomeMessage,
Toast.LENGTH_SHORT).show();
}
Toast output:
So Toast gets the value from xml/defaults not from the Cloud.
It'd be much appreciated if somebody found where I made a mistake.
For development testing, specify a cache expiration time of zero to force an immediate fetch:
mFirebaseRemoteConfig.fetch(0) // <- add the zero
.addOnCompleteListener(this, new OnCompleteListener<Void>() {
...
});
Some tips the helped to me:
Don't forget to click "publish changes" in Firebase console after each value update
Uninstall and install the App before checking (Firebase may not fetch immediately)
Use mFirebaseRemoteConfig.fetch(0)
For what it worth I found that our firebase remote configs weren't downloading no matter what we tried - we are usually debugging while connected to a proxy (like Charles Proxy) and that was interrupting the firebase cloud update.
Once we connected to a non-proxied wifi connection we got the update.
You can also set your config to developer mode if running a debug build which will refresh values more often - but the proxy was our root problem.
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(BuildConfig.DEBUG)
.build();
In Flutter, I just changed the value of minimumFetchInterval to const Duration(hours: 0). I manually added an message to firebase and here I just get it. Here is my code;
await Firebase.initializeApp();
RemoteConfig remoteConfig = RemoteConfig.instance;
await remoteConfig.setConfigSettings(RemoteConfigSettings(
fetchTimeout: const Duration(seconds: 10),
minimumFetchInterval: const Duration(hours: 0),
));
RemoteConfigValue(null, ValueSource.valueStatic);
bool updated = await remoteConfig.fetchAndActivate();
if (updated) {
print("it is updated");
} else {
print("it is not updated");
}
print('my_message ${remoteConfig.getString('my_message')}');
Make sure your mFirebaseRemoteConfig.fetch() called only once. It gets throttled if you call it multiple times.
There is a default minimum time duration Intervals for firebase remote config fetching. According to the Firebase documentation, it is now 12 hours. During that default time interval gap, if you change the keys from Firebase remote config and if you don't uninstall the app, you don't get updated data. you will get updated data after passing default time intervals. If you need more frequent data changes, you can override fetch intervals from client side.
mFirebaseRemoteConfig.fetch(0)
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
System.out.println("Fetch Succeeded");
// Once the config is successfully fetched it must be
// values are returned.
mFirebaseRemoteConfig.activateFetched();
} else {
System.out.println("Fetch failed");
}
}
});
I added this to get the remote config from the server. I was able to get the values a couple of times. I updated the remote config conditions after that and now fetch doesnt return anything. Tried a lot of approaches including moving the call after on onResume and calling it from a separate thread. Updating to 9.2.1 also didnt worked for me
What else can be done to get the config?
I'm trying to setup firebase remote config for release mode by setting developer mode to false. But with cache expiration time less then 3000(may be a bit less, determined it experimentally) seconds, it fails to fetch data. It throws FirebaseRemoteConfigFetchThrottledException
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(false)
.build();
And with .setDeveloperModeEnabled(true) it allows me to set any time even 0 and works well.
Here is whole hunk:
new Handler().postDelayed(new Runnable() {
#Override
public void run() {
mFirebaseRemoteConfig = FirebaseRemoteConfig.getInstance();
FirebaseRemoteConfigSettings configSettings = new FirebaseRemoteConfigSettings.Builder()
.setDeveloperModeEnabled(false)
.build();
mFirebaseRemoteConfig.setConfigSettings(configSettings);
mFirebaseRemoteConfig.setDefaults(R.xml.remote_config_defaults);
mFirebaseRemoteConfig.fetch(CACHE_EXPIRATION)
.addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
Log.i("info32", "remote config succeeded");
mFirebaseRemoteConfig.activateFetched();
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception exception) {
Log.i("info32", "remote config failed");
}
});
}
}, 0);
Could you please explain what the issue is?
Remote Config implements client-side throttling to prevent buggy or malicious clients from blasting the Firebase servers with high frequency fetch requests. One user has reported the limit is five requests per hour. I haven't found the limit documented anywhere, although I have confirmed that five rapid fetches will activate throttling.
The caching of configuration values is explained in the documentation. Because of the throttling limits, it is not possible for your released app to immediately see changes in Remote Config values. Cached values will be used until the next fetch is allowed. The default cache expiration is 12 hours.
I have recently switched to the new firebase. When I was using the legacy code I was able to reset the users email with no problem. Now with the new firebase I keep getting the error "An internal error has occurred. [ Error code: 13 ]". Even when I hit the password reset button on my app console I get the same error message on the console. I also followed all the instructions from the site on how to reset the users password.
Here is my code:
private void resetPassword() {
String email = mEmailEditText.getText().toString();
FirebaseAuth auth = FirebaseAuth.getInstance();
auth.sendPasswordResetEmail(email)
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
if (task.isSuccessful()) {
Toast.makeText(LoginActivity.this, R.string.sent_temp_password,
Toast.LENGTH_LONG).show();
}
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Log.i(TAG, e.getMessage());
}
});
}
Any help as to why this is occurring would be greatly appreciated!
I have also recently switched to the new Firebase console. I had many problems with authentication and I couldn't find any solutions. I backed up on a file the database and the rules, then I deleted the Firebase project and created a new one (from scratch, recreated the Firebase project, except for the database and the rules that I saved in advance). It worked. I guess there are many problems with converting a Firebase project from the old console to the new Firebase console.
If you don't find any other solution I recommend you do the same, it doesn't take too long.
In the new Firebase version, before any significant change in any user ( change the user's password or email, or delete the user) , the user must have signed in recently. so in order to guarantee a valid response you need to use the reauthenticate method before calling the change method...
FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
// Get auth credentials from the user for re-authentication. The example below shows
// email and password credentials but there are multiple possible providers,
// such as GoogleAuthProvider or FacebookAuthProvider.
AuthCredential credential = EmailAuthProvider
.getCredential("user#example.com", "password1234");
// Prompt the user to re-provide their sign-in credentials
user.reauthenticate(credential)
.addOnCompleteListener(new OnCompleteListener<Void>() {
#Override
public void onComplete(#NonNull Task<Void> task) {
Log.d(TAG, "User re-authenticated.");
//Here you can can insert your code
}
});
Just to clarify on my situation which is similar. This happens to all users. I don't have much dedicated to this database. Rebuilding, and will get back, but it's weird it was able to authenticate previously. Mind you I am not coming from an old firebase console to a new one. This project is a fresh new console.