Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Example of how to use Feature Toggle in your Xamarin.Forms applications.
using System.ComponentModel;
using ConfigCat.Client;
using Xamarin.Forms;
namespace DemoFeatureToggle
{
[DesignTimeVisible(false)]
public partial class MainPage : ContentPage
{
ManualPollConfiguration clientConfiguration = new ManualPollConfiguration
{
ApiKey = "API KEY"
};
IConfigCatClient client;
public MainPage()
{
InitializeComponent();
client = new ConfigCatClient(clientConfiguration);
}
void Handle_Clicked(object sender, System.EventArgs e)
{
client.ForceRefresh();
if (client.GetValue("isAwesomeFeatureEnabled", false))
{
LblResult.Text = "ON";
LblResult.TextColor = Color.GreenYellow;
}
else
{
LblResult.Text = "OFF";
LblResult.TextColor = Color.Red;
}
}
protected override void OnDisappearing()
{
base.OnDisappearing();
client.Dispose();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment