Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor!: rework remote config plugin #4186

Merged
merged 58 commits into from
Jan 14, 2021
Merged
Changes from 1 commit
Commits
Show all changes
58 commits
Select commit Hold shift + click to select a range
195ebcc
move mobile plugin to specific dir
kroikie Nov 23, 2020
dfbdc15
setup platform interface
kroikie Dec 6, 2020
c040d93
Enable multiple app support
kroikie Dec 6, 2020
432397b
enable multi app for method channel
kroikie Dec 6, 2020
4f44e06
refactor: update method channel interface
kroikie Dec 15, 2020
f9d57b2
refactor: notify when method_channel activates config
kroikie Dec 17, 2020
c655b20
refactor: Move change notifier to app visible plugin
kroikie Dec 17, 2020
da3c431
refactor: use getAll from native sdk
kroikie Dec 19, 2020
a770b0e
refactor: support static values on dart side
kroikie Dec 19, 2020
200e5cd
initial ios rework
kroikie Dec 21, 2020
87d162e
refactor: initial working e2e test
kroikie Dec 21, 2020
5c307d0
refactor: Expose remote config properties
kroikie Dec 22, 2020
bcf3fe9
refactor: Update plugin constants on native side
kroikie Dec 22, 2020
c150acf
test: Add mobile plugin unit tests
kroikie Dec 23, 2020
5e04491
refactor: separate getting parameters and getting properties
kroikie Dec 24, 2020
6a8f357
refactor: add getProperties call to Android side
kroikie Dec 24, 2020
31818fd
refactor: send fetchTimeout and minimumFetchInterval in millis
kroikie Dec 24, 2020
e57e0a5
fix: lastFetchTime conversion on iOS
kroikie Dec 28, 2020
965cacd
refactor: Add throttleEndTime when available
kroikie Dec 28, 2020
db3e0e1
fix: always notify listeners on activate
kroikie Dec 28, 2020
e9ec6b5
chore: remove unused variables
kroikie Dec 28, 2020
718dffa
docs: document public members
kroikie Dec 28, 2020
b568ef8
chore: export necessary classes in remote_config plugin
kroikie Dec 28, 2020
55c443e
style: fix formatting
kroikie Dec 28, 2020
31459cf
refactor: Add platform exception conversion to Firebase Exception
kroikie Dec 28, 2020
fb28be5
chore: fix formatting
kroikie Dec 29, 2020
f0e512e
chore: remove path parameters
kroikie Dec 29, 2020
2a87937
chore: return GoogleService-Info.plist to rightful place
kroikie Dec 29, 2020
1641ad3
refactor: Use seconds for fetch timeout and minimum fetch interval
kroikie Dec 29, 2020
7e15c83
docs: Add docs to RemoteConfigFetchStatus
kroikie Dec 29, 2020
80dc5c4
style: fix formatting
kroikie Dec 29, 2020
d52c61e
refactor: Add license readme and changelog to PI
kroikie Dec 29, 2020
09ee9d6
refactor: convert PlatformException to FirebaseException
kroikie Dec 29, 2020
d45eeba
refactor: provide native exception details
kroikie Dec 30, 2020
961855e
chore: set rc platform interface version
kroikie Dec 30, 2020
cdfb8f8
refactor: remove analysis_options.yaml
kroikie Dec 31, 2020
24bf053
refactor: move zero duration fetchTimeout check to dart side
kroikie Dec 31, 2020
1863fe3
docs: add docs to firebase_remote_config level definitions
kroikie Dec 31, 2020
3a87285
refactor: add stack trace to FirebaseException
kroikie Dec 31, 2020
db0c01c
refactor: ignore public member api docs in example
kroikie Dec 31, 2020
5d6aa73
refactor: assert RemoteConfigSettings durations are not negative
kroikie Jan 1, 2021
cf6b1d7
refactor: pass stack trace to FirebaseException from method channel call
kroikie Jan 1, 2021
49bd811
Update packages/firebase_remote_config/firebase_remote_config/lib/src…
kroikie Jan 4, 2021
5922459
style: use ??= for assigning _delegatePackaingProperty
kroikie Jan 4, 2021
a986445
style: fix dart formatting
kroikie Jan 4, 2021
86796d9
fix: Properly pass error code and message from iOS side
kroikie Jan 5, 2021
65d13d1
refactor: remove unnecessary RemoteConfigSettings definition
kroikie Jan 7, 2021
1efbc0d
docs: Update changelog and migration guide
kroikie Jan 12, 2021
6e52739
chore: bump verion of firebase_remote_config plugin
kroikie Jan 12, 2021
d901577
chore: bump version of firebase_core_platform_interface
kroikie Jan 12, 2021
bbaa03a
Update packages/firebase_remote_config/firebase_remote_config_platfor…
kroikie Jan 12, 2021
1082675
docs: add usage sidebar link
Salakar Jan 12, 2021
d2b319c
docs: update plugin readme
Salakar Jan 12, 2021
cfd37e2
chore: add dependency_override for firebase_remote_config_platform_in…
Salakar Jan 12, 2021
8cc394b
chore(example): commit Podfile with osx 10.12 deployment target
Salakar Jan 12, 2021
65f537a
fix(macos): add missing symlinks
Salakar Jan 12, 2021
7cb628f
docs: update usage docs
kroikie Jan 12, 2021
b146368
Update docs/remote-config/usage.mdx
kroikie Jan 12, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
docs: update usage docs
kroikie committed Jan 12, 2021
commit 7cb628f409ca21bd62c60ffb59bcf60e73ab9e16
81 changes: 79 additions & 2 deletions docs/remote-config/usage.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,83 @@
---
title: Remote Config
title: Using Firebase Remote Config
sidebar_label: Usage
---

Remote Config usage
Once installed, you can access the [`firebase_remote_config`](!firebase_remote_config) plugin by importing
it in your Dart code:

```dart
import 'package:firebase_remote_config/firebase_remote_config.dart';
```

Before using Firebase Remote Config, you must first have ensured you have [initialized FlutterFire](../overview.mdx#initializing-flutterfire).

To create a new Firebase Remote Config instance, call the [`instance`](!firebase_remote_config.FirebaseRemoteConfig.instance)
getter on [`FirebaseRemoteConfig`](!firebase_remote_config.FirebaseRemoteConfig):

```dart
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.instance;
```

By default, this allows you to interact with Firebase Remote Config using the default Firebase App used whilst installing FlutterFire on your
platform. If however you'd like to use a secondary Firebase App, use the [`instanceFor`](!firebase_remote_config.FirebaseRemoteConfig.instanceFor) method:

```dart
FirebaseApp secondaryApp = Firebase.app('SecondaryApp');
FirebaseRemoteConfig remoteConfig = FirebaseRemoteConfig.instanceFor(app: secondaryApp);
```

## Defaults

Firebase Remote Config default parameters allows your application to startup without the need to make a
network call. To set the default parameters call the `setDefaults()` method on your [`FirebaseRemoteConfig`](!firebase_remote_config.FirebaseRemoteConfig) instance:

```dart
remoteConfig.setConfigSettings(<String, dynamic>{
kroikie marked this conversation as resolved.
Show resolved Hide resolved
'welcome_message': 'this is the default welcome message',
'feat1_enabled': false,
});
```

## Fetching and activating

Only when default parameters are no longer sufficient updates to the Remote Config template should be made
in the Firebase console or via the Admin SDK. Use the `fetchAndActivate()` method on your [`FirebaseRemoteConfig`](!firebase_remote_config.FirebaseRemoteConfig) instance:

```dart
bool updated = await remoteConfig.fetchAndActivate();
if (updated) {
// the config has been updated, new parameter values are available.
} else {
// the config values were previously updated.
}
```

The `fetchAndActivate()` combines the operations of the `fetch()` and `activate()` methods which can be used separately
if needed.

## Get/Use parameters

Whether using default or fetched parameters, you can fetch the parameter values using the available getters:

```dart
Text('Welcome ${remoteConfig.getString('welcome_message')}')
```

Other getters include: `getBool()`, `getInt()`, `getDouble()`, `getValue()`.

## Settings

Since fetching involves network calls Remote Config allows you to specify how long cached parameters are valid and
how long a fetch should wait before timing out. These settings can be specified using the `setConfigSettings()`
method on your [`FirebaseRemoteConfig`](!firebase_remote_config.FirebaseRemoteConfig) instance:

```dart
await remoteConfig.setConfigSettings(RemoteConfigSettings(
fetchTimeout: Duration(seconds: 10),
minimumFetchInterval: Duration(hours: 1),
));
```

The above snippet specifies that a fetch will wait up to 10 seconds before timing out and fetch parameters will be
cached for a maximum of 1 hour before being considered stale and going to the server on the next `fetch()` call.