「Flutter/firebase/RemoteConfig」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→サンプル) |
|||
行41: | 行41: | ||
await remoteConfig.setDefaults(defaults); | await remoteConfig.setDefaults(defaults); | ||
await remoteConfig.setConfigSettings(RemoteConfigSettings(debugMode: true)); // developer_mode | await remoteConfig.setConfigSettings(RemoteConfigSettings(debugMode: true)); // developer_mode | ||
− | await remoteConfig.fetch(expiration: const Duration( | + | await remoteConfig.fetch(expiration: const Duration(seconds: 720)); |
await remoteConfig.activateFetched(); | await remoteConfig.activateFetched(); | ||
print('welcome message: ' + remoteConfig.getString('welcome')); | print('welcome message: ' + remoteConfig.getString('welcome')); | ||
</pre> | </pre> |
2020年1月28日 (火) 11:21時点における版
インストール
dependencies:
firebase_remote_config: ^0.3.0+1
androidの準備
google-services.jsonをandroid/appの下へ
android/build.gradle
buildscript { repositories { google() // Google's Maven repository } dependencies { classpath 'com.android.tools.build:gradle:3.2.1' classpath 'com.google.gms:google-services:4.3.0' } } allprojects { repositories { google() // Google's Maven repository } }
android/app/build.gradle のファイルの末尾へapply~を追加
dependencies { } apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
サンプル
初回起動
import 'package:firebase_remote_config/firebase_remote_config.dart'; final RemoteConfig remoteConfig = await RemoteConfig.instance;
値取得
import 'package:firebase_remote_config/firebase_remote_config.dart'; final defaults = <String, dynamic>{'welcome': 'default welcome'}; await remoteConfig.setDefaults(defaults); await remoteConfig.setConfigSettings(RemoteConfigSettings(debugMode: true)); // developer_mode await remoteConfig.fetch(expiration: const Duration(seconds: 720)); await remoteConfig.activateFetched(); print('welcome message: ' + remoteConfig.getString('welcome'));