「Flutter/firebase/RemoteConfig」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→androidの準備) |
|||
行28: | 行28: | ||
} | } | ||
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin | apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin | ||
+ | </pre> | ||
+ | |||
+ | ==サンプル== | ||
+ | 初回起動 | ||
+ | import 'package:firebase_remote_config/firebase_remote_config.dart'; | ||
+ | final RemoteConfig remoteConfig = await RemoteConfig.instance; | ||
+ | |||
+ | <pre> | ||
+ | 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(second: 720)); | ||
+ | await remoteConfig.activateFetched(); | ||
+ | print('welcome message: ' + remoteConfig.getString('welcome')); | ||
</pre> | </pre> |
2019年12月16日 (月) 18:30時点における版
インストール
dependencies:
firebase_remote_config: ^0.3.0+1
androidの準備
google-services.jsonをandorid/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(second: 720)); await remoteConfig.activateFetched(); print('welcome message: ' + remoteConfig.getString('welcome'));