<?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>Forem: Fatih</title>
    <description>The latest articles on Forem by Fatih (@akgoze).</description>
    <link>https://forem.com/akgoze</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%2F51260%2F76f654e8-5563-4c6c-adb9-a05aeac38a33.jpg</url>
      <title>Forem: Fatih</title>
      <link>https://forem.com/akgoze</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/akgoze"/>
    <language>en</language>
    <item>
      <title>Firebase Integration Challenges in React Native</title>
      <dc:creator>Fatih</dc:creator>
      <pubDate>Sun, 22 Dec 2024 12:38:41 +0000</pubDate>
      <link>https://forem.com/akgoze/firebase-integration-challenges-in-react-native-4119</link>
      <guid>https://forem.com/akgoze/firebase-integration-challenges-in-react-native-4119</guid>
      <description>&lt;p&gt;This article was originally published at &lt;a href="https://akgoze.medium.com/firebase-integration-challenges-in-react-native-518dabebd450" rel="noopener noreferrer"&gt;Medium&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I was working on a mobile app idea built with React Native. To quickly create a prototype and move forward with an MVP, we decided to use Firebase. However, we encountered several issues during the integration of Firebase with React Native, which took quite some time to resolve. Here’s a step-by-step guide detailing the problems we faced and their solutions.&lt;/p&gt;

&lt;h2&gt;
  
  
  Prebuild
&lt;/h2&gt;

&lt;p&gt;I used Expo when creating the React Native project. When starting Firebase integration, we will first run the prebuild command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx expo prebuild
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Expo CLI generates the native files necessary to compile the app. Actually, Expo abstracts away the need to interact with native code. However, when you want to use modules like Firebase that require native integrations, you will need to modify these files after running the prebuild command.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;During the prebuild process, you must specify a package name for Android and iOS in the app.json file. This serves as the app's identity, typically starting with a reversed domain name (e.g., com.company).&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "name": "TestApp",
  "slug": "test-app",
  "android": {
    "package": "com.company.TestApp"
  },
  "ios": {
    "bundleIdentifier": "com.company.TestApp"
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  React Native Firebase Installation
&lt;/h2&gt;

&lt;p&gt;Before integrating Firebase, you need to set up the necessary environments for both iOS and Android. You can follow the steps outlined in the &lt;a href="https://reactnative.dev/docs/set-up-your-environment?platform=ios" rel="noopener noreferrer"&gt;React Native documentation&lt;/a&gt; to install the required tools, such as Xcode for iOS development and the Java Development Kit and Android Studio for Android.&lt;/p&gt;

&lt;p&gt;Next, install the core Firebase package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install --save @react-native-firebase/app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you’re using Expo, follow these steps: &lt;a href="https://rnfirebase.io/#expo" rel="noopener noreferrer"&gt;Firebase Expo&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can also install additional Firebase modules based on your needs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx expo install 
    @react-native-firebase/auth 
    @react-native-firebase/firestore
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Afterward, add the following to the &lt;code&gt;plugins&lt;/code&gt; section in your &lt;code&gt;app.json&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"plugins": [
  "@react-native-firebase/app",
  "@react-native-firebase/auth",
  [
    "expo-build-properties",
    {
      "ios": {
        "useFrameworks": "static"
      }
    }
  ]
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Some packages may be incompatible with Expo modules, and adding them could result in build errors. If expo-build-properties is not installed, add it with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;expo install expo-build-properties
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This package helps manage iOS and Android build settings from a single location. The &lt;strong&gt;useFrameworks: “static”&lt;/strong&gt; setting is essential because Firebase requires static frameworks for iOS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Firebase Project Configuration
&lt;/h2&gt;

&lt;p&gt;Create a new Firebase project and add both iOS and Android apps. Other than the app name and package name (e.g., &lt;code&gt;com.company.TestApp&lt;/code&gt;), no additional information is needed. You will need the &lt;strong&gt;SHA-1&lt;/strong&gt; fingerprint for Android later during authentication setup.&lt;/p&gt;

&lt;p&gt;Download the service files: &lt;code&gt;GoogleService-Info.plist&lt;/code&gt; for iOS and &lt;code&gt;google-services.json&lt;/code&gt; for Android. Place them in your project directory and reference them in the app.json.&lt;/p&gt;

&lt;h2&gt;
  
  
  Reverse Client ID Error
&lt;/h2&gt;

&lt;p&gt;When running the prebuild command again after adding the service files, you might encounter the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: [ios.infoPlist]: withIosInfoPlistBaseMod:
[@react-native-firebase/auth] Failed to parse your GoogleService-Info.plist.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Are you sure it is a valid Info.Plist file with a REVERSED_CLIENT_ID field?&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54hi68sfzydm8iy1z0qh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F54hi68sfzydm8iy1z0qh.png" alt="REVERSED_CLIENT_ID Error" width="800" height="108"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Actually, the &lt;code&gt;CLIENT_ID&lt;/code&gt; and &lt;code&gt;REVERSED_CLIENT_ID&lt;/code&gt; keys are automatically generated and added to the service file. However, when you create the app for the first time, these keys might not be generated on Firebase's end.&lt;/p&gt;

&lt;p&gt;To resolve this, you need to enable &lt;strong&gt;Google Authentication&lt;/strong&gt; in Firebase. After doing so, download the new service files, which will now include the required keys.&lt;/p&gt;

&lt;p&gt;At this point, you’ll see a screen where you can download the service files again, and you’ll need the &lt;strong&gt;SHA-1&lt;/strong&gt; fingerprint for Android.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkg4zkh3rja5kk8xg4gbx.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkg4zkh3rja5kk8xg4gbx.png" alt="Image description" width="800" height="704"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding SHA-1 Fingerprint for Android
&lt;/h2&gt;

&lt;p&gt;Firebase Authentication for Android apps requires a SHA-1 fingerprint. To retrieve this, navigate to the android directory and run the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx expo prebuild
cd android
./gradlew signingReport
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you get a &lt;code&gt;BUILD FAILED&lt;/code&gt; error, verify your Java version. You may also need to check the Android SDK path.&lt;/p&gt;

&lt;p&gt;Create a &lt;code&gt;local.properties&lt;/code&gt; file in the android directory and add the following:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;# Replace "${USERNAME}" with your system username
sdk.dir=/Users/${USERNAME}/Library/Android/sdk
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;signingReport&lt;/code&gt; command is a Gradle task used in Android projects.&lt;/p&gt;

&lt;p&gt;It provides keystore information, including SHA-1 and SHA-256 signatures for both &lt;strong&gt;debug&lt;/strong&gt; and &lt;strong&gt;release&lt;/strong&gt; builds.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Variant: debug
Config: debug
Store: /Users/username/TestApp/android/app/debug.keystore
Alias: androiddebugkey
MD5: *:*:*:**:**:**:**:**:**:**:**:**:**:**:**:*
SHA1: *:*:*:**:**:**:**:**:**:**:**:**:**:**:**:*
SHA-256: *:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**:**
Valid until: Wednesday, May 1, 2052
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For development, use the &lt;strong&gt;debug&lt;/strong&gt; SHA-1 fingerprint and add it to the Android settings in Firebase, then download the updated service files.&lt;/p&gt;

&lt;h2&gt;
  
  
  Testing Registration with Firebase
&lt;/h2&gt;

&lt;p&gt;Once the Firebase setup is complete, you can test Firestore and Authentication using a simple registration flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import auth from '@react-native-firebase/auth';
import firestore from '@react-native-firebase/firestore';
import { Alert } from 'react-native';
import React, { useState } from 'react';
...


const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const register = async () =&amp;gt; {
  try {
    await auth().createUserWithEmailAndPassword(email, password);
    Alert.alert('Success', 'User account created &amp;amp; signed in!');
    createNewUser({ email, firstname: 'John', lastname: 'Doe' });
  } catch (error) {
    Alert.alert('Error', error.message);
  }
};
const createNewUser = async (user) =&amp;gt; {
  try {
    await firestore().collection('users').add(user);
    Alert.alert('Success', 'User added to Firestore!');
  } catch (error) {
    Alert.alert('Error', error.message);
  }
};
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Native Module Error
&lt;/h2&gt;

&lt;p&gt;While developing with Expo and Firebase, you may encounter the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ERROR  Invariant Violation:
Your JavaScript code tried to access a native module that doesn't exist.
...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3rrsfukbuizhydohzns.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft3rrsfukbuizhydohzns.png" alt="Image description" width="800" height="142"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This occurs because certain native modules are not fully compatible with Expo. To fix this, create a native development build by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx expo run:ios
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command will ensure that Firebase modules work correctly.&lt;/p&gt;

</description>
      <category>reactnative</category>
      <category>firebase</category>
    </item>
    <item>
      <title>The Short Story of JavaScript</title>
      <dc:creator>Fatih</dc:creator>
      <pubDate>Tue, 02 May 2023 06:54:51 +0000</pubDate>
      <link>https://forem.com/akgoze/the-short-story-of-javascript-2k65</link>
      <guid>https://forem.com/akgoze/the-short-story-of-javascript-2k65</guid>
      <description>&lt;p&gt;I heard that when I began learning JavaScript: “JavaScript has nothing to do with Java.” It’s still the first sentence on Wikipedia under the headline of JavaScript.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhcjsnmaizmxv2gqmzgum.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhcjsnmaizmxv2gqmzgum.png" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I don’t know why, but it came to my mind again on this weekend: If it’s not related to Java, then why is it called JavaScript? What is the meaning of ECMAScript if this is JavaScript? Who’s ECMA? What does Script mean? Then I found myself writing this post when I was deep-diving into all these issues.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;JavaScript&lt;/strong&gt; has been created by &lt;strong&gt;Brendan Eich&lt;/strong&gt; in &lt;strong&gt;1995.&lt;/strong&gt; It was the early days of &lt;strong&gt;WWW.&lt;/strong&gt; The web pages were nothing more than static text pages. Of course, after a while, people are looking for more dynamic interactions with websites. &lt;strong&gt;Netscape’s&lt;/strong&gt; team started working towards this. At least, &lt;strong&gt;Javascript&lt;/strong&gt; was created which is a scripting language for Netscape browsers.&lt;/p&gt;

&lt;p&gt;They used to call it &lt;strong&gt;Mocha&lt;/strong&gt; when it was still being developed. Then obtained &lt;strong&gt;‘LiveScript’&lt;/strong&gt; as a name within the test process. At least, in 1997, changed the name LiveScript as &lt;strong&gt;JavaScript&lt;/strong&gt; with the beta of &lt;strong&gt;Netscape Navigator 2.0.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;While Javascript has no direct relativity to Java, it is made confusing for people. Although there was no relation as technologically, it has an indirect connection.&lt;/p&gt;

&lt;p&gt;In the ’90s, &lt;strong&gt;Netscape&lt;/strong&gt; had a major rival in the browser war. &lt;strong&gt;This was Microsoft.&lt;/strong&gt; In 1995, Micros developed Internet Explorer and made it part of its operating systems. Then Netscape started working on an operational system. They invest and support to Java language. They also plan to use Javascript as their scripting language for this operating system. As a result, they selected Java as the name for marketing.&lt;/p&gt;

&lt;p&gt;While adding JavaScipt inside the browser, Netscape has opened developing new kind of website. Then Microsoft announced a new scripting language that was added to Explorer. They called JScript.&lt;/p&gt;

&lt;p&gt;In 1996, Netscape applied to ECMA for defining JavaScript as industrial standards. In 1997, ECMA published ECMAScript Language Specification for scripting language standardization.&lt;br&gt;
So What and Who is ECMA?&lt;/p&gt;

&lt;p&gt;Now let’s go to ECMA. ECMA (European computer manufacturers Association) is a non-profit organization that aims to develop standards for computer hardware, software languages, and communication technologies.&lt;/p&gt;

&lt;p&gt;The QWERTY layout for keyboards is one of the standards defined by ECMA. Also, ECMA has set standards for a lot of software and hardware technologies, from floppy disks to C languages, and then they prepare international standards.&lt;br&gt;
They have named ECMA-262 as standard for Javascript. In 1997, ECMA began work to develop the standard. They got JScript and Javascript as a reference point for the new script language standard and they call it ECMAScript. As noted in ECMAScript standards;&lt;/p&gt;

&lt;p&gt;ECMAScript is based on several originating technologies, the most well-known being JavaScript (Netscape) and JScript (Microsoft).&lt;/p&gt;

&lt;p&gt;The last version was published in June 2021 as the 12th version. The other term is TC39 (Technical Committee 39) that you can see so many times in the document. This term defines the group responsible for the development of ECMA-262.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is ECMAScript?
&lt;/h2&gt;

&lt;p&gt;ECMAScript is a term that uses defines the standardization of the scripting language. These standards define what a scripting language requires with functions and rules.&lt;/p&gt;

&lt;p&gt;We may say that JavaScript is a scripting language that follows the rules and functions that define in ECMAScript.&lt;/p&gt;

&lt;p&gt;If we say that JS is the language we use, then ECMAScript is the standard of such languages. You can learn how to create a scripting language by looking at ECMAScript’s standards and learn how to use JavaScript by reading the JavaScript documentation.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Scripting — Script Language?
&lt;/h2&gt;

&lt;p&gt;We have called script or script language up to now, but what is script language?&lt;br&gt;
Software languages can be separated into three groups:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Programming languages,&lt;/li&gt;
&lt;li&gt;Scripting languages&lt;/li&gt;
&lt;li&gt;Markup languages.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Programming languages&lt;/strong&gt; are essentially defined software languages that we can tell computers what to do. These languages make it possible to manage the hardware by compiling in machine language.&lt;/p&gt;

&lt;p&gt;Moreover, &lt;strong&gt;scripting languages&lt;/strong&gt; are different from the programming language, and in fact, we can position them as a subgroup of programming languages.&lt;/p&gt;

&lt;p&gt;The script, in the dictionary, refers to the series of instructions, writing using a particular alphabet or a set of works to be made as a scenario. Like a meaning word, script languages are an automated series of statements executed in a particular order.&lt;/p&gt;

&lt;p&gt;Scripting languages are programs that work at the runtime, read and interpret by programs without compilation. These are domain-specific languages. So they just work for a certain job.&lt;/p&gt;

&lt;p&gt;JavaScipt is a good example of scripting languages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Runs only inside browsers.&lt;/li&gt;
&lt;li&gt;Can’t be compiled.&lt;/li&gt;
&lt;li&gt;It is interpreted directly in runtime.&lt;/li&gt;
&lt;li&gt;It may modify HTML documents.&lt;/li&gt;
&lt;li&gt;Not direct access to the hardware.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;JavaScript became the first language in the list of popular software languages for several years. JavaScript gets new updates through 2016 quickly and more than in the past. As written in the documentation, JavaScript is still live and it has not yet completed its evolution, and it will continue to grow with new features.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>ecmascript</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
  </channel>
</rss>
