<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Abhishek sharma on Medium]]></title>
        <description><![CDATA[Stories by Abhishek sharma on Medium]]></description>
        <link>https://medium.com/@shabhi?source=rss-1ffa27f2acdb------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*2B-a6Ld1ZJtFib8NUJAgsA.jpeg</url>
            <title>Stories by Abhishek sharma on Medium</title>
            <link>https://medium.com/@shabhi?source=rss-1ffa27f2acdb------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 23:02:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@shabhi/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[How actually a full-stack web application works]]></title>
            <link>https://medium.com/@shabhi/how-actually-a-full-stack-web-application-works-7a8822a49b80?source=rss-1ffa27f2acdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a8822a49b80</guid>
            <category><![CDATA[full-stack-developer]]></category>
            <category><![CDATA[mern-stack]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[api]]></category>
            <category><![CDATA[system-architecture]]></category>
            <dc:creator><![CDATA[Abhishek sharma]]></dc:creator>
            <pubDate>Mon, 24 Oct 2022 08:39:32 GMT</pubDate>
            <atom:updated>2022-10-24T08:39:32.478Z</atom:updated>
            <content:encoded><![CDATA[<p>When I was in my initial phase of learning it was very difficult for me to figure out how a Full-Stack Web Application works, and what is the role of the Backend, Database, Frontend, etc. Let’s cover the whole thing with a story, stay tuned.</p><p>John goes to the restaurant, After going through the menu John calls the waiter and orders the “Mushroom pizza”. The waiter takes the order and goes to the chef with John’s order.</p><p>The chef goes through the available options and tells the waiter that this option is not available right now please tell John to order from other available options, the waiter goes to John and delivers the same message as told.</p><p>John chooses “Cheese Pizza” this time and delivers the order to the waiter, the waiter again goes to the chef and delivers John’s order, chef checks the available options and this time chef was able to provide the pizza, as soon as the pizza is ready the waiter takes the order and deliver to John’s table.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JMrmYQbXQFSW1pKlLVNVCg.png" /><figcaption>Basic Architecture of a Full-Stak Web Application</figcaption></figure><p>Let me break down this story that you have just read. Every Full-Stack Web Application is divided into major three parts which are Frontend, Backend, and Database. Another salient part is API which acts as a communication medium between the Frontend and Backend.</p><p>In this story, the Frontend is John(Client), the Waiter is API, Chef is the Backend, and the storage unit from where Chef is checking the available options is Database.</p><p>Whenever a user submits any form or clicks to play any video or perform any event from frontend the API takes the request from the client(Frontend) to the backend, the backend performs the required operations by syncing with the Database(if required) and Provides with the expected solution to the API and API deliver the result to the Client(Frontend) with the successful message or expected video, etc.</p><p>I hope now you can feel how even a small operation is being handled in a full-stack web application. I tried to keep this concept as simple as possible if you have any queries please let me know in the comments.</p><p>Thank you :)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a8822a49b80" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make one to one chat system with firebase in react native expo (Part 3).]]></title>
            <link>https://medium.com/@shabhi/how-to-make-one-to-one-chat-system-with-firebase-in-react-native-expo-part-3-988edf9357da?source=rss-1ffa27f2acdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/988edf9357da</guid>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[expo-react-native]]></category>
            <category><![CDATA[mobile-application]]></category>
            <category><![CDATA[react-native-app]]></category>
            <category><![CDATA[chat-application]]></category>
            <dc:creator><![CDATA[Abhishek sharma]]></dc:creator>
            <pubDate>Tue, 31 Mar 2020 12:31:40 GMT</pubDate>
            <atom:updated>2020-03-31T12:31:40.289Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*7SmY8ITMTca2s0UlC9ELWA.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*UiYP0_JVuGrW2SJt56DXlA.jpeg" /><figcaption>fig 1.0- chat screen, fig 2.0- Homepage screen</figcaption></figure><p>This is going to be the last part of this project. In this part, we will work on the Homepage screen (user.js) file and Chat screen(chatRoom.js) and also we are going to continue with the remaining steps. So let’s start.</p><h3>STEP SIX:-</h3><h4>1. user.js</h4><pre>import React, { Component } from &#39;react&#39;<br>import {StyleSheet,Text,View,Image,TouchableOpacity,ScrollView,<br>Dimensions,AsyncStorage,TextInput} from &#39;react-native&#39;<br>const screenWidth = Math.round(Dimensions.get(&#39;window&#39;).width)<br>import firebaseSvc from &#39;../firebaseSDK&#39;</pre><pre>export default class Users extends Component {</pre><pre>constructor(){<br>super()<br>this.state={auth_data:[],uid:&#39;&#39;,uname:&#39;&#39;,uemail:&#39;&#39;}}</pre><pre>componentWillMount=()=&gt;{<br>this._retrieveData()<br>this.User_data()}</pre><pre>_retrieveData = async () =&gt; {<br>let u_id = this.props.navigation.getParam(&#39;uid&#39;)<br>let u_name = this.props.navigation.getParam(&#39;userName&#39;)<br>let u_email = this.props.navigation.getParam(&#39;uemail&#39;)<br>this.setState({uid:u_id,uname:u_name,uemail:u_email})}</pre><pre>User_data=()=&gt;{<br>firebaseSvc.usersData().then((solve)=&gt;{<br>this.setState({auth_data:solve})}).catch((fail)=&gt;{console.log(&#39;not getting data&#39;)})}</pre><pre>render() {<br>let Data=this.state.auth_data<br>let User=Data.map((u_data)=&gt;{</pre><pre>return(<br>  &lt;View style={styles.backarrow}&gt;<br>   &lt;TouchableOpacity onPress={()=&gt;          this.props.navigation.navigate(&#39;ChatRoom&#39;,{uemail:this.state.uemail,<br>uid:this.state.uid,uname:this.state.uname,fid:u_data.uid,fname:u_data.name,femail:u_data.email})}&gt;<br>   &lt;View style={styles.list}  &gt;<br>    &lt;View  style={ styles.forwidth_left}&gt;<br>      &lt;TouchableOpacity &gt;<br>        &lt;Image style={{width: 70,height: 70,borderRadius:87,                     position:&#39;absolute&#39;,top:0,left:0}} <br>source={require(&#39;../assets/images/no_image.jpg&#39;)} /&gt;<br>      &lt;/TouchableOpacity&gt;<br>    &lt;/View&gt;</pre><pre>    &lt;View style={ styles.forwidth_right}&gt;<br>      &lt;Text style={ styles.price}&gt; {u_data.name}&lt;/Text&gt;<br>      &lt;Text style={ styles.carname}&gt; {u_data.email}&lt;/Text&gt;<br>    &lt;/View&gt;<br>   &lt;/View&gt;<br> &lt;/TouchableOpacity&gt;<br>&lt;/View&gt;<br> )<br>})<br>return (<br>&lt;View style={styles.container}&gt;<br>  &lt;TouchableOpacity&gt;<br>   &lt;View style={styles.top_header}  &gt;<br>  &lt;TouchableOpacity&gt;</pre><pre> &lt;Image style={styles.nav_icon} source=  {require(&#39;../assets/images/nav.png&#39;)} /&gt;<br>  &lt;/TouchableOpacity&gt;<br>  &lt;TouchableOpacity&gt;<br>    &lt;View style={styles.search_header} &gt;</pre><pre>    &lt;Image style={styles.search_icon} source=  {require(&#39;../assets/images/search.png&#39;)} /&gt;</pre><pre>    &lt;TextInput  style={styles.search_box}keyboardType=&#39;web-     search&#39;placeholder=&#39;search name&#39;/&gt;<br>      &lt;/View&gt;<br>    &lt;/TouchableOpacity&gt;<br>   &lt;/View&gt;<br> &lt;/TouchableOpacity&gt;<br>&lt;View style={styles.home_padding}&gt;<br>&lt;ScrollView&gt;<br>  {User}<br>  &lt;/ScrollView&gt;<br>&lt;/View&gt;&lt;/View&gt;<br>)}}</pre><p>This is the code snippet that will give you a Homepage screen in which all users will be shown in the form of a list who have registered in the application. So it will be easy for a user to choose the person he wants to chat with. But this code snippet is not completed yet because in this code snippet some functionalities are pending which we are going to complete in the firebaseSDK.js file.</p><h4>2. firebaseSDK.js</h4><p>Remember <a href="https://medium.com/@alphaq1205/how-to-make-one-to-one-chat-system-with-firebase-in-react-native-expo-part-2-8e0fb8fd1367">Step Four</a>, In that step, we have stored data in the firebase cloud firestore of users who had registered in the application, therefore, we are going to retrieve the user details and we will use that data in our Homepage screen to show the available users in a list form.</p><pre>usersData=()=&gt;{<br>let all=[]<br>  return new Promise((resolve,reject)=&gt;{<br>   var docRef = firebase.firestore().collection(&quot;chatie_user&quot;)<br>     docRef.get().then(function(querySnapshot) {<br>       querySnapshot.forEach(function(doc) {<br>         all.push(doc.data())<br>       },resolve(all))<br>     })<br>  })<br>}</pre><p>Import this function from the firebaseSDK.js file to user.js file and that’s all. This will give you all the user details stored in the cloud firestore.</p><h3>STEP SEVEN:-</h3><p>This is the last step and then we are done. In this part, we will write the code for the chat screen.</p><h4>chatRoom.js</h4><pre>import React, { Component } from &#39;react&#39;;<br>import{StyleSheet,Text,View,TouchableOpacity,Image,ScrollView,Dimensions,TextInput,} from &#39;react-native&#39;;<br>import firebaseSvc from &#39;../firebaseSDK&#39;<br>const screenHeight = Math.round(Dimensions.get(&#39;window&#39;).height);</pre><pre>export default class Chat extends Component {<br>render() {</pre><pre>componentWillMount=()=&gt;{<br> firebaseSvc.refOn().then((solve)=&gt;{<br>  this.setState({chatData:solve})<br> }).catch((fail)=&gt;{<br>   console.log(fail)<br>})<br>this.retrieveData()}</pre><pre>retrieveData = async() =&gt; {<br>let fid = this.props.navigation.getParam(&#39;fid&#39;)<br>let fname = this.props.navigation.getParam(&#39;fname&#39;)<br>let femail = this.props.navigation.getParam(&#39;femail&#39;)<br>let uid = this.props.navigation.getParam(&#39;uid&#39;)<br>let uname = this.props.navigation.getParam(&#39;uname&#39;)<br>let uemail = this.props.navigation.getParam(&#39;uemail&#39;)<br>this.setState({f_email:femail,f_id:fid,f_name:fname,u_id:uid,u_name:uname,u_email:uemail})<br>}</pre><pre>onSend=()=&gt;{<br>  this.textInput.clear()<br>firebaseSvc.send(this.state.f_id,this.state.f_email,this.state.text,this.state.u_id,this.state.u_email,this.state.u_name)<br>  firebaseSvc.refOn().then((solve)=&gt;{<br>    this.setState({chatData:solve})<br>   }).then(()=&gt;{<br>  let data=this.state.chatData<br>}).catch((fail)=&gt;{console.log(fail)})}</pre><pre>render() {<br>let Data=this.state.chatData<br>let chats=Data.map((c_data)=&gt;{<br>  if(this.state.f_id==c_data.fid &amp;&amp; this.state.u_id==c_data.user.uid || this.state.f_id==c_data.user.uid &amp;&amp; this.state.u_id==c_data.fid){<br>    if(this.state.u_id==c_data.user.uid){<br>       return(<br>          &lt;View style={{backgroundColor:&quot;#91d0fb&quot;,marginLeft:&#39;50%&#39;,<br>borderRadius:4,marginBottom:20,width:&#39;50%&#39;,maxWidth: 500,padding: 15,borderRadius: 20,}}&gt;<br>     &lt;Text style={{fontSize:16,color:&quot;#000&quot; }}&gt; {c_data.text}&lt;/Text&gt;&lt;/View&gt;)<br>}else{<br>  return(<br>    &lt;View style={{backgroundColor:&quot;#dedede&quot;,borderRadius:4,marginBottom:20,width:&#39;50%&#39;,maxWidth: 500,padding: 15,borderRadius: 20,}}&gt;</pre><pre>&lt;Text style={{fontSize:16,color:&quot;#000&quot; }}&gt; {c_data.text}&lt;/Text&gt;<br>&lt;/View&gt;)}}})<br>  <br> return (<br>   &lt;View style={styles.container}&gt;<br>     &lt;View style={{height:screenHeight - 150,marginVertical: 20,<br>flex: 1,flexDirection: &#39;row&#39;,backgroundColor:&quot;#eeeeee&quot;,<br>borderRadius:10,padding:0,}}&gt;<br>&lt;ScrollView&gt;{chats}&lt;/ScrollView&gt;<br>&lt;/View&gt;<br>&lt;View style={styles.footer}&gt;<br>  &lt;View style={styles.inputContainer}&gt;<br>   &lt;TextInput style={styles.inputs} placeholder=&quot;Write a message...&quot;<br>underlineColorAndroid=&#39;transparent&#39;ref={input =&gt; { this.textInput = input }}<br>onChangeText={(msg) =&gt; this.setState({text:msg})}/&gt;<br>   &lt;/View&gt;<br>  &lt;TouchableOpacity style={styles.btnSend} onPress={this.onSend}&gt;<br> &lt;Image source={{uri:&quot;https://png.icons8.com/small/75/ffffff/filled-sent.png&quot;}} style={styles.iconSend}  /&gt;<br>  &lt;/TouchableOpacity&gt;<br>&lt;/View&gt;&lt;/View&gt;)}}</pre><p>I know this code snippet is looking pretty heavy but this is the last piece of the puzzle so we have to go with that. This code snippet is not complete yet, as usual, we have to write the functionality for retrieving and sending chat data to the firebase realtime database in the firebaseSDK.js file.</p><h4>firebaseSDK.js</h4><pre>refOn =() =&gt; {<br>  return new Promise((resolve,reject)=&gt;{<br>  let cData=[]<br>  this.ref.on(&#39;child_added&#39;, function (snapshot) {<br>  const { timestamp: numberStamp, text, user,name,femail,fid } = snapshot.val()<br>  const { key: id } = snapshot<br>  const { key: _id } = snapshot<br>  const timestamp = new Date(numberStamp)<br>  const message = {femail,fid,text,timestamp,user}<br> cData.push(message)<br>resolve(cData)<br>   })<br> })<br>}</pre><pre>send=(fid,femail,text,uid,uemail,uname)=&gt;{<br>  firebase.database().ref(&#39;chat_messages/&#39;).push({&#39;fid&#39;:fid,<br>    &#39;femail&#39;:femail,&#39;text&#39;:text,user:  {&#39;uid&#39;:uid,&#39;uemail&#39;:uemail,&#39;uname&#39;:uname}<br>  }).then((data)=&gt;{<br>     console.log(&#39;data &#39; , data)<br>  }).catch((error)=&gt;{<br>     console.log(&#39;error &#39; , error)<br>})<br>}</pre><p>Add this code snippet to your firebaseSDK.js file. There are two functions written in this code snippet one for sending chat data and second for getting chat data from the firebase realtime database.</p><p>Congratulations, this is it and now you are ready to make your own chat application in react native expo. <a href="https://docs.expo.io/versions/latest/distribution/building-standalone-apps/">Build application APK</a> and use it in any way you want.</p><ul><li>You can get full code here: <a href="https://github.com/alphaq1205/Chatie.git">https://github.com/alphaq1205/Chatie.git</a></li></ul><h4>REFERENCE</h4><ul><li><a href="https://blog.expo.io/how-to-build-a-chat-app-with-react-native-3ef8604ebb3c">https://blog.expo.io/how-to-build-a-chat-app-with-react-native-3ef8604ebb3c</a></li><li><a href="https://firebase.google.com/docs/auth/android/firebaseui">https://firebase.google.com/docs/auth/android/firebaseui</a></li><li><a href="https://firebase.google.com/docs/database">https://firebase.google.com/docs/database</a></li><li><a href="https://firebase.google.com/docs/firestore">https://firebase.google.com/docs/firestore</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=988edf9357da" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make one to one chat system with firebase in react native expo (Part 2).]]></title>
            <link>https://medium.com/@shabhi/how-to-make-one-to-one-chat-system-with-firebase-in-react-native-expo-part-2-8e0fb8fd1367?source=rss-1ffa27f2acdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/8e0fb8fd1367</guid>
            <category><![CDATA[chat-system]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[expo-react-native]]></category>
            <dc:creator><![CDATA[Abhishek sharma]]></dc:creator>
            <pubDate>Tue, 25 Feb 2020 07:14:13 GMT</pubDate>
            <atom:updated>2020-02-25T07:21:49.429Z</atom:updated>
            <content:encoded><![CDATA[<h4>Login Screen + Signup Screen + Firebase API-Configuration</h4><h3>It’s Time To Code Now</h3><p>We have set up our <a href="https://medium.com/@alphaq1205/how-to-make-one-to-one-chat-system-with-firebase-in-react-native-expo-part-1-86d2ca11779b">firebase account</a>, authentication, and database so far in the first part of this series. In this part, we are going to make functional Signup and Login screens before that we have to set up our application screens.</p><p>Open the starter snack <a href="https://snack.expo.io/@alphaq001/fadcad">from here</a></p><h4>First Step:-</h4><p>We will create files for our applications screens which are:-</p><ul><li>signup.js</li><li>login.js</li><li>users.js</li><li>chatRoom.js</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BcWpk33Lge6AsuuEjR3AUg.png" /></figure><h4>Step Two:-</h4><p>Now we are going connect all these screens. First we have to add “react-navigation” so that we can navigate between screens and “react-navigation-stack” which provides a way for your app to transition between screens and manage <strong>navigation</strong> history. Initially, these screens will be blank, one by one we will look into the functionalities and UI of each screen.</p><pre>import React, { Component } from &#39;react&#39;<br>import { View, StyleSheet } from &#39;react-native&#39;<br>export default class Basic extends Component {<br>  render() {<br>    return &lt;View /&gt;;<br>  }<br>}const styles = StyleSheet.create({})</pre><p>Add this part of code on every component with the class name of your choice. This is important or else errors will pop up.</p><h4>App.js</h4><pre>import React,{Component} from &#39;react&#39;<br>import { createStackNavigator } from &#39;react-navigation-stack&#39;<br>import {  createAppContainer } from &#39;react-navigation&#39;</pre><pre>import Login from &#39;./components/login&#39;<br>import Sinup from &#39;./components/sinup&#39;<br>import Users from &#39;./components/users&#39;<br>import ChatRoom from &#39;./components/chatRoom&#39;</pre><pre>const AppNavigator = createStackNavigator(<br>{<br>  Login:Login,<br>  Sinup:Sinup, <br>  Users:Users,<br>  ChatRoom:ChatRoom,<br>},<br>{<br>  headerMode: &#39;none&#39;,<br>  navigationOptions: {<br>    headerVisible: false, <br> }<br>},<br>{<br>  initialRouteName: &#39;Login&#39;<br>}<br>)</pre><pre>const AppContainer = createAppContainer(AppNavigator)<br>export default class App extends Component{<br>  render(){<br>    return &lt;AppContainer/&gt;<br> }  <br>}</pre><p>In App.js, we have linked all the screens. Now it’s time to discuss functionalities and basic UI of each and every screen.</p><h4>Step Three:-</h4><h4>firebaseSDK.js</h4><pre>import firebase from &#39;firebase&#39;<br>import &#39;@firebase/firestore&#39;</pre><pre>const config = {<br>  apiKey: &quot;********************************&quot;,<br>  authDomain: &quot;*****************************&quot;,<br>  databaseURL: &quot;***********************************&quot;,<br>  projectId: &quot;**********&quot;,<br>  storageBucket: &quot;**********************&quot;,<br>  messagingSenderId: &quot;************&quot;,<br>}</pre><pre>class FirebaseSvc {<br>constructor() {<br> if (!firebase.apps.length) {<br>    firebase.initializeApp(config);<br> } else {<br>     console.log(&quot;firebase apps already running...&quot;)<br>    }<br>  }<br>}</pre><p>Add this part of code to firebaseSDK.js file and replace the “*************” to your firebase configuration. Now you are connected to your firebase and can access all its properties (for e.g its database, storage, authentication, etc.) We will write all the functionalities of our screen that needs access to firebase properties. This part is done here let’s move to the functionalities of the signup screen.</p><h4>Step Four:-</h4><h4>firebaseSDK.js</h4><pre>createAccount = async (user) =&gt; {<br>return new Promise((resolve,reject)=&gt;{<br>  firebase.auth()<br>   .createUserWithEmailAndPassword(user.email, user.password)<br>   .then(function(pass){</pre><pre>var userf = firebase.auth().currentUser;<br>userf.updateProfile({ displayName: user.name})<br>.then(function() {<br> firebase.firestore().collection(&quot;chatie_user&quot;).doc(pass.user.uid).set({<br>   uid: pass.user.uid,<br>   email: pass.user.email,<br>   name:user.name,<br>   emailVerified:pass.user.emailVerified<br>  })<br> .then(function() {<br>console.log(&quot;Document successfully written!&quot;)<br>})<br>.catch(function(error) {<br>    console.error(&quot;Error writing document: &quot;, error)<br> })<br>alert(&quot;User &quot; + user.name + &quot; was created successfully. Please           login.&quot;)<br>}, function(error) {<br>     console.warn(&quot;Error update displayName.&quot;);<br>  })<br> }, function(error) {<br>      console.error(&quot;got error:&quot; + typeof(error) + &quot; string:&quot; +   error.message)<br>       alert(&quot;Create account failed. Error: &quot;+error.message);<br>   })<br> })<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9iCuv4Iy2cHmYAJRguRvwQ.png" /></figure><p>In this part of code, we write components to create a username, email, and password by using firebase.auth() and at the same time, we are saving this user data in the firebase cloud firestore by using firebase.firestore(). This data will be used in the upcoming users&#39; screen in which you will be able to select your user to whom you want to chat.</p><h4>Signup.js</h4><pre>import React,{Component} from &#39;react&#39;<br>import {View,Text,StyleSheet,TouchableOpacity,TextInput, Image, ImageBackground,ScrollView} from &#39;react-native&#39;<br>import firebaseSvc from &#39;../firebaseSDK&#39;</pre><pre>export default class Login extends Component{</pre><pre>constructor(){<br>  state = {<br>           name: &#39;&#39;, <br>           email: &#39;&#39;,<br>           password: &#39;&#39;,<br>         }<br>      }</pre><pre>onPressCreate = async () =&gt; {<br>    this.sinupData()<br>  }</pre><pre>sinupData=()=&gt;{<br>      const user = {<br>                name: this.state.name,<br>                email: this.state.email,<br>                password: this.state.password,<br>              }</pre><pre> firebaseSvc.createAccount(user).then((solve)=&gt;{<br>     console.log(&#39;this is sinup data==&gt;  &#39;+JSON.stringify(solve))<br>   }).catch((fail)=&gt;{<br>     console.log(&#39;not getting data.....................&#39;)<br>   })<br>}</pre><pre>onChangeTextEmail = email =&gt; this.setState({ email })<br>onChangeTextPassword = password =&gt; this.setState({ password })<br>onChangeTextName = name =&gt; this.setState({ name })</pre><pre>render(){<br>   return(<br>        &lt;View style={styles.container}&gt;<br>            &lt;ImageBackground  style={styles.loginbox} source=        {require(&#39;../assets/back_screen.jpg&#39;)} &gt;</pre><pre>            &lt;ScrollView&gt;<br>               &lt;View style={styles.padding_btm}&gt;<br>                &lt;TextInput style = {styles.input}<br>                           keyboardType=&#39;email-address&#39;<br>                           placeholder=&#39;Email or Mobile Num&#39;<br>                           onChangeText={this.onChangeTextEmail}<br>                           value={this.state.email}<br>                       /&gt;</pre><pre>                 &lt;TextInput style = {styles.input}<br>                            placeholder=&#39;Password&#39;<br>                            onChangeText={this.onChangeTextPassword}<br>                            value={this.state.password}<br>                         /&gt;</pre><pre>                  &lt;TextInput style = {styles.input}<br>                             placeholder=&#39;Name&#39;<br>                             onChangeText={this.onChangeTextName}<br>                             value={this.state.name}<br>                             secureTextEntry<br>                          /&gt;</pre><pre>           &lt;TouchableOpacity style={styles.buttonContainer} <br>                         onPress={this.onPressCreate}&gt;<br>               &lt;Text style={styles.buttonText}&gt;CREATE ACCOUNT&lt;/Text&gt;<br>           &lt;/TouchableOpacity&gt;<br>       &lt;/View&gt;<br>     &lt;/ScrollView&gt;<br>  &lt;/ImageBackground&gt;<br>&lt;/View&gt;<br>   )<br>  }<br>}<br></pre><p>In this part of the code, we create a basic UI for the screen along with handing over the required data to the parameter of the function that we have created in the firebaseSDK.js file for this page.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*S6PaXa_05helMUTHWRWLkQ.jpeg" /></figure><p>This is the basic UI of the signup screen through which we will get enough data to maintain the authentication of our application. The screen will look somewhat like this. You can manipulate the UI of the screen in the way you want. Now let&#39;s move to our last and final step.</p><h4>Step Five:-</h4><h4>firebaseSDK.js</h4><pre>login = async(user, success_callback, failed_callback) =&gt; {<br>  const output = await           <br>      firebase.auth()<br>        .signInWithEmailAndPassword(user.email,user.password)<br>        .then(success_callback, failed_callback)<br> }</pre><pre>loginData=()=&gt;{<br>   return new Promise((resolve,reject)=&gt;{<br>      firebase.auth().onAuthStateChanged(function(user) {<br>        if (user) {<br>           //console.log(&quot;user: &quot;, user);<br>           resolve(user)<br>           // User is signed in.<br>         } else {<br>            // No user is signed in.<br>              }<br>          })<br>     })<br> }</pre><p>This the code snippet which will be used for login authentication through google firebase, which gives a positive response only if the user has been registered successfully through the application.</p><h4>App.js</h4><pre>import React,{Component} from &#39;react&#39;<br>import{View,Text,StyleSheet,TouchableOpacity,TextInput,Image,ImageBackground,ScrollView,AsyncStorage} from &#39;react-native&#39;<br>import firebaseSvc from &#39;../firebaseSDK&#39;</pre><pre>export default class Login extends Component{<br> constructor(){<br>  super()<br>  this.state = {password: &#39;&#39;,user_Data:&#39;&#39;,uid:&#39;&#39;,username:&#39;&#39;,<br>                uemail:&#39;&#39;}<br>         }<br>onPressLogin = async () =&gt; {<br>     const user = {<br>          email: this.state.uemail,<br>          password: this.state.password,<br>       }<br>   const response =  firebaseSvc.login(user,this.loginSuccess,this.loginFailed,)<br>   this.Data_match()<br>}<br>Data_match=()=&gt;{<br>     firebaseSvc.loginData()<br>         .then((solve)=&gt;{this.setState({user_Data:solve})})<br>         .then(()=&gt;{<br>              let userData=this.state.user_Data<br>              this.setState({uid:userData.uid,<br>                    userName:userData.displayName,<br>                    uemail:userData.email})<br>         }).catch((fail)=&gt;{<br>     console.log(&#39;not getting data.....................&#39;)<br>   })<br> }<br>loginSuccess = async () =&gt; {<br>    this.props.navigation.navigate(&#39;Users&#39;, {uid:this.state.uid,<br>      userName:this.state.userName,uemail:this.state.email})}<br>loginFailed = () =&gt; {<br>   console.log(&#39;login failed ***&#39;);<br>   alert(&#39;Login failure. Please tried again.&#39;);<br> }<br> onChangeTextEmail = email =&gt; this.setState({ email });<br> onChangeTextPassword = password =&gt; this.setState({ password })<br>render(){<br>   return(<br>       &lt;View style={styles.container}&gt;<br>       &lt;ImageBackground  style={styles.loginbox} source=<br>                {require(&#39;../assets/back_screen.jpg&#39;)} &gt;<br>     &lt;ScrollView&gt;<br>        &lt;View style={styles.padding_btm}&gt;<br>        &lt;TextInput style = {styles.input}<br>                  keyboardType=&#39;email-address&#39;<br>                   placeholder=&#39;Email or Mobile Num&#39;<br>                   onChangeText={this.onChangeTextEmail}<br>                   value={this.state.email}<br>        /&gt;<br>        &lt;TextInput style = {styles.input}<br>                   placeholder=&#39;Password&#39;<br>                   secureTextEntry<br>                   onChangeText={this.onChangeTextPassword}<br>                   value={this.state.password}</pre><pre>          /&gt;<br>   &lt;TouchableOpacity style={styles.buttonContainer} onPress=       {this.onPressLogin}&gt;<br>       &lt;Text  style={styles.buttonText}&gt;LOGIN&lt;/Text&gt;     &lt;/TouchableOpacity&gt;<br>     &lt;TouchableOpacity style={styles.buttonContainer} onPress={() =&gt; this.props.navigation.navigate(&quot;Sinup&quot;)}&gt;<br>  &lt;Text  style={styles.buttonText}&gt;CREATE ACCOUNT NOW&lt;/Text&gt;         &lt;/TouchableOpacity&gt;<br>              &lt;/View&gt;<br>           &lt;/ScrollView&gt;<br>        &lt;/ImageBackground&gt;<br>     &lt;/View&gt;<br>   )<br> }<br>}</pre><p>This part of the code snippet is big (more details in my <a href="https://github.com/alphaq1205">GitHub repo</a>) but a lot of things are carried on the backend of this page, the reason being that this page is where a user is recognized, whose data is used in our homepage. In this page also we are handing over the required data to the parameter of the function that we have created in the firebaseSDK.js file as we have done before in the signup.js file.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/720/1*eqgz-N9upI6g94EG0zV58Q.jpeg" /></figure><p>The login screen will look pretty much like this. On the LOGIN button, I have called the function responsible for authentication. If the result is positive it will navigate to the Homepage or if the result is negative it will show the failure message in the form of an alert . Also, there is a signup screen for new users which can be accessed by clicking on CREATE ACCOUNT NOW. Isn&#39;t it looking pretty neat? That’s all for this part we have successfully create the authentication for our application and also completed 60% of our application.</p><p>The main part of this application that differs from the other chat system is going to begin in the next part. In that part, the user will able to choose his willing friend or the stranger to chat with so stay tuned…………</p><h4>LINKS</h4><p>The full project: <a href="https://github.com/alphaq1205/Chatie">https//github.com/alphaq1205/Chatie</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8e0fb8fd1367" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to make one to one chat system with firebase in react native expo (Part 1).]]></title>
            <link>https://medium.com/@shabhi/how-to-make-one-to-one-chat-system-with-firebase-in-react-native-expo-part-1-86d2ca11779b?source=rss-1ffa27f2acdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/86d2ca11779b</guid>
            <category><![CDATA[one-to-one-chat-system]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[chat-system]]></category>
            <category><![CDATA[firebase]]></category>
            <category><![CDATA[expo-react-native]]></category>
            <dc:creator><![CDATA[Abhishek sharma]]></dc:creator>
            <pubDate>Wed, 12 Feb 2020 16:41:35 GMT</pubDate>
            <atom:updated>2020-02-12T16:41:35.375Z</atom:updated>
            <content:encoded><![CDATA[<h4>Google Firebase+ React Native Expo+ Some basic UI Designs</h4><h3>INTRODUCTION</h3><h3>React Native expo</h3><p>Expo is a framework and a platform for universal React applications. It is a set of tools and services built around <a href="https://docs.expo.io/versions/latest/">React Native</a> and native platforms that help you develop, build, deploy, and quickly iterate on iOS, Android, and web apps from the same JavaScript/TypeScript codebase. The fastest way to build an app. With Expo tools, services, and React, you can build, deploy, and quickly iterate on native Android, iOS, and web apps from the same JavaScript codebase.</p><ul><li>Access to device capabilities like camera, location, notifications, sensors, haptics, and much more, all with universal APIs.</li><li>Build service gives you app-store ready binaries and handles certificates, no need for you to touch Xcode or Android Studio.</li><li>Over-the-air updates let you update your app at any instance without the hassle and delay of submitting to the store.</li></ul><h3>Chat System</h3><p>This is the one to one chat system mobile application built on React native expo with google firebase.</p><h4>How this chat system is different from other chat applications</h4><ul><li>This is a one to one chat system built on react native expo with Google Firebase. You can find a chat system <a href="https://blog.expo.io/how-to-build-a-chat-app-with-react-native-3ef8604ebb3c">tutorial</a> built on react native expo with Google Firebase online, to make a group chat system but with limited functionalities (like the lack of one to one chats). In this blog, a step to step procedure will be discussed to make a one to one chat application in react native expo.</li><li>The chat system is quick due to realtime updation of activity.</li><li>Heavy tools like Android Studio are not required to make this application.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yqF8hNu23lvlRtl2veTlGg.jpeg" /></figure><h3>Making a chat application will require a few things:</h3><ul><li>Firebase server to store data.</li><li>Signup screen.</li><li>Login screen.</li><li>Home screen.</li><li>Chat Screen.</li></ul><h3>1. A server to store all the messages</h3><p>To use the database, storage, authentication, etc features of google firebase you have to follow these steps to set up the server:</p><ul><li><strong>START FROM HERE</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*koJMIBUYrlFtnjpj36WyTg.png" /><figcaption>Create a new account</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eFZOzgc59QPSQMj6pXn3Hw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wzUVpGUNZCURiWpEhPtdZQ.png" /><figcaption>Select Web option ”&lt;/&gt;”</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n26Cfr8oRl7mYPPIyuWmPg.png" /><figcaption>Follow the wizard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-jUMdcSZAm0TlEZTEFUBA.png" /><figcaption>Continue to console and select the web app you just registered</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xrwUIdGPvbfgqFZK0R5Daw.png" /><figcaption>Select config option and copy the API Key and other details which will be noted down for later</figcaption></figure><ul><li><strong>Setting-up Authentication Section</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2tgH-YI6RL79aQSI4vZRpQ.png" /><figcaption>Enable Anonymous provider option from the authentication section</figcaption></figure><ul><li><strong>Setting-up Database Section</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*seWRNEMbxGvGn-iX3LUSzg.png" /></figure><ul><li>Go to the database section and click on create a database.</li><li>Select “Start in test mode” and follow the wizard.</li><li>We are almost done, one last step remaining to complete configuring of the database.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*01lbxQiSqxTHFJ-RMPse2g.png" /><figcaption>Select the Realtime Database section</figcaption></figure><ul><li>Go to the rules section in the realtime database and exchange existing configuration with the configuration given below.</li></ul><pre>{<br>  &quot;rules&quot;: {<br>    &quot;.read&quot;: true,<br>    &quot;.write&quot;: true<br>  }<br>}</pre><p>Setting-up of the environment is done here. This is enough for part one and now it’s time to code. Stay tuned for part two.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86d2ca11779b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to upload multiple images in react native with base 64.]]></title>
            <link>https://medium.com/@shabhi/how-to-upload-multiple-images-in-react-native-with-base-64-c096cabcaf49?source=rss-1ffa27f2acdb------2</link>
            <guid isPermaLink="false">https://medium.com/p/c096cabcaf49</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[multiple-images-upload]]></category>
            <category><![CDATA[base64]]></category>
            <category><![CDATA[expo-react-native]]></category>
            <dc:creator><![CDATA[Abhishek sharma]]></dc:creator>
            <pubDate>Tue, 24 Sep 2019 04:15:06 GMT</pubDate>
            <atom:updated>2019-09-24T04:15:06.214Z</atom:updated>
            <content:encoded><![CDATA[<h4>INTRODUCTION</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*duf26xUBkM790FkJQrw8iw.png" /></figure><p>This is a small part of the functionality of my app that I’m working on right now. I was getting an issue with uploading these images to the database. Then I came to know we have to convert image URI to base 64 encoding so that it can upload to the database. Along with that, we will also see how to upload multiple images.</p><pre>import * as React from &#39;react&#39;</pre><pre>import { Button, Image, View,StyleSheet} from &#39;react-native&#39;</pre><pre>import * as ImagePicker from &#39;expo-image-picker&#39;</pre><pre>import Constants from &#39;expo-constants&#39;</pre><pre>import * as Permissions from &#39;expo-permissions&#39;</pre><h4>STEP ONE</h4><p>First, we have to export a module called“<a href="https://www.npmjs.com/package/expo-image-picker">expo-image-picker</a>”. It’s an NPM module that Provides access to the system’s UI for selecting images and videos from the phone’s library or taking a photo with the camera. We also need to import “expo-permissions” which allows us to use a camera and other functionality of the device.</p><pre>state = {<br>LocalImage:[],<br>multipleUrl:[]<br>}</pre><pre>componentDidMount() {<br>   this.getPermissionAsync()<br>}</pre><pre>getPermissionAsync = async () =&gt; {<br>     if (Constants.platform.ios) {const { status } = await                            Permissions.askAsync(Permissions.CAMERA_ROLL)</pre><pre>if (status !== &#39;granted&#39;) {<br>         alert(&#39;Sorry, we need camera roll permissions to make this             work!&#39;)<br>      }</pre><pre>}<br>}</pre><h4>STEP TWO</h4><p>In this part, we will set two states one with the name of ‘LocalImage’ which we will set the local path of the image that we have selected and the second state i.e ‘multipleUrl’ which will contain images URI that we had selected with base 64 extensions. ‘getPermissionAsync’ in this function we will set the permission to access the camera and gallery of the device.</p><pre>_pickImage = async () =&gt; {<br>  let pickerResult = await ImagePicker.launchImageLibraryAsync({<br>    mediaTypes: ImagePicker.MediaTypeOptions.All,<br>    <strong>base64: true</strong>,<br>    allowsEditing: true,<br>    aspect: [4, 3],<br>  })</pre><pre><strong>let imageUri = pickerResult ?   `data:image/jpg;base64,${pickerResult.base64}` : null</strong><br>   imageUri &amp;&amp; {uri: imageUri}<br>   this.state.multipleUrl.push(imageUri)<br>    this.setState({<br>LocalImage: this.state.LocalImage.concat([pickerResult.uri]),<br>})<br>}</pre><pre>_takePhoto = async () =&gt; {<br>const {<br>status: cameraPerm<br>} = await Permissions.askAsync(Permissions.CAMERA)</pre><pre>const {<br>status: cameraRollPerm<br>} = await Permissions.askAsync(Permissions.CAMERA_ROLL)<br>// only if user allows permission to camera AND camera roll</pre><pre>if (cameraPerm === &#39;granted&#39; &amp;&amp; cameraRollPerm === &#39;granted&#39;) {<br>let pickerResult = await ImagePicker.launchCameraAsync({<br>     <strong>base64: true</strong>,<br>     allowsEditing: true,<br>     aspect: [4, 3],<br>})</pre><pre>if (!pickerResult.cancelled) {<br>   <strong>let imageUri = pickerResult ?     `data:image/jpg;base64,${pickerResult.base64}` : null</strong></pre><pre>this.state.multipleUrl.push(imageUri)<br>this.setState({<br>LocalImage: this.state.LocalImage.concat([pickerResult.uri]),<br>    })</pre><pre>}<br> }<br>}</pre><h4>STEP THREE</h4><p>‘_pickImage()’ and ‘_takePhoto()’ are the two functions i had created. In these functions variable named ‘pickerResult’ access the gallery and camera of the device with the help of ‘expo-permissions’. We have to pass ‘base 64:true’ in the parameter of image picker functionality and some more line of code that I had mentioned in bold. These parameters will convert the local image URI of the device in base 64 extensions. I had set base 64 URI into a state named ‘multipleUrl’ and local path URI of the image that we had selected into a state named ‘LocalImage’. These both states are array so I can select and add images uri as much as I want.</p><pre>_renderImages() {<br>    let images = []<br>    this.state.LocalImage.map((item, index) =&gt; {<br>       images.push(<br>         &lt;Image  key={index} source={{ uri: item }}  style={{ width:   100, height: 100 }} /&gt;<br>         )<br>       })<br>    return images<br>  }</pre><pre>render() {<br>   return (<br>      &lt;View style={styles.mainView}&gt;<br>           &lt;View style={style.buttons}&gt;<br>                 &lt;Button title=&quot;Pick an image from camera roll&quot;  onPress={this._pickImage}/&gt;<br>           &lt;/View&gt;</pre><pre>           &lt;View style={style.buttons}&gt;<br>                 &lt;Button onPress={this._takePhoto} title=&quot;Take a photo&quot; /&gt;<br>           &lt;/View&gt;<br>           <br>            &lt;View style={styles.containers}&gt;<br>              {this._renderImages()}<br>             &lt;/View&gt;<br>       &lt;/View&gt;<br>      )<br>   }<br></pre><h4>STEP FOUR</h4><p>Finally, we are done with our functionalities now its time to get the image URI from the state and set it into our UI design. We will extract image URI’s from the state named as ‘LocalImage’ and set the image URI into our View.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c096cabcaf49" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>