Software licensing and activation for .NET applications
Website • Documentation • .NET Guide • Git
--- **IronLicensing** helps you protect your software with flexible licensing, activations, and feature management. Built for developers who want simple, powerful licensing without the complexity. ## Installation ```bash dotnet add package IronLicensing.Client ``` ## Quick Start ### 1. Register Services ```csharp using IronLicensing.Client.Extensions; builder.Services.AddIronLicensing(options => { options.PublicKey = "pk_live_xxxxxxxxxx"; options.ProductSlug = "my-product"; options.OfflineGraceDays = 7; }); ``` ### 2. Validate a License ```csharp using IronLicensing.Client; public class MyViewModel { private readonly ILicenseManager _license; public MyViewModel(ILicenseManager license) { _license = license; } public async Task ValidateLicenseAsync() { var result = await _license.ValidateAsync("IRON-XXXX-XXXX-XXXX-XXXX"); if (result.Success) { Console.WriteLine($"Licensed! Tier: {result.License.Tier}"); } else { Console.WriteLine($"Error: {result.ErrorMessage}"); } } } ``` ### 3. Feature Gating ```csharp // Check if feature is available if (_license.HasFeature("advanced-reports")) { ShowAdvancedReports(); } // Or throw if feature is required _license.RequireFeature("advanced-reports"); // throws LicenseRequiredException ``` ## Configuration Options ```csharp builder.Services.AddIronLicensing(options => { // Required options.PublicKey = "pk_live_xxxxxxxxxx"; options.ProductSlug = "my-product"; // Offline support options.OfflineGraceDays = 7; // Days license is valid offline options.RequireSignatureForOffline = true; // Require signed license for offline // API settings options.ApiBaseUrl = "https://ironlicensing.com"; options.HttpTimeout = TimeSpan.FromSeconds(30); // In-app purchase URLs options.SuccessUrl = "myapp://purchase/success"; options.CancelUrl = "myapp://purchase/cancel"; }); ``` ## License Activation ```csharp // Activate a license key var result = await _license.ActivateAsync("IRON-XXXX-XXXX-XXXX-XXXX"); if (result.Success) { // License is now active on this device Console.WriteLine($"Activated! {_license.CurrentLicense.ActivationsUsed}/{_license.CurrentLicense.ActivationsMax}"); } // Deactivate (free up activation slot) await _license.DeactivateAsync(); ``` ## Trial Support ```csharp // Start a trial var success = await _license.StartTrialAsync("user@example.com"); if (success) { Console.WriteLine($"Trial started! {_license.TrialDaysRemaining} days remaining"); } // Check trial status if (_license.IsTrial) { ShowTrialBanner(_license.TrialDaysRemaining); } ``` ## In-App Purchase ```csharp // Start checkout flow var checkout = await _license.StartPurchaseAsync("tier-id", "customer@example.com"); if (checkout.Success) { // Open checkout URL in browser await Launcher.OpenAsync(checkout.CheckoutUrl); } ``` ## Events ```csharp // Listen for license changes _license.LicenseChanged += (sender, args) => { Console.WriteLine($"License changed from {args.OldLicense?.Status} to {args.NewLicense?.Status}"); }; // Listen for validation results _license.ValidationCompleted += (sender, args) => { if (!args.Success) { Console.WriteLine($"Validation failed: {args.ErrorCode} - {args.ErrorMessage}"); } }; ``` ## License Status ```csharp // Quick status checks bool isLicensed = _license.IsLicensed; // Active or Trial bool isTrial = _license.IsTrial; LicenseStatus status = _license.Status; // Active, Trial, Expired, Suspended, Revoked // Full license info var license = _license.CurrentLicense; Console.WriteLine($"Tier: {license.Tier}"); Console.WriteLine($"Expires: {license.ExpiresAt}"); Console.WriteLine($"Features: {string.Join(", ", license.Features)}"); ``` ## Offline Support Licenses are cached locally with cryptographic signatures for secure offline validation: - **Grace Period**: Configurable days the license is valid without server contact - **Signature Verification**: Optional RSA signature verification for offline licenses - **Automatic Sync**: License is re-validated when connectivity is restored ```csharp // Clear cached license await _license.ClearCacheAsync(); ``` ## Platform Support | Platform | Minimum Version | |----------|-----------------| | Android | 5.0 (API 21) | | iOS | 15.0 | | macOS (Catalyst) | 15.0 | | Windows | 10.0.17763.0 | ## Documentation For complete documentation, visit [ironlicensing.com/docs](https://ironlicensing.com/docs). ## Other SDKs | Platform | Package | |----------|---------| | JavaScript/TypeScript | [@ironservices/licensing](https://git.marketally.com/ironservices/ironlicensing-js) | | Python | [ironlicensing](https://git.marketally.com/ironservices/ironlicensing-python) | | Go | [ironlicensing-go](https://git.marketally.com/ironservices/ironlicensing-go) | | Java | [ironlicensing-java](https://git.marketally.com/ironservices/ironlicensing-java) | | Rust | [ironlicensing](https://git.marketally.com/ironservices/ironlicensing-rust) | ## Support - **Documentation**: [ironlicensing.com/docs](https://ironlicensing.com/docs) - **Email**: dev@ironservices.io - **Issues**: [git.marketally.com/ironservices/ironlicensing-dotnet/issues](https://git.marketally.com/ironservices/ironlicensing-dotnet/issues) ## License MIT License - see [LICENSE](LICENSE) for details.