{"id":58290,"date":"2023-07-22T11:05:23","date_gmt":"2023-07-22T09:05:23","guid":{"rendered":"https:\/\/ar3dp.de\/docs\/programmieren\/net-maui-basis-applikation-app-template\/lizenz-manager\/"},"modified":"2023-07-22T11:05:23","modified_gmt":"2023-07-22T09:05:23","slug":"lizenz-manager","status":"publish","type":"docs","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/lizenz-manager\/","title":{"rendered":"License Manager"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">Unser App-Template kommt mit einem voll funktionsf\u00e4higer Lizenz-Verwaltung, welche unter anderem auch unser 3D Druckkosten-Kalkulator verwendet.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Abh\u00e4ngigkeiten<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Um die Lizenz-Verwaltung nutzen zu k\u00f6nnen, sind jedoch folgende Drittanbieterl\u00f6sungen n\u00f6tig.<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>WooCommerce (via WordPress)<\/li>\n\n\n\n<li>WP Software License Plugin, kostenpflichtig (<a href=\"https:\/\/wpsoftwarelicense.com\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/wpsoftwarelicense.com\/<\/a>)<\/li>\n<\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">Produkt erstellen und konfigurieren<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Um die Lizenz-Verwaltung zu aktivieren, erstelle oder bearbeite das gew\u00fcnschte Produkt unter &#8220;Produkte&#8221; in deinem WordPress-Dashboard.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1092\" height=\"114\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_1.png\" alt=\"Aktivieren der Lizenz-Einstellungen f\u00fcr ein WooCommerce Produkt\" class=\"wp-image-58293\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_1.png 1092w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_1-768x80.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_1-18x2.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_1-380x40.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_1-590x62.png 590w\" sizes=\"(max-width: 1092px) 100vw, 1092px\" \/><figcaption class=\"wp-element-caption\">Aktivieren der Lizenz-Einstellungen f\u00fcr ein WooCommerce Produkt<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Bei den Produktdaten, w\u00e4hle &#8220;Variables Produkt&#8221; und aktiviere &#8220;Lizenz&#8221;. Nun muss unter &#8220;Eigenschaften&#8221; noch eine Eigenschaft angelegt werde, welche zur Unterscheidung der Varianten verwendet wird. In unserem Beispiel ist es die Eigenschaft &#8220;Lizenz&#8221;. Die Werte werden dabei mit <code>|<\/code> getrennt.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1076\" height=\"269\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_2.png\" alt=\"Konfiguration der Varianten\" class=\"wp-image-58296\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_2.png 1076w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_2-768x192.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_2-18x5.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_2-380x95.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_2-590x148.png 590w\" sizes=\"(max-width: 1076px) 100vw, 1076px\" \/><figcaption class=\"wp-element-caption\">Konfiguration der Varianten<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Aktiviere hier die Option &#8220;F\u00fcr Varianten verwenden&#8221;. Gehe nun zu &#8220;Varianten&#8221; und gib die jeweiligen Produktdaten zu deiner Lizenz ein, sowie den gew\u00fcnschten Preis.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Abschlie\u00dfend wird die Lizenz unter &#8220;Lizenz&#8221; noch konfiguriert.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1076\" height=\"464\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_3.png\" alt=\"Hauptinformationen zum Lizenz-Produkt\" class=\"wp-image-58299\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_3.png 1076w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_3-768x331.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_3-18x8.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_3-380x164.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_3-590x254.png 590w\" sizes=\"(max-width: 1076px) 100vw, 1076px\" \/><figcaption class=\"wp-element-caption\">Hauptinformationen zum Lizenz-Produkt<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Hier sind nur die Informationen entscheidet, welche unter &#8220;Allgemein&#8221; angegeben werden. Die einzigartige ID wird ben\u00f6tigt, damit unser <code>LicenseManager<\/code> das Produkt identifizieren kann. Die Version, damit auf Updates gepr\u00fcft werden kann.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">App konfigurieren<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Damit die App das richtige Produkt (Unique ID) in WooCommerce abfragt, musst du die Produkt-ID in der <code>secrets.json<\/code> Datei eingeben.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;javascript&quot;,&quot;mime&quot;:&quot;application\/json&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;JSON&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;json&quot;}\">{\n  &quot;AppBasement&quot;: {\n    \/\/..\n    &quot;LicenseManagerProductCode&quot;: &quot;MY-PRODUCTID&quot;\n    \/\/..\n  }\n}<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">In der Klasse <code>AppHostBuilderExtensions<\/code> wird der <code>LicenseManager<\/code> initialisiert. Hier ist nur noch der <code>Uri<\/code> zu deiner WordPress Website anzugeben,<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csharp&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;C#&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;csharp&quot;}\">public static MauiAppBuilder ConfigureApp(this MauiAppBuilder builder)\n{\n  builder\n    .RegisterDispatcher()\n    .RegisterMainViewModels()\n    .RegisterPageViewModels()\n    .RegisterModalViewModels()\n    .RegisterSettingsViewModels()\n    .RegisterMainViews()\n    .RegisterPageViews()\n    .RegisterModalViews()\n    .RegisterSettingsViews()\n    .RegisterNavigationRoots()\n    .ConfigureLicensing(new Uri(&quot;https:\/\/ar3dp.de\/&quot;), &quot;&quot;)\n    ;\n\n  ConfigureMappers();\n  return builder;\n}<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Lizenz-Manager<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Die Instanz des <code>LicenseManager<\/code> ist \u00fcber den <code>ServiceProvider<\/code> zugreifbar. In der <code>BaseViewModel<\/code> Klasse wird dieser initialisiert.<\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csharp&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;C#&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;csharp&quot;}\">public BaseViewModel(IDispatcher dispatcher, IServiceProvider provider) : base(dispatcher, provider)\n{\n    Dispatcher = dispatcher;\n    Provider = provider;\n\n    UpdateVersionBuild();\n    RegisterMessages();\n    InitializeLicenseServer();\n}\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ Initializes the LicenseManager to react on chances of the current license state.\n\/\/\/ &lt;\/summary&gt;\nprotected void InitializeLicenseServer()\n{\n    LicenseManager = Provider.GetServices&lt;ILicenseManager&gt;().First();\n    LicenseManager.LicenseChanged += LicenseManager_LicenseChanged;\n\n    IsLightVersion = !LicenseManager?.CurrentLicense?.IsValid ?? true;\n}\n\n\/\/....\n\n\/\/\/ &lt;summary&gt;\n\/\/\/ Event if the current license info has changed. All dependencies will be updated.\n\/\/\/ &lt;\/summary&gt;\n\/\/\/ &lt;param name=&quot;sender&quot;&gt;&lt;c&gt;LicenseManager&lt;\/c&gt;&lt;\/param&gt;\n\/\/\/ &lt;param name=&quot;e&quot;&gt;&lt;c&gt;LicenseChangedEventArgs&lt;\/c&gt;&lt;\/param&gt;\nprotected void LicenseManager_LicenseChanged(object sender, EventArgs e)\n{\n  DispatchManager.Dispatch(Dispatcher, () =&gt; {\n    if (e is LicenseChangedEventArgs args)\n    {\n      LicenseValid = args.Valid;\n      IsLightVersion = !args.Valid;\n      LicenseKey = args.LicenseKey;\n      LastLicenseCheck = args.CheckDate;\n    }\n  });\n}\n<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Alle <code>ViewModels<\/code>, welche auf dem <code>BaseViewModel<\/code> basieren, werden automatisch benachrichtig, wenn sich die Lizenz \u00e4ndert. <\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Debugging<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Solange das Projekt im Debug ausgef\u00fchrt wird, erscheint der Lizenz-Dialog, solange bis keine Aktivierung erfolgt hat. Dies kann in der Funktion <code>BaseViewModel.CheckLicense()<\/code> deaktiviert werden.  <\/p>\n\n\n\n<div class=\"wp-block-codemirror-blocks-code-block code-block\"><pre class=\"CodeMirror\" data-setting=\"{&quot;showPanel&quot;:true,&quot;languageLabel&quot;:&quot;language&quot;,&quot;fullScreenButton&quot;:true,&quot;copyButton&quot;:true,&quot;mode&quot;:&quot;clike&quot;,&quot;mime&quot;:&quot;text\/x-csharp&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:false,&quot;styleActiveLine&quot;:false,&quot;lineWrapping&quot;:false,&quot;readOnly&quot;:true,&quot;fileName&quot;:&quot;&quot;,&quot;TrpContentRestriction&quot;:{&quot;restriction_type&quot;:&quot;exclude&quot;,&quot;selected_languages&quot;:[],&quot;panel_open&quot;:true},&quot;language&quot;:&quot;C#&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;csharp&quot;}\">        [RelayCommand]\n        protected async Task CheckLicense()\n        {\n            try\n            {\n                LicenseInfo licenseInfo = JsonConvertHelper.ToObject&lt;LicenseInfo&gt;(SettingsApp.LicenseInfo);\n                if (!string.IsNullOrEmpty(licenseInfo?.License))\n                {\n                    bool isValid = await CheckLicenseValidAsync(licenseInfo);\n                    SettingsApp.LicenseInfo = JsonConvertHelper.ToSettingsString(licenseInfo);\n                    await SettingsApp.SaveSettingsAsync();\n                    \/\/IsLightVersion = !isValid;\n                    \/\/ Notify all about license change\n                    WeakReferenceMessenger.Default.Send(new LicenseChangedMessage(licenseInfo));\n                }\n#if DEBUG\n                else if (true) \/\/ Set this to false to avoid showing the license enter dialog\n#else\n                else if (VersionTracking.Default.IsFirstLaunchEver &amp;&amp; !LicenseActivationShown)\n#endif\n                {\n                    \/\/ Avoids multiple popups in the first session\n                    LicenseActivationShown = true;\n                    await ShowLicenseActivation();\n                }\n                DispatchManager.Dispatch(Dispatcher, () =&gt; LastLicenseCheck = DateTime.Now);\n            }\n            catch (Exception exc)\n            {\n                \/\/Log error\n                EventManager.Instance.LogError(exc);\n            }\n        }<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"1432\" height=\"796\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_4.png\" alt=\"\" class=\"wp-image-58306\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_4.png 1432w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_4-768x427.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_4-18x10.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_4-380x211.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_license_manager_4-590x328.png 590w\" sizes=\"(max-width: 1432px) 100vw, 1432px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Unser App-Template kommt mit einem voll funktionsf\u00e4higer Lizenz-Verwaltung, welche unter anderem auch unser 3D Druckkosten-Kalkulator verwendet. Abh\u00e4ngigkeiten Um die Lizenz-Verwaltung nutzen zu k\u00f6nnen, sind jedoch folgende Drittanbieterl\u00f6sungen n\u00f6tig. Produkt erstellen und konfigurieren Um die Lizenz-Verwaltung zu aktivieren, erstelle oder bearbeite das gew\u00fcnschte Produkt unter &#8220;Produkte&#8221; in deinem WordPress-Dashboard. Bei den Produktdaten, w\u00e4hle &#8220;Variables Produkt&#8221; und&#8230;<\/p>","protected":false},"author":1,"featured_media":0,"parent":57992,"menu_order":10,"comment_status":"open","ping_status":"closed","template":"","meta":{"_featured":false,"_is_vendor_doc":"0","footnotes":""},"doc_tag":[],"class_list":["post-58290","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58290","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/comments?post=58290"}],"version-history":[{"count":1,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58290\/revisions"}],"predecessor-version":[{"id":58964,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58290\/revisions\/58964"}],"up":[{"embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/57992"}],"next":[{"title":"Biometrische Authentifizierung","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/biometrische-authentifizierung\/","href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58960"}],"prev":[{"title":"Firebase","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/firebase\/","href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58257"}],"wp:attachment":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/media?parent=58290"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/doc_tag?post=58290"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}