App version up with Firebase Remote Config
Firebase Remote Config can change the app setting very easy.
Firebase A/B test is also effective, and it is an excellent thing that you can remotely change the setting and take the data further by A/B test with Firebase.
I introduce to show App version app Dialog with Firebase Remote config.
Setting
First we will introduce the following package.
Edit pubspec.yml
dependencies:
flutter:
sdk: flutter
flutter_localizations:
sdk: flutter
firebase_remote_config: ^0.0.6+1
Then, execute this command.
flutter packages get
Implementation
Setting Remote Config, Where Firebase console.
The key name `ios_app_version` is the version of the current application. If it differs from this version, it will be an implementation that issues an update dialog.
_checkAppVersion() async {
final RemoteConfig remoteConfig = await RemoteConfig.instance;
MethodChannel platform =
const MethodChannel(MethodChannelString.appVersion);
String appVersion;
try {
appVersion = await platform.invokeMethod("getAppVersion");
} on PlatformException catch (e) {
return;
}
if (Platform.isIOS) {
try {
final defaults = <String, dynamic>{'ios_app_version': appVersion};
await remoteConfig.setDefaults(defaults);
await remoteConfig.fetch();
await remoteConfig.activateFetched();
if (appVersion != remoteConfig.getString('ios_app_version')) {
_showIosUpdateAppDialog();
}
} catch (e) {
print(e.toString());
}
}
}
In this implementation only iOS, but let’s put on another dialog on Android as well.
Follow
Please follow this Twitter. I am posting it in Japanese, but please translate it and read it.