After writing more than 2 entries into the database. Trying to do so again after more than 70 seconds - just nothing happens.
It is necessary to delete the FirebaseApp and reinitilize it again to be able to write.
What can be the problem here?
const configMB = FirebaseOptions(
apiKey: 'XXXX-XXXXXX-VpFyS3bbNo',
authDomain: 'XXXX-XXX.firebaseapp.com',
projectId: 'XXX-XXX',
messagingSenderId: 'XXXXXXXX',
databaseURL: 'https://XXX-XXX.firebaseio.com',
storageBucket: 'XXX-XXXX',
appId: '1:XXXX:ios:442813749dccf0d1');
class TKDatabase {
static Future<void> configureDatabases() async {
FirebaseDart.setup();
await Firebase.initializeApp(name: "mb", options: configMB);
}
static Future<void> reinitialize() async {
await Firebase.app("mb").delete();
await Firebase.initializeApp(name: "mb", options: configMB);
}
static FirebaseDatabase mb() => FirebaseDatabase(app: Firebase.app("mb"));
}
void main(List<String> arguments) async {
await TKDatabase.configureDatabases();
log('✅ Firebase Database connected.');
// FAILING TEST
TKDatabase.mb().reference().child('test/a').set({'test': 'test123'});
TKDatabase.mb().reference().child('test/a').set({'test': 'test1234'});
Timer.periodic(Duration(seconds: 70), (_) async {
log('The following write is just IGNORED');
TKDatabase.mb().reference().child('appconfig/test').set('test');
});
// SUCCESSFUL TEST
Timer.periodic(Duration(seconds: 70), (_) async {
log('The following workaround works...');
await TKDatabase.reinitialize();
TKDatabase.mb().reference().child('appconfig/test').set('test');
});
}