# IronServices.Maui MAUI controls and services for IronServices (IronLicensing, IronNotify, IronTelemetry). ## Installation ```xml ``` ## Quick Start ### 1. Register Services ```csharp // MauiProgram.cs builder.Services.AddIronServices(); // Or with custom URLs builder.Services.AddIronServices(options => { options.LicensingUrl = "https://ironlicensing.com"; options.NotifyUrl = "https://ironnotify.com"; options.TelemetryUrl = "https://irontelemetry.com"; }); ``` ### 2. Use Controls ```xaml ``` --- ## Controls ### LoginView A drop-in login form for IronServices authentication. **Type:** `ContentView` (embeddable) #### Properties | Property | Type | Default | Description | |----------|------|---------|-------------| | `Client` | `IronServicesClient` | `null` | **Required.** The client instance for authentication. | | `Title` | `string` | `"Sign In"` | Header text above the form. | | `Subtitle` | `string` | `"Enter your credentials..."` | Subheader text. | | `Logo` | `ImageSource` | `null` | Optional logo image. | | `ShowRegisterLink` | `bool` | `true` | Show "Sign Up" link. | | `ShowForgotPasswordLink` | `bool` | `true` | Show "Forgot Password?" link. | #### Events | Event | Args | Description | |-------|------|-------------| | `LoginSuccess` | `LoginSuccessEventArgs` | Fired on successful login. Contains `UserId`, `Email`, `DisplayName`. | | `LoginFailed` | `LoginFailedEventArgs` | Fired on failed login. Contains `Error` message. | | `RegisterRequested` | `EventArgs` | User tapped "Sign Up" link. | | `ForgotPasswordRequested` | `EventArgs` | User tapped "Forgot Password?" link. | #### Example ```csharp // XAML // Code-behind private async void OnLoginSuccess(object sender, LoginSuccessEventArgs e) { await DisplayAlert("Success", $"Welcome, {e.DisplayName}!", "OK"); await Shell.Current.GoToAsync("//main"); } private async void OnRegisterRequested(object sender, EventArgs e) { await Shell.Current.GoToAsync("//register"); } ``` --- ### LicenseActivationView A license key entry and activation form. **Type:** `ContentView` (embeddable) #### Properties | Property | Type | Default | Description | |----------|------|---------|-------------| | `LicenseManager` | `ILicenseManager` | `null` | **Required.** The license manager instance. | | `Title` | `string` | `"Activate License"` | Header text. | | `Subtitle` | `string` | `"Enter your license key..."` | Subheader text. | | `LicenseKey` | `string` | `null` | Pre-filled license key (two-way binding). | | `ShowHelpLink` | `bool` | `true` | Show help link below form. | | `HelpUrl` | `string` | `"https://..."` | URL opened when help tapped. | #### Events | Event | Args | Description | |-------|------|-------------| | `LicenseActivated` | `LicenseActivatedEventArgs` | Activation succeeded. Contains `License` info. | | `ActivationFailed` | `LicenseActivationFailedEventArgs` | Activation failed. Contains `Error` message. | | `HelpRequested` | `EventArgs` | User tapped help link. | #### Methods | Method | Returns | Description | |--------|---------|-------------| | `ValidateAsync()` | `Task` | Validate the entered license key without activating. | #### Example ```csharp // XAML // Code-behind private async void OnLicenseActivated(object sender, LicenseActivatedEventArgs e) { var license = e.License; await DisplayAlert("Activated", $"License: {license.Tier}\nExpires: {license.ExpiresAt:d}", "OK"); } ``` --- ### AppLogView A full-page log viewer for exceptions and telemetry events. Shows queued items from `TelemetryClient.OfflineQueue`. **Type:** `ContentPage` (standalone page, use with NavigationPage) #### Properties | Property | Type | Default | Description | |----------|------|---------|-------------| | `TelemetryClient` | `TelemetryClient` | `null` | Client to pull queued logs from. Auto-refreshes on set. | | `Title` | `string` | `"App Logs"` | Page title (shown in navigation bar). | | `ShowShareButton` | `bool` | `true` | Enable Share toolbar button. | | `ShowClearButton` | `bool` | `true` | Enable Clear toolbar button. | #### Events | Event | Args | Description | |-------|------|-------------| | `LogsCleared` | `EventArgs` | User cleared the log list. | | `LogsShared` | `EventArgs` | User shared the logs. | | `LogSelected` | `LogItem` | User selected a log entry. | | `LogsRefreshed` | `EventArgs` | Log list was refreshed. | #### Methods | Method | Returns | Description | |--------|---------|-------------| | `RefreshLogs()` | `void` | Reload logs from TelemetryClient queue. | | `AddLog(type, title, message, stackTrace?)` | `void` | Add a manual log entry. | | `AddException(Exception)` | `void` | Add an exception as a log entry. | | `ClearLogs()` | `void` | Clear displayed logs (not the queue). | | `ClearAllLogs()` | `void` | Clear displayed logs AND the offline queue. | | `ExportLogs()` | `string` | Export all logs as formatted text. | | `GetLogs()` | `IReadOnlyList` | Get current log items. | | `LogCount` | `int` | Number of log items. | #### LogItem Properties | Property | Type | Description | |----------|------|-------------| | `Timestamp` | `DateTime` | UTC timestamp. | | `Type` | `string` | `"exception"`, `"message"`, `"info"`, `"warning"`, etc. | | `Title` | `string` | Exception type name or message title. | | `Message` | `string` | Log message. | | `StackTrace` | `string?` | Stack trace for exceptions. | | `JourneyId` | `string?` | Associated user journey ID. | | `UserId` | `string?` | Associated user ID. | #### Example ```csharp // Navigate to log view await Navigation.PushAsync(new AppLogView { TelemetryClient = _telemetryClient, Title = "Error Logs" }); // With event handling var logView = new AppLogView { TelemetryClient = _telemetryClient }; logView.LogsCleared += (s, e) => Debug.WriteLine("Logs cleared"); logView.LogSelected += (s, item) => Debug.WriteLine($"Selected: {item.Title}"); await Navigation.PushAsync(logView); // Manual log entries (without TelemetryClient) var logView = new AppLogView(); logView.AddException(ex); logView.AddLog("warning", "Network Issue", "Connection timeout after 30s"); ``` #### Toolbar - **Share** (Primary): Exports logs as text and opens system share sheet. - **Clear** (Secondary/overflow menu): Clears displayed logs. - **Refresh** button in summary bar: Reloads from queue. --- ## Services ### MauiSecureTokenStorage Secure token storage using MAUI `SecureStorage`. Automatically registered when using `AddIronServices()`. ```csharp // Automatically used by IronServicesClient builder.Services.AddIronServices(); // Or manually services.AddSingleton(); ``` ### ServiceCollectionExtensions ```csharp // Default URLs services.AddIronServices(); // Custom URLs services.AddIronServices(options => { options.LicensingUrl = "https://licensing.myapp.com"; options.NotifyUrl = "https://notify.myapp.com"; options.TelemetryUrl = "https://telemetry.myapp.com"; }); ``` Registers: - `MauiSecureTokenStorage` as `ITokenStorage` - `IronServicesClient` as singleton --- ## Complete Example ```csharp // MauiProgram.cs public static MauiApp CreateMauiApp() { var builder = MauiApp.CreateBuilder(); builder.UseMauiApp(); // Register IronServices builder.Services.AddIronServices(); // Register TelemetryClient for logging builder.Services.AddSingleton(sp => new TelemetryClient(new TelemetryOptions { Dsn = "your-dsn-here", EnableOfflineQueue = true })); return builder.Build(); } // LoginPage.xaml // LoginPage.xaml.cs public partial class LoginPage : ContentPage { public LoginPage(IronServicesClient client) { InitializeComponent(); LoginControl.Client = client; } private async void OnLoginSuccess(object sender, LoginSuccessEventArgs e) { await Shell.Current.GoToAsync("//main"); } } // SettingsPage.xaml.cs - Navigate to logs private async void OnViewLogsClicked(object sender, EventArgs e) { var telemetry = Handler.MauiContext.Services.GetService(); await Navigation.PushAsync(new AppLogView { TelemetryClient = telemetry }); } ``` --- ## Styling All controls use MAUI resource dictionaries. Override these colors in your `App.xaml`: ```xaml #512BD4 #DFD8F7 #E1E1E1 #C8C8C8 #919191 #6E6E6E #404040 #212121 #FFFFFF ``` Controls support light/dark themes via `AppThemeBinding`. --- ## Platform Support | Platform | Minimum Version | |----------|-----------------| | Android | API 21 (5.0) | | iOS | 14.0 | | macOS | 11.0 | | Windows | 10.0.17763.0 | --- ## Dependencies - `IronServices.Client` - Core API client - `IronLicensing.Client` - License validation - `IronTelemetry.Client` - Telemetry and logging - `Microsoft.Maui.Controls` - MAUI framework --- ## License Proprietary. See LICENSE file.