Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/smarongiu/Xamarin.Plugin.Firebase.RemoteConfig

Xamarin Forms bindings for Firebase RemoteConfig
https://github.com/smarongiu/Xamarin.Plugin.Firebase.RemoteConfig

Last synced: 3 months ago
JSON representation

Xamarin Forms bindings for Firebase RemoteConfig

Awesome Lists containing this project

README

        

# Xamarin.Plugin.Firebase.RemoteConfig
Cross-platform library for using Firebase RemoteConfig in Xamarin Forms applications.
The plugin provides a simple facade to official Xamarin bindings for Firebase native libs.

## Platform support
This plugin is compatible with iOS and Android.

## Quickstart

### Setup
- Setup your Firebase project on https://console.firebase.google.com
- NuGet package available: https://www.nuget.org/packages/Xam.Plugin.FirebaseRemoteConfig
- Install the nuget package into your PCL/Forms project and client projects.

### API Usage
Call **CrossFirebaseRemoteConfig.Current** from PCL or client code to use APIs.
```csharp
///
/// Initializes the service.
///
/// If set, load defaults from this resource
/// If set to true developer mode is enabled.
void Init(string defaultConfigResourceName = null, bool developerModeEnabled = false);

///
/// Initializes the service without default config.
///
/// If set to true developer mode is enabled.
void Init(bool developerModeEnabled = false);

///
/// Fetchs the remote config.
///
/// Cache expiration in seconds.
/// when fetch fails.
Task FetchAsync(long cacheExpiration);

///
/// Activates the last fetched config.
///
void ActivateFetched();

///
/// Gets the value with specified key as string.
///
string GetString(string key);

///
/// Gets the value with specified key as byte array.
///
byte[] GetBytes(string key);

///
/// Gets the value with specified key as boolean.
///
bool GetBool(string key);

///
/// Gets the value with specified key as long.
///
long GetLong(string key);

///
/// Gets the value with specified key as double.
///
double GetDouble(string key);

///
/// Gets all keys by prefix.
///
ICollection GetKeysByPrefix(string prefix);
```

### iOS
- From the Firebase Console, add your iOS app to your project.
- Download and add the generated GoogleService-Info.plist file to your app in the root folder and mark it as "BundleResource".
- Add this line to AppDelegate.cs:
```csharp
Firebase.Core.App.Configure();
CrossFirebaseRemoteConfig.Current.Init("my_config_defaults");
```
- you can add a default config file as a plist, put it in the root folder and mark it as "BundleResource".

### Android
- From the Firebase Console, add your Android app to your project.
- Download and add the generated google-services.json file to your app in the root folder and mark it as "GoogleServicesJson".
- Add the nuget package https://www.nuget.org/packages/Plugin.CurrentActivity and follow installation guide.
- Add these lines to MainActivity.cs, after base.OnCreate(bundle):
```csharp
Firebase.FirebaseApp.InitializeApp(this);
CrossFirebaseRemoteConfig.Current.Init("my_config_defaults");
```
- you can add a default config file as xml resource (under Resources/xml).

## License
Licensed under MIT, see license file.