<?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: Balamurugan</title>
    <description>The latest articles on DEV Community by Balamurugan (@balamurugan).</description>
    <link>https://dev.to/balamurugan</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%2F1103025%2Fab4e06ca-c0e5-49e5-873b-384cb35c2884.jpeg</url>
      <title>DEV Community: Balamurugan</title>
      <link>https://dev.to/balamurugan</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/balamurugan"/>
    <language>en</language>
    <item>
      <title>Integrate Zoom SDK with React</title>
      <dc:creator>Balamurugan</dc:creator>
      <pubDate>Tue, 04 Jul 2023 19:59:55 +0000</pubDate>
      <link>https://dev.to/balamurugan/integrate-zoom-sdk-with-react-3a88</link>
      <guid>https://dev.to/balamurugan/integrate-zoom-sdk-with-react-3a88</guid>
      <description>&lt;p&gt;A quick write up on Zoom SDK integration with React - that takes help from the repos shared by the official Zoom team.&lt;/p&gt;

&lt;p&gt;Zoom is a well-known tool for attending meetings and webinars. Since it is widely used, Zoom developers team helps us with sample repos to encourage us quickly integrate Zoom SDk to our applications such as mobile or web.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Develop React site&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Head to &lt;a href="https://developers.zoom.us/docs/meeting-sdk/web/"&gt;https://developers.zoom.us/docs/meeting-sdk/web/&lt;/a&gt; to see all the sample repos for web apps. Click on "React sample".&lt;/p&gt;

&lt;p&gt;You can clone this repo and test it out. I've modified it and uploaded it onto my github account - which you can check it out.&lt;/p&gt;

&lt;p&gt;In App.js, make sure you import ZoomMtg and use it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import { ZoomMtg } from "@zoomus/websdk";

ZoomMtg.setZoomJSLib("https://source.zoom.us/2.13.0/lib", "/av");

  const sdkKey = process.env.REACT_APP_ZOOM_SDK_KEY_PROD;
  const role = 0;
  const leaveUrl = "https://zoom.us";
  const meetingNumber = 99488065055;
  const passWord = "******";
  const userName = "Test User";
  const userEmail = "svbala99@gmail.com";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Here I just retrieved the sdkkey from .env file. role 0 stands for attendee and 1 for host. We can specify leaveUrl to the desired site to which user would be taken to, upon the conclusion of the meeting. Here, I've set up a meeting from my Zoom account and mentioned my meeting number. You can replace it with yours. You can also do the same for password, username, user email.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
   * @async
   * @function getSignature
   * @param {Event} e
   * @description generates description by hitting the hosted git repo Express server
   * @description replace localhost 4000 with the URL where the Express server runs remotely
   */
  const getSignature = async (event) =&amp;gt; {
    try {
      event.preventDefault();

      // hit the remote experss server to retrieve signature
      // meetingNumber and role are must.
      // role 0 means attendee, 1 stands for host
      const responseFromSignatureEndpoint = await fetch(
        "https://zoomsdk-sign-generator-express.onrender.com",
        {
          method: "POST",
          headers: { "Content-Type": "application/json" },
          body: JSON.stringify({
            meetingNumber,
            role,
          }),
        }
      );

      // if signature is retrieved successfully, then attempt to start meeting
      const signatureJSON = await responseFromSignatureEndpoint.json();
      if (signatureJSON) {
        startMeeting(signatureJSON?.signature);
      }
    } catch (error) {
      console.error(error);
    }
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;I just revamped the getSignature() method that was already there in the cloned repo from zoom developers. Here I made it async because we're gonna perform some async operations such as make an API call to get the signature, which is required to join the meeting.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;https://zoomsdk-sign-generator-express.onrender.com&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;This is the URL in which I hosted the signature generator that is built on Nodejs. we shall come back to it in further steps. You can use your &lt;a href="http://localhost:4000"&gt;http://localhost:4000&lt;/a&gt; or whichever local address in which your local Node server is running.&lt;/p&gt;

&lt;p&gt;I also revamped the startMeeting() method as follows. The code is self explanatory.&lt;br&gt;
&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;/**
   * @function startMeeting
   * @param {String} signature
   * @description starts the zoom meeting
   */
  const startMeeting = (signature = null) =&amp;gt; {
    // in the HTML document, whichever div has zmmtg-root as ID, then overwrite its style prop by display : 'block'
    document.getElementById("zmmtg-root").style.display = "block";

    // make init() from zoomSDK
    // pass success and error callbacks for init() and join()
    // all fields are mandatory
    ZoomMtg.init({
      leaveUrl,
      success: (success) =&amp;gt; {
        //   console.log("============= Zoom init success",success)
        ZoomMtg.join({
          signature,
          sdkKey,
          meetingNumber,
          passWord,
          userName,
          userEmail,
          // success: (success) =&amp;gt; {
          //   console.log("============= Zoom join success",success)
          // },
          // error: (error) =&amp;gt; {
          //   console.log("============= Zoom join error", error);
          // }
        });
      },
      // error: (error) =&amp;gt; {
      //   console.log("============= Zoom init error", error);
      // }
    });
  };
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Finally the entire App.js would look something like this:-&lt;/p&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;



&lt;p&gt;Done. We've completed the React part of it. Now let's do the Node.JS server to serve us the signature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Run a NodeJS server&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Head to &lt;a href="https://github.com/zoom/meetingsdk-auth-endpoint-sample"&gt;https://github.com/zoom/meetingsdk-auth-endpoint-sample&lt;/a&gt; and clone this repo. This is the officially provided repo. I've modified it and placed it on my github account.&lt;/p&gt;

&lt;p&gt;The purpose of this repo is to get meeting number and role to create a signature (JWT based) and return it. This is provided officially by zoom developers.&lt;/p&gt;

&lt;p&gt;Only change I've made here is the creation of .env file for process.env.ZOOM_MEETING_SDK_SECRET&lt;/p&gt;

&lt;p&gt;Issue the following commands to install the dependencies and start the NodeJS server locally on your machine.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i
node index.js
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If you wanna host this server online for free in simple steps, you can refer my post here: &lt;a href="https://medium.com/@svbala99/set-up-a-simple-express-server-and-deploy-it-for-free-on-render-com-1d770722d235"&gt;https://medium.com/@svbala99/set-up-a-simple-express-server-and-deploy-it-for-free-on-render-com-1d770722d235&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Run React app that fetches signature from this NodeJS server&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm i
npm start
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This would install the dependencies and start the server.&lt;br&gt;
Hurray! we are done. You can see the following screens:-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--i-cltdu6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz0gfn6jf9den2g2q383.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--i-cltdu6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/cz0gfn6jf9den2g2q383.png" alt="Image description" width="800" height="304"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fCDs96kT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1q1iyo718ssq7qbvbiip.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fCDs96kT--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1q1iyo718ssq7qbvbiip.png" alt="Image description" width="800" height="480"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9sK5S9iS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/89qw16ymxtjn9cw3819e.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9sK5S9iS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/89qw16ymxtjn9cw3819e.png" alt="Image description" width="800" height="420"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once the meeting is started by the host, you can join the meeting.&lt;/p&gt;

&lt;p&gt;Hope this is useful for somebody who works with Zoom in React webpage. Thank you for your time, see you next time folks! Stay healthy.&lt;/p&gt;

&lt;p&gt;React webpage - Github repository : &lt;a href="https://github.com/svbala99/react-zoom/"&gt;https://github.com/svbala99/react-zoom/&lt;/a&gt;&lt;br&gt;
NodeJS server - Github repo : &lt;a href="https://github.com/svbala99/zoomsdk-sign-generator-express"&gt;https://github.com/svbala99/zoomsdk-sign-generator-express&lt;/a&gt;&lt;/p&gt;

</description>
      <category>zoom</category>
      <category>reactnative</category>
      <category>react</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Communication between React Native web view and React app</title>
      <dc:creator>Balamurugan</dc:creator>
      <pubDate>Tue, 04 Jul 2023 19:49:49 +0000</pubDate>
      <link>https://dev.to/balamurugan/communication-between-react-native-web-view-and-react-app-3ik5</link>
      <guid>https://dev.to/balamurugan/communication-between-react-native-web-view-and-react-app-3ik5</guid>
      <description>&lt;p&gt;This is one way of data communication between React native web view and react application.&lt;/p&gt;

&lt;p&gt;There could me many possible ways for communicating between a react native app's web view and the react application that is hosted separately. I came across such requirement and I'm sharing the solution that I decided to apply here.&lt;/p&gt;

&lt;p&gt;First of all, let's have a basic implementation of a react application and reatc native application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A simple React application:-&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In useEffect() of App.js, add an event listener that listens for any native event. It is present within the "window" object of HTML. The addEventListener() method of the EventTarget interface sets up a function that will be called whenever the specified event is delivered to the target. Ref: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener"&gt;https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;In the listener function that we attach, we get the nativeEvent object, within which we can find the data that is being sent from React native or any external source that is targeted to the HTML document.&lt;/li&gt;
&lt;li&gt;To send the message to react native from react, we can use window.ReactNativeWebView.postMessage() method. This doesn't require any additional import or any package to be added. It comes in-built with "window" object of HTML. The window.postMessage() method safely enables cross-origin communication between Window objects; e.g., between a page and a pop-up that it spawned, or between a page and an iframe embedded within it.Ref: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage"&gt;https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UX8Ezfgd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yrjbn7w68i5m7z2608r5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UX8Ezfgd--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yrjbn7w68i5m7z2608r5.png" alt="Image description" width="800" height="653"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;A simple react native application with web view:-&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create a simple webview from any npm package&lt;/li&gt;
&lt;li&gt;To receive messages from the website, attach a method that points to the onMessage = {} property in the webview. In that function we can handle the incoming message.&lt;/li&gt;
&lt;li&gt;To send messages to react, we need to set ref to the web view to get the current instance of the referred object using useRef(). Attach it with ref = {webViewRef}&lt;/li&gt;
&lt;li&gt;Using webViewRef.current.postMessage(), we can send messages to react website.&lt;/li&gt;
&lt;li&gt;If we want to trigger something at the time of componentDidMount(), then we can do it by adding the required method at onLoadEnd() property of webview - that triggers a callback when the webview has loaded a website on it.&lt;/li&gt;
&lt;li&gt;We have mentioned the latest version of userAgents. Also had some props enables such as domStorageEnabled, cacheEnabled, javaScriptEnabled, etc for better performance of react native screen that loads webview.&lt;/li&gt;
&lt;li&gt;We can also show custom loaders until the site is loaded.&lt;/li&gt;
&lt;/ol&gt;


&lt;div class="ltag_gist-liquid-tag"&gt;
  
&lt;/div&gt;


&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--w608LvjC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1kff0j4l591lvs22azcy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--w608LvjC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1kff0j4l591lvs22azcy.png" alt="Image description" width="800" height="1018"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Sharing my Github repository here : &lt;a href="https://github.com/svbala99/react-zoom"&gt;https://github.com/svbala99/react-zoom&lt;/a&gt; and &lt;a href="https://github.com/svbala99/zoomsdk-sign-generator-express"&gt;https://github.com/svbala99/zoomsdk-sign-generator-express&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;These repositories help you to setup a webview in which you can host a zoom meeting in web view in react native. The second repo is to generate secure signature. It is as dictated by official Zoom.&lt;/p&gt;

&lt;p&gt;I hope this could be useful to somebody. Thanks for reading. Will come back with yet another interesting article. Stay healthy, take care!!!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>react</category>
      <category>reactnative</category>
      <category>postmessage</category>
    </item>
  </channel>
</rss>
