Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
44 changes: 44 additions & 0 deletions .github/scripts/verify-maui-android.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
set -e

echo "Installing APK..."
adb install client-sdk/frameworks/maui/bin/Debug/net8.0-android/com.launchdarkly.hello-Signed.apk

echo "Clearing logcat..."
adb logcat -c

echo "Launching app..."
adb shell monkey -p com.launchdarkly.hello -c android.intent.category.LAUNCHER 1

for i in 1 2 3 4; do
echo "Waiting 15 seconds (attempt $i of 4)..."
sleep 15

echo "=== Checking if app is running ==="
adb shell pidof com.launchdarkly.hello || echo "App process NOT running"

echo "=== Logcat (crash/mono related) ==="
adb logcat -d -t 100 2>&1 | grep -iE "AndroidRuntime|FATAL|crash|mono|dotnet|HelloDotNet|launchdarkly" | tail -50 || true

echo "=== UI dump ==="
adb exec-out uiautomator dump /dev/tty > /tmp/uidump.xml 2>&1 || true
cat /tmp/uidump.xml

if grep -q 'feature flag evaluates to' /tmp/uidump.xml; then
echo "SUCCESS: Flag evaluation verified"
exit 0
fi
echo "Attempt $i: text not found yet, retrying..."

# If app crashed, try relaunching
if ! adb shell pidof com.launchdarkly.hello > /dev/null 2>&1; then
echo "App not running, relaunching..."
adb shell monkey -p com.launchdarkly.hello -c android.intent.category.LAUNCHER 1
fi
done

echo "=== FULL LOGCAT DUMP (last 200 lines) ==="
adb logcat -d 2>&1 | tail -200 || true

echo "FAILURE: Could not verify flag evaluation after 4 attempts"
exit 1
104 changes: 104 additions & 0 deletions .github/workflows/client-sdk.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
name: client-sdk
on:
schedule:
# * is a special character in YAML so you have to quote this string
- cron: '0 9 * * *'
push:
branches: [ main, 'feat/**' ]
paths:
- 'client-sdk/**'
- '.github/scripts/verify-maui-android.sh'
- '.github/workflows/client-sdk.yml'
pull_request:
branches: [ main, 'feat/**' ]
paths:
- 'client-sdk/**'
- '.github/scripts/verify-maui-android.sh'
- '.github/workflows/client-sdk.yml'

jobs:
build-and-run:
runs-on: ubuntu-latest

permissions:
id-token: write # Needed if using OIDC to get release secrets.
contents: read

steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- name: Setup .NET
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: 8.0.x

- name: Build console app
run: dotnet build client-sdk/getting-started

- uses: launchdarkly/gh-actions/actions/release-secrets@release-secrets-v1
name: 'Get mobile key and flag key'
with:
aws_assume_role: ${{ vars.AWS_ROLE_ARN }}
ssm_parameter_pairs: '/sdk/common/hello-apps/mobile-key = LAUNCHDARKLY_MOBILE_KEY,
/sdk/common/hello-apps/boolean-flag-key = LAUNCHDARKLY_FLAG_KEY'

- name: Configure MAUI appsettings
run: |
echo "{\"MobileKey\": \"$LAUNCHDARKLY_MOBILE_KEY\", \"FlagKey\": \"$LAUNCHDARKLY_FLAG_KEY\"}" > client-sdk/frameworks/maui/Resources/Raw/appsettings.json

- name: Install MAUI workload
working-directory: client-sdk/frameworks/maui
run: dotnet workload install maui-android

- name: Build MAUI app (Android)
working-directory: client-sdk/frameworks/maui
run: dotnet build -p:EmbedAssembliesIntoApk=true

- name: Enable KVM group perms (for performance)
run: |
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules
sudo udevadm control --reload-rules
sudo udevadm trigger --name-match=kvm

- name: Free disk space
uses: jlumbroso/free-disk-space@54081f138730dfa15788a46383842cd2f914a1be # v1.3.1
with:
android: false
dotnet: false
large-packages: false

- name: Run MAUI app on emulator
uses: reactivecircus/android-emulator-runner@324029e2f414c084d8b15ba075288885e74aef9c # v2.34.0
with:
api-level: 29
arch: x86_64
script: bash .github/scripts/verify-maui-android.sh

- uses: launchdarkly/gh-actions/actions/verify-hello-app@verify-hello-app-v2
with:
use_mobile_key: true
role_arn: ${{ vars.AWS_ROLE_ARN }}
command: dotnet run --project client-sdk/getting-started

build-maui:
runs-on: macos-latest

steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- name: Setup .NET
uses: actions/setup-dotnet@9a946fdbd5fb07b82b2f5a4466058b876ab72bb2 # v5.3.0
with:
dotnet-version: 8.0.x

- name: Install MAUI workloads
working-directory: client-sdk/frameworks/maui
run: dotnet workload install maui

- name: Build MAUI app (Android)
working-directory: client-sdk/frameworks/maui
run: dotnet build -f net8.0-android

- name: Build MAUI app (iOS)
working-directory: client-sdk/frameworks/maui
run: dotnet build -f net8.0-ios
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,6 @@

# Local env files
.env

# MAUI appsettings (contains LaunchDarkly keys)
**/Resources/Raw/appsettings.json
9 changes: 5 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ or the [.NET SDK reference guide](https://docs.launchdarkly.com/sdk/server-side/

## SDKs

| SDK | Package | Examples |
|--------------------|-----------------------------|------------------------------------------|
| .NET Server SDK | `LaunchDarkly.ServerSdk` | [`server-sdk/`](./server-sdk/) |
| .NET Server AI SDK | `LaunchDarkly.ServerSdk.Ai` | [`server-sdk-ai/`](./server-sdk-ai/) |
| SDK | Package | Examples |
|--------------------|-----------------------------|--------------------------------------|
| .NET Server SDK | `LaunchDarkly.ServerSdk` | [`server-sdk/`](./server-sdk/) |
| .NET Server AI SDK | `LaunchDarkly.ServerSdk.Ai` | [`server-sdk-ai/`](./server-sdk-ai/) |
| .NET Client SDK | `LaunchDarkly.ClientSdk` | [`client-sdk/`](./client-sdk/) |

## Requirements

Expand Down
17 changes: 17 additions & 0 deletions client-sdk/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# LaunchDarkly .NET Client SDK examples

Examples for the [`LaunchDarkly.ClientSdk`](https://www.nuget.org/packages/LaunchDarkly.ClientSdk) package.

For more comprehensive instructions, you can visit your [Quickstart page](https://app.launchdarkly.com/quickstart#/) or the [client-side .NET SDK reference guide](https://docs.launchdarkly.com/sdk/client-side/dotnet).

## Getting Started

| Example | Description |
|--------------------------------------|-------------------------------------------------------------|
| [Flag Retrieval](./getting-started/) | Console app that initializes the SDK and evaluates a feature flag |

## Frameworks

| Framework | Example | Description |
|-----------|----------------------------------|-----------------------------------------------------------------|
| .NET MAUI | [MAUI](./frameworks/maui/) | Cross-platform (Android & iOS) app evaluating a feature flag |
14 changes: 14 additions & 0 deletions client-sdk/frameworks/maui/App.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<?xml version = "1.0" encoding = "UTF-8" ?>
<Application xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:HelloDotNetClient"
x:Class="HelloDotNetClient.App">
<Application.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/Styles/Colors.xaml" />
<ResourceDictionary Source="Resources/Styles/Styles.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Application.Resources>
</Application>
11 changes: 11 additions & 0 deletions client-sdk/frameworks/maui/App.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
namespace HelloDotNetClient;

public partial class App : Application
{
public App()
{
InitializeComponent();

MainPage = new AppShell();
}
}
15 changes: 15 additions & 0 deletions client-sdk/frameworks/maui/AppShell.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?xml version="1.0" encoding="UTF-8" ?>
<Shell
x:Class="HelloDotNetClient.AppShell"
xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
xmlns:local="clr-namespace:HelloDotNetClient"
Shell.FlyoutBehavior="Disabled"
Title="LaunchDarkly Hello">

<ShellContent
Title="Home"
ContentTemplate="{DataTemplate local:MainPage}"
Route="MainPage" />

</Shell>
9 changes: 9 additions & 0 deletions client-sdk/frameworks/maui/AppShell.xaml.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
namespace HelloDotNetClient;

public partial class AppShell : Shell
{
public AppShell()
{
InitializeComponent();
}
}
22 changes: 22 additions & 0 deletions client-sdk/frameworks/maui/MainPage.xaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8" ?>
<ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml"
x:Class="HelloDotNetClient.MainPage"
x:Name="Page"
BackgroundColor="#373841">

<VerticalStackLayout
VerticalOptions="Center"
HorizontalOptions="Center"
Padding="30">

<Label
x:Name="FlagLabel"
Text="Initializing..."
TextColor="#FFFFFF"
FontSize="24"
HorizontalTextAlignment="Center" />

</VerticalStackLayout>

</ContentPage>
Loading
Loading