this.firebase.getValue('CONTACT_DATA', '')
.then((data) => {
console.log('CONTACT_DATA.....', data);
});
I am having an issue with the above code when running on android. I have my CONTACT_DATA set in the firebase console. I am running fetch() and activateFetched() as well. When I run on iOS, the above data (the remote config value that I set in the firebase console) is logged out as expected. However on android, no data is logged out. The string 'CONTACT_DATA' from above is logged out, but no remote config value.
It's working for me. Try like this
window.FirebasePlugin.fetch(600, function () {
window.FirebasePlugin.activateFetched(function (activated) {
window.FirebasePlugin.getValue(YOUR_KEY, function (value) {
alert("FirebasePlugin.getValue " + value);
}, function (error) {
console.log("FirebasePlugin.getValue error " + error);
});
}, function (error) {
console.error(error);
});
});
Yeah, I got it to work as well. I was trying to use the ionic wrapper initially, but there seems to be an issue with that. Once I used the plugin straight up, it worked as expected. Thanks.
Has anyone got this to work on iOS? I tried that code but always receive null. I'm using Ionic as well.
@bytekode Why new function () {} vs. function() {}?
@rockrgrrl, can you please share you code that worked in Ionic?
@remisture LOL! It's because I write JAVA code a lot. UPDATED!
@samarthagarwal Sure. Here it is:
window['FirebasePlugin'].fetch(3600, (result) => {
window['FirebasePlugin'].activateFetched((activated) => {
// do something here
}, (error) => {
const message = 'There was an error getting the contacts.';
const toast = this.toastCtrl.create({
message: message,
duration: 3000,
cssClass: 'toast-danger',
});
toast.present();
});
}, (error) => {
const message = 'There was an error getting the contacts.';
const toast = this.toastCtrl.create({
message: message,
duration: 3000,
cssClass: 'toast-danger',
});
toast.present();
});
Same bug here. Thank you rockrgrrl for the solution its working for me.
In order for the getValue function to work properly you are required to set a default value see firebase loading strategies => https://firebase.googleblog.com/2017/01/firebase-remote-config-loading.html
closing for now, reopen if still an issue with the latest version of the plugin
@Thomasbehan I tried setting default values using the setDefaults API. Still does not work. So I think there is an issue with the firebase-native implementation.
this.firebase.setDefaults( {
projectId: 'DefaultProject'
}).then( () => {
alert("Default set")
this.firebase.fetch(60).then(() => {
this.firebase.activateFetched().then((value) => {
alert('Activated' + value)
this.firebase.getValue('projectId').then((proj) => {
alert('proj' + proj)
})
.catch((err) => {
alert('getvalue err' + err)
})
})
.catch((error2) => {
alert('activation error' + JSON.stringify(error2));
});
}
);
});
I get success for setDefaults and nothing afterwards. On the other hand, following this and other issues, it is possible to fetch the remote config without the native plugin implementation as mentioned by @rockrgrrl
Most helpful comment
@samarthagarwal Sure. Here it is: