<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nico Alani -✨🛸☄️</title>
    <description>The latest articles on DEV Community by Nico Alani -✨🛸☄️ (@nicoalani).</description>
    <link>https://dev.to/nicoalani</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F677376%2F948f5838-ef7a-44dd-9b2b-a9460dfef646.jpg</url>
      <title>DEV Community: Nico Alani -✨🛸☄️</title>
      <link>https://dev.to/nicoalani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/nicoalani"/>
    <language>en</language>
    <item>
      <title>How to configure Firebase in Nativescript (Angular)</title>
      <dc:creator>Nico Alani -✨🛸☄️</dc:creator>
      <pubDate>Tue, 15 Jul 2025 23:25:15 +0000</pubDate>
      <link>https://dev.to/nicoalani/how-to-configure-firebase-in-nativescript-angular-2imo</link>
      <guid>https://dev.to/nicoalani/how-to-configure-firebase-in-nativescript-angular-2imo</guid>
      <description>&lt;h3&gt;
  
  
  1. Install Firebase Core
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install @nativescript/firebase-core
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2. Set Up a 🔥 Firebase Project
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In the Firebase Console, create a new project.&lt;/li&gt;
&lt;li&gt;Select &lt;strong&gt;Android&lt;/strong&gt; and/or &lt;strong&gt;iOS&lt;/strong&gt; as your target platform(s).&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Configure Your App ☎️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Follow the Firebase setup wizard to specify your app name and properties. This process will generate a google-services.json file for Android.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  4. Add Configuration File
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;App_Resources/Android/src/google-services.json
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Note: Ensure the file is placed inside the src directory.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  5. Initialize Firebase in Your App
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;In your \src\main.ts, add the following code:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;firebase&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@nativescript/firebase-core&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// ...rest of your code&lt;/span&gt;
&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;initializeApp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="c1"&gt;// ...rest of your code&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6. Clean and Run the Project
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ns clean
ns run android
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7. Troubleshooting: Initialization Error ⚠️
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you encounter the following error:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight powershell"&gt;&lt;code&gt;&lt;span class="n"&gt;Firebase&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;initialization&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;error:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Error:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;Cannot&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;read&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;properties&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;of&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="nx"&gt;undefined&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;reading&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s1"&gt;'FirebaseApp'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This usually indicates a problem with the Firebase configuration, often due to missing fingerprint authentication (SHA-1).&lt;/p&gt;




&lt;h2&gt;
  
  
  How to Add SHA-1 Fingerprint
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;In the Firebase Console, go to your project settings and locate the section to download the &lt;code&gt;google-services.json&lt;/code&gt; file and add a fingerprint.&lt;/li&gt;
&lt;li&gt;Generate your SHA-1 fingerprint by running the following command inside the &lt;code&gt;platforms/android&lt;/code&gt; directory:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt; ./gradlew signingReport
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;The output will include a section similar to:
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Variant: debug
Config: debug
Store: /.../.android/debug.keystore
Alias: AndroidDebugKey
SHA1: XX:XX:XX:XXXX:XXXX:XX:...
SHA-256: ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Copy the &lt;code&gt;SHA1&lt;/code&gt; value and add it to your Firebase project.&lt;/li&gt;
&lt;li&gt;Download the updated &lt;code&gt;google-services.json&lt;/code&gt; and repeat step 4 above (replace the file in &lt;code&gt;App_Resources/Android/src/&lt;/code&gt;).&lt;/li&gt;
&lt;li&gt;Run &lt;code&gt;ns clean&lt;/code&gt; and &lt;code&gt;ns run android&lt;/code&gt; again.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  8. Verifying the Integration
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You can verify initialization by logging the result of &lt;code&gt;firebase().initializeApp()&lt;/code&gt; in &lt;code&gt;main.ts&lt;/code&gt;, or by integrating Firebase Analytics to see events in realtime:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;@nativescript/firebase-analytics&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;initializeApp&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="nf"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;analytics&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;setAnalyticsCollectionEnabled&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nf"&gt;firebase&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;analytics&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;logEvent&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;app_start&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>nativescript</category>
      <category>angular</category>
      <category>firebase</category>
    </item>
  </channel>
</rss>
