{"id":58257,"date":"2023-07-22T09:55:20","date_gmt":"2023-07-22T07:55:20","guid":{"rendered":"https:\/\/ar3dp.de\/docs\/programmieren\/net-maui-basis-applikation-app-template\/firebase\/"},"modified":"2023-07-22T09:55:20","modified_gmt":"2023-07-22T07:55:20","slug":"firebase","status":"publish","type":"docs","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/firebase\/","title":{"rendered":"Firebase"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Firebase Synchronisierung<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Unser App-Template ist vorbereitet, Nutzerdaten, sowie Standard-Konfigurationen aus Firebase zu laden und zu synchronisieren. Dies erlaubt es, Nutzerdaten \u00fcber verschiedene Ger\u00e4te synchron zu halten. Um den Service zu aktivieren, definiere folgende Konstanten in der <code>AppBasement.csproj<\/code> Datei und f\u00fcge folgende Nuget-Pakete hinzu.<\/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;xml&quot;,&quot;mime&quot;:&quot;application\/xml&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;XML&quot;,&quot;maxHeight&quot;:&quot;400px&quot;,&quot;modeName&quot;:&quot;xml&quot;}\">\t&lt;!-- Enables all firebase code --&gt;\n\t&lt;DefineConstants&gt;$(DefineConstants);Firebase;FirebaseAuth&lt;\/DefineConstants&gt;\n\n\n\t&lt;!-- Needed for Firebase --&gt;\n\t&lt;PackageReference Include=&quot;FirebaseAuthentication.net&quot; Version=&quot;4.1.0&quot; \/&gt;\n\t&lt;PackageReference Include=&quot;FirebaseDatabase.net&quot; Version=&quot;4.2.0&quot; \/&gt;<\/pre><\/div>\n\n\n\n<h3 class=\"wp-block-heading\">Firebase einrichten<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Falls nicht vorhanden, ben\u00f6tigest du einen Account bei Firebase. Dieser ist kostenlos und kann mit einem Google-Konto ganz einfach erstellt werden. Besuche dazu einfach folgenden Link:<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Firebase Console:<\/strong> <a href=\"https:\/\/console.firebase.google.com\/u\/1\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">https:\/\/console.firebase.google.com\/u\/1\/<\/a><\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Anschlie\u00dfend erstelle ein <strong>neues Projekt<\/strong>, indem du auf &#8220;Projekt hinzuf\u00fcgen&#8221; klickst.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"660\" height=\"320\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_1.png\" alt=\"Neues Projekt erstellen\" class=\"wp-image-58259\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_1.png 660w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_1-18x9.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_1-380x184.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_1-590x286.png 590w\" sizes=\"(max-width: 660px) 100vw, 660px\" \/><figcaption class=\"wp-element-caption\">Neues Projekt erstellen<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Folge anschlie\u00dfend den Setup-Assistenten.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"780\" height=\"595\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_2.png\" alt=\"Benenne dein Projekt\" class=\"wp-image-58260\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_2.png 780w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_2-768x586.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_2-16x12.png 16w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_2-380x290.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_2-590x450.png 590w\" sizes=\"(max-width: 780px) 100vw, 780px\" \/><figcaption class=\"wp-element-caption\">Benenne dein Projekt<\/figcaption><\/figure>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"839\" height=\"648\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_3.png\" alt=\"Konfiguriere Google Analytics\" class=\"wp-image-58261\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_3.png 839w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_3-768x593.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_3-16x12.png 16w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_3-380x293.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_3-590x456.png 590w\" sizes=\"(max-width: 839px) 100vw, 839px\" \/><figcaption class=\"wp-element-caption\">Konfiguriere Google Analytics, falls gew\u00fcnscht<\/figcaption><\/figure>\n<\/div><\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Nach dem das Projekt erstellt wurde, f\u00fcge die Dienste &#8220;Echtzeitdatenbank&#8221; und &#8220;Authentifizierung&#8221; zu deinem Projekt hinzu.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"839\" height=\"648\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_4.png\" alt=\"Erstellen der ben\u00f6tigten Dienste\" class=\"wp-image-58265\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_4.png 839w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_4-768x593.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_4-16x12.png 16w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_4-380x293.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_4-590x456.png 590w\" sizes=\"(max-width: 839px) 100vw, 839px\" \/><figcaption class=\"wp-element-caption\">Erstellen der ben\u00f6tigten Dienste<\/figcaption><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">Firebase Authentifizierung<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Um die Authentifizierung nutzen zu k\u00f6nnen, solltest du mindestens die Registrierung per Mail und Passwort aktivieren. Dies ist auch die Standard-Loginmethode f\u00fcr das App Template. Alle weiteren Dienste sind aktuell noch nicht umgesetzt.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"1179\" height=\"372\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_5.png\" alt=\"Anmeldemethoden verwalten und erstellen\" class=\"wp-image-58264\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_5.png 1179w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_5-768x242.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_5-18x6.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_5-380x120.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_5-590x186.png 590w\" sizes=\"(max-width: 1179px) 100vw, 1179px\" \/><figcaption class=\"wp-element-caption\">Anmeldemethoden verwalten und erstellen<\/figcaption><\/figure>\n<\/div>\n\n\n<h3 class=\"wp-block-heading\">Firebase Realtime Database<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Zum Speichern der Daten ist eine Datenbank erforderlich. Diese kannst du ebenfalls mit ein paar Klicks erstellen. Klicke dazu unter &#8220;Entwickeln&#8221; auf &#8220;Realtime Database&#8221; und anschlie\u00dfend auf &#8220;Datenbank erstellen&#8221;. Folge den Schritten bis zum Abschluss.<\/p>\n\n\n\n<div class=\"wp-block-columns is-layout-flex wp-container-core-columns-is-layout-8f761849 wp-block-columns-is-layout-flex\">\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"801\" height=\"367\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_6.png\" alt=\"Speicherort der Datenbank ausw\u00e4hlen (USA ist empfohlen)\" class=\"wp-image-58268\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_6.png 801w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_6-768x352.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_6-18x8.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_6-380x174.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_6-590x270.png 590w\" sizes=\"(max-width: 801px) 100vw, 801px\" \/><figcaption class=\"wp-element-caption\">Speicherort der Datenbank ausw\u00e4hlen (USA ist empfohlen)<\/figcaption><\/figure>\n<\/div><\/div>\n\n\n\n<div class=\"wp-block-column is-layout-flow wp-block-column-is-layout-flow\"><div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"804\" height=\"581\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_7-1.png\" alt=\"Einrichten der Sicherheitsregel (hier im Testmodus starten)\" class=\"wp-image-58270\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_7-1.png 804w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_7-1-768x555.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_7-1-18x12.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_7-1-600x435.png 600w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_7-1-380x275.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_7-1-590x426.png 590w\" sizes=\"(max-width: 804px) 100vw, 804px\" \/><figcaption class=\"wp-element-caption\">Einrichten der Sicherheitsregel (hier im Testmodus starten)<\/figcaption><\/figure>\n<\/div><\/div>\n<\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Anschlie\u00dfend m\u00fcssen die Sicherheitsregeln \u00fcberarbeitet werden. Aktuell hat jeder Zugriff auf alle Daten. Du kannst folgende Sicherheitsregel als Grundlage verwenden.<\/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;rules&quot;: {\n   \/* Access for custom folders (preset data for instance)\n   &quot;Printers&quot;:{\n     &quot;.read&quot;: &quot;auth != null&quot;,\n     &quot;.write&quot;: false,\n   },\n   *\/\n   &quot;users&quot;: {\n      &quot;$uid&quot;: {\n        &quot;.write&quot;: &quot;$uid === auth.uid&quot;,\n        &quot;.read&quot;: &quot;$uid === auth.uid&quot;,\n      }\n   }\n \t}\n}<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Hier ist es allen erlaubt zu lesen, welche sich Authentifiziert haben (\u00fcber API-Schl\u00fcssel oder Anmeldung). Des Weiteren k\u00f6nnen Benutzer (&#8220;users&#8221;) unter dem Datenbankpfad &#8220;users&#8221;, dort wo die Benutzerdaten abgelegt werden, nur unter Ihrer ID Schreiben und Lesen.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">App konfigurieren<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Abschlie\u00dfend muss die App konfiguriert werden, dass diese mit dem Firebase Projekt interagieren kann. Dazu musst du erst eine &#8220;Web App&#8221; in Firebase erstellen. Klicke dazu auf das &#8220;&lt;\/&gt;&#8221; Symbol.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"873\" height=\"344\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_9.png\" alt=\"Neue Web-App erstellen\" class=\"wp-image-58276\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_9.png 873w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_9-768x303.png 768w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_9-18x7.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_9-380x150.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_9-590x232.png 590w\" sizes=\"(max-width: 873px) 100vw, 873px\" \/><figcaption class=\"wp-element-caption\">Neue Web-App erstellen<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Anschlie\u00dfend gib deiner App noch einen passenden Namen und best\u00e4tige das Setup mit &#8220;App registrieren&#8221;.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full\"><img decoding=\"async\" width=\"757\" height=\"483\" src=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_10.png\" alt=\"Neue Web App registrieren\" class=\"wp-image-58277\" srcset=\"https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_10.png 757w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_10-18x12.png 18w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_10-380x242.png 380w, https:\/\/ar3dp.de\/wp-content\/uploads\/2023\/07\/maui_app_template_firebase_10-590x376.png 590w\" sizes=\"(max-width: 757px) 100vw, 757px\" \/><figcaption class=\"wp-element-caption\">Neue Web App registrieren<\/figcaption><\/figure>\n<\/div>\n\n\n<p class=\"wp-block-paragraph\">Nun erh\u00e4ltst du alle n\u00f6tigen Zugangsdaten, welche unser App-Template ben\u00f6tigt, um mit deinem Firebase Projekt zu interagieren. Die Daten sehen wie folgt aus:<\/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-csrc&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;c&quot;}\">const firebaseConfig = {\n  apiKey: &quot;xxxxx_your_api_key&quot;,\n  authDomain: &quot;your_project.firebaseapp.com&quot;,\n  databaseURL: &quot;https:\/\/your_project-rtdb.firebaseio.com&quot;,\n  projectId: &quot;your_project&quot;,\n  storageBucket: &quot;your_project.appspot.com&quot;,\n  messagingSenderId: &quot;XXX&quot;,\n  appId: &quot;1:XXXXX&quot;,\n  measurementId: &quot;G-XXXXXXX&quot;\n};<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Diese Informationen m\u00fcssen nun in der <code>secrets.json<\/code> Datei eingegeben 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;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;FirebaseUri&quot;: &quot;https:\/\/your_project-rtdb.firebaseio.com&quot;,\t\t\t\/\/ The databaseURL\n    &quot;FirebaseSecret&quot;: &quot;xxxxx_your_secret_key&quot;,\t\t\t\t\t\t\t\/\/ The secret (obsolete)\n    &quot;FirebaseApiKey&quot;: &quot;xxxxx_your_api_key&quot;,\t\t\t\t\t\t\t\t\/\/ The apiKey\n    &quot;FirebaseAuthDomain&quot;: &quot;your_project.firebaseapp.com&quot;,\t\t\t\t\/\/ the authDomain\n    \/\/...\n  }\n}<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Der <code>DatabaseSecret<\/code> ist abgek\u00fcndigt und sollte nicht mehr verwendet werden. Stattessen sollte die Authentifizierung \u00fcber eine Anmeldung bzw. den API-Schl\u00fcssel erfolgen. Nichtsdestotrotz findest du das <code>Secret<\/code> unter &#8220;Projekteinstellungen -&gt; Dienstkonto -&gt; Datenbank-Secrets&#8221;.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Mehr zu der <code>secrets.json<\/code> Datei findest du in den <a href=\"https:\/\/ar3dp.de\/docs\/programmieren\/net-maui-basis-applikation-app-template\/erste-schritte\/\" target=\"_blank\" rel=\"noreferrer noopener\">Ersten Schritten<\/a>.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">FirebaseHandler<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Im App-Template \u00fcbernimmt die Helferklasse <code>FirebaseHandler<\/code> den Datenaustausch, sowie die Authentifizierung mit Firebase. Im <code>LoadingPageViewModel.Refresh()<\/code> wird, sofern sich schon ein Benutzer angemeldet hat, die Einstellungen synchronisiert. <\/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;}\">Func&lt;Task&gt; onSuccess = async () =&gt;\n{\n  var settings = await FirebaseHandler.Instance.GetAppSettingsDictionaryAsync();\n  await SettingsApp.LoadSettingsAsync(dictionary: settings);\n};\nif (!string.IsNullOrEmpty(SettingsApp.Firebase_Username) &amp;&amp; !string.IsNullOrEmpty(SettingsApp.Firebase_Password))\n{\n  await LoginFirebaseWithCredentialsAsync(SettingsApp.Firebase_Username, SettingsApp.Firebase_Password, onSuccess: onSuccess);\n}\nelse\n{\n  \/\/ If no account infos are available, login as anonymous (If allowed by your Firebase setup)\n  \/\/await LoginFirebaseAnonymouslyAsync(onSuccess: onSuccess);\n}<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Werden w\u00e4hrend der Laufzeit Einstellungen angepasst, so werde diese gleich Richtung Firebase synchronisiert.<\/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;}\">[ObservableProperty]\nbool allowAppTracking = false;\npartial void OnAllowAppTrackingChanged(bool value)\n{\n  if (!IsLoading)\n  {\n    SettingsApp.Privacy_AllowAppTracking = value;\n    SettingsApp.SettingsChanged = true;\n    #if FirebaseAuth\n      FirebaseHandler.Instance.SyncSettings(setting =&gt; SettingsApp.Privacy_AllowPersonalizedAds);\n    #endif\n    }\n  if (AllowAppTracking &amp;&amp; !IsLoading &amp;&amp; SettingsStaticDefault.Privacy_AllowPersonalizedAds)\n  {\n    Task.Run(RequestTrackingAuthorization);\n  }\n}<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Durch das \u00c4ndern der Einstellungen in der &#8220;Firebase Realtime Database&#8221;, wird automatisch ein <code>Event<\/code> ausgel\u00f6st und alle aktiven Applikationen benachrichtig. Um auf das Event reagieren zu k\u00f6nnen, wird beim Anmelden eine <code>Func<\/code> mitgegeben, welche die ge\u00e4nderten Einstellungen lokal aktualisiert.<\/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;}\">userInfo = await FirebaseHandler.Instance.LoginWithEmailAndPasswordAsyncAsync(username, password, onDataChanged: async (p) =&gt;\n{\n    \/\/ Save the users settings on any changes\n    await SettingsApp.LoadSettingsAsync(p.Item1, p.Item2);\n});\n\n\/\/....\n\nOnUserDataChangedEvent(new()\n{\n    User = CurrentUser,\n    SettingsKey = p.Item1,\n    ChangedSetting = data,\n});<\/pre><\/div>\n\n\n\n<p class=\"wp-block-paragraph\">Die gew\u00e4hrleistet, dass bei Mehrfachnutzung der Applikation, die Daten nicht auseinander laufen und eine Instanz die Daten der zweiten Instanz \u00fcberschreibt.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Firebase Synchronisierung Unser App-Template ist vorbereitet, Nutzerdaten, sowie Standard-Konfigurationen aus Firebase zu laden und zu synchronisieren. Dies erlaubt es, Nutzerdaten \u00fcber verschiedene Ger\u00e4te synchron zu halten. Um den Service zu aktivieren, definiere folgende Konstanten in der AppBasement.csproj Datei und f\u00fcge folgende Nuget-Pakete hinzu. Firebase einrichten Falls nicht vorhanden, ben\u00f6tigest du einen Account bei Firebase. Dieser&#8230;<\/p>","protected":false},"author":1,"featured_media":0,"parent":57992,"menu_order":9,"comment_status":"open","ping_status":"closed","template":"","meta":{"_featured":false,"_is_vendor_doc":"0","footnotes":""},"doc_tag":[],"class_list":["post-58257","docs","type-docs","status-publish","hentry"],"comment_count":0,"_links":{"self":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58257","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=58257"}],"version-history":[{"count":1,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58257\/revisions"}],"predecessor-version":[{"id":58687,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58257\/revisions\/58687"}],"up":[{"embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/57992"}],"next":[{"title":"License Manager","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/lizenz-manager\/","href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58290"}],"prev":[{"title":"Dipatching & UIThread","link":"https:\/\/ar3dp.de\/en\/docs\/programmieren\/net-maui-basis-applikation-app-template\/dipatching-uithread\/","href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/docs\/58002"}],"wp:attachment":[{"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/media?parent=58257"}],"wp:term":[{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/ar3dp.de\/en\/wp-json\/wp\/v2\/doc_tag?post=58257"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}