<?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 Vinay Singh on Medium]]></title>
        <description><![CDATA[Stories by Vinay Singh on Medium]]></description>
        <link>https://medium.com/@thevinaysingh?source=rss-b1cedfe63062------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6ExrILTKnADxzyZIBeH5Dg.png</url>
            <title>Stories by Vinay Singh on Medium</title>
            <link>https://medium.com/@thevinaysingh?source=rss-b1cedfe63062------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 17:44:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@thevinaysingh/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[Go Swadeshi: India’s Digital Revolution —  Ai+ Unleashes Nova 5G and Pulse with Sovereign…]]></title>
            <link>https://thevinaysingh.medium.com/go-swadeshi-indias-digital-revolution-ai-unleashes-nova-5g-and-pulse-with-sovereign-b65d355b64af?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/b65d355b64af</guid>
            <category><![CDATA[swadeshi]]></category>
            <category><![CDATA[india]]></category>
            <category><![CDATA[5g]]></category>
            <category><![CDATA[digital-revolution]]></category>
            <category><![CDATA[smartphones]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Wed, 24 Sep 2025 17:45:52 GMT</pubDate>
            <atom:updated>2025-09-24T17:45:52.710Z</atom:updated>
            <content:encoded><![CDATA[<h3>Go Swadeshi: <strong>India’s Digital Revolution — Ai+ Unleashes Nova 5G and Pulse with Sovereign NxtQuantum OS</strong></h3><p>In a significant move for India’s smartphone market, the homegrown brand Ai+ has introduced two new devices: <a href="https://www.google.com/search?prds=pvt:hg,pvo:29,imageDocid:6846612910281799395,headlineOfferDocid:3527956144200039103,productDocid:3527956144200039103&amp;ibp=oshop&amp;q=product&amp;sa=X&amp;ved=2ahUKEwj6qvyf9fGPAxXDRmwGHbpvBZ0Qxa4PegYIAQgEEAI"><strong>Ai+ Nova 5G</strong></a><strong> </strong>and the <a href="https://www.google.com/search?prds=pvt:hg,pvo:29,imageDocid:12244928085821718298,headlineOfferDocid:17661643576617020836,catalogid:13393462948402781012,productDocid:11762998760548150849&amp;ibp=oshop&amp;q=product&amp;sa=X&amp;ved=2ahUKEwj6qvyf9fGPAxXDRmwGHbpvBZ0Qxa4PegYIAQgEEAQ"><strong>Ai+ Pulse</strong></a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/0*OBtmKkpZWZSFme2S" /><figcaption><a href="https://www.google.com/search?prds=pvt:hg,pvo:29,imageDocid:6846612910281799395,headlineOfferDocid:3527956144200039103,productDocid:3527956144200039103&amp;ibp=oshop&amp;q=product&amp;sa=X&amp;ved=2ahUKEwj6qvyf9fGPAxXDRmwGHbpvBZ0Qxa4PegYIAQgEEAI"><strong>Ai+ Nova 5G</strong></a></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/345/0*1bhVNH9i-gf97L2E" /><figcaption><a href="https://www.google.com/search?prds=pvt:hg,pvo:29,imageDocid:12244928085821718298,headlineOfferDocid:17661643576617020836,catalogid:13393462948402781012,productDocid:11762998760548150849&amp;ibp=oshop&amp;q=product&amp;sa=X&amp;ved=2ahUKEwj6qvyf9fGPAxXDRmwGHbpvBZ0Qxa4PegYIAQgEEAQ"><strong>Ai+ Pulse</strong></a></figcaption></figure><p>Running on the privacy-focused, India-built NxtQuantum OS, these smartphones aim to challenge foreign dominance by offering a compelling mix of features, affordability, and data sovereignty.</p><h4>Company — <a href="https://aiplusstore.com/">https://aiplusstore.com/</a></h4><h4>Madhav Sheth (CEO) — <a href="https://www.linkedin.com/in/madhavsheth/">https://www.linkedin.com/in/madhavsheth/</a></h4><h3>The NxtQuantum OS: A New Era of Privacy</h3><p>At the heart of the Ai+ smartphones is the NxtQuantum OS, India’s first sovereign mobile operating system. Built on Android 15, this OS prioritizes user privacy and security with several key features:</p><ul><li><strong>Indian-based data storage:</strong> All user data is securely stored on Google Cloud servers within India, adhering to regulations from the Ministry of Electronics and Information Technology (MeitY).</li><li><strong>“Zero bloatware”:</strong> The OS is designed to be clean and responsive, providing a smooth user experience free from unnecessary pre-installed apps.</li><li><strong>NxtQuantum PlayStore:</strong> Instead of the standard Google Play Store, these devices use a dedicated Indian-developed app marketplace.</li><li><strong>Privacy dashboard:</strong> A built-in feature allows users to monitor which apps are tracking their data.</li><li><strong>End-to-end control:</strong> Ai+ asserts that it gives users full control over their data, ensuring transparency and security.</li></ul><h3>Ai+ Nova 5G: The Budget 5G Challenger</h3><p>The <strong>Ai+ Nova 5G</strong> is a strong contender in the budget 5G segment, offering a feature set that punches above its price point.</p><p><strong>Hardware Highlights</strong></p><ul><li><strong>Display:</strong> A large 6.75-inch HD+ LCD display with a high 120Hz refresh rate for smooth scrolling and animations.</li><li><strong>Processor:</strong> Powered by the Unisoc T8200 octa-core chipset, which provides snappy performance for everyday use.</li><li><strong>Memory:</strong> Choose between 6GB or 8GB of RAM, paired with 128GB of internal storage, expandable up to 1TB via microSD.</li><li><strong>Camera:</strong> A 50MP AI dual-camera system on the back and a 5MP front camera for selfies.</li><li><strong>Battery:</strong> A 5,000mAh battery keeps the phone running all day, with 18W fast charging support.</li><li><strong>Other:</strong> Includes a side-mounted fingerprint sensor, face unlock, and an IP54 rating for water and dust resistance.</li></ul><h3>Ai+ Pulse: The Affordable 4G All-rounder</h3><p>For those on an even tighter budget, the <strong>Ai+ Pulse</strong> delivers a robust and reliable 4G experience.</p><p><strong>Hardware Highlights</strong></p><ul><li><strong>Display:</strong> Features a 6.75-inch HD+ LCD display with a 90Hz refresh rate.</li><li><strong>Processor:</strong> Uses the Unisoc T615 octa-core chipset, offering solid performance for basic tasks.</li><li><strong>Memory:</strong> Available in 4GB or 6GB RAM configurations with either 64GB or 128GB of storage, also expandable up to 1TB via microSD.</li><li><strong>Camera:</strong> A 50MP AI dual-camera system and a 5MP selfie camera.</li><li><strong>Battery:</strong> A large 5,000mAh battery, though charging is slower at 10W.</li><li><strong>Other:</strong> Equipped with a side-mounted fingerprint sensor and face unlock.</li></ul><h3>Software details (Both phones)</h3><p>The Ai+ Nova 5G and Ai+ Pulse run on NxtQuantum OS, which is based on Android 15. Key software features include:</p><ul><li><strong>Privacy-focused</strong>: User data is stored on Indian-based Google Cloud servers with a zero-trust framework.</li><li><strong>Zero bloatware</strong>: The OS is designed to be clean and responsive, without unnecessary apps.</li><li><strong>NxtQuantum PlayStore</strong>: An Indian-developed app marketplace.</li><li><strong>Privacy Dashboard</strong>: Allows users to monitor app data tracking.</li><li><strong>NxtSafe Space</strong>: A security feature of the OS.</li><li><strong>Locally trained AI engines</strong>: The OS incorporates AI tools developed in India.</li></ul><h3>The Verdict</h3><p>The launch of the Ai+ Nova 5G and Pulse represents more than just new hardware; it signifies a serious effort by an Indian company to build a sovereign digital ecosystem. For price-conscious buyers in India, these phones offer a compelling package of modern features, including 5G connectivity on the Nova, without compromising on data privacy. With a clean, bloatware-free OS and secure data storage within India, Ai+ is building trust in a crowded market.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b65d355b64af" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Accessibility in Reactjs?]]></title>
            <link>https://thevinaysingh.medium.com/accessibility-in-reactjs-991571d80e53?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/991571d80e53</guid>
            <category><![CDATA[accessibility]]></category>
            <category><![CDATA[semantic-html]]></category>
            <category><![CDATA[html]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[reactjs]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Sat, 11 May 2024 06:43:48 GMT</pubDate>
            <atom:updated>2024-05-11T06:43:48.280Z</atom:updated>
            <content:encoded><![CDATA[<p>Key concepts and ways to use accessibility</p><h4>Accessibility (a11y) in React.js is all about creating user interfaces that can be understood and interacted with by everyone, regardless of their abilities.</h4><p>This includes people who use assistive technologies like screen readers, keyboard navigation, or voice control.</p><p>Here’s a breakdown of key concepts for accessibility in React:</p><h4><strong>1. Semantic </strong>HTML</h4><ul><li>Build your components using semantic HTML elements like &lt;h1&gt; for headings, &lt;button&gt; for buttons, &lt;nav&gt; for navigation, etc. These elements convey meaning to assistive technologies and browsers.</li></ul><pre>&lt;header&gt; {/* Semantic header element */}<br>    &lt;h1&gt;Main Title of the Page&lt;/h1&gt; {/* Semantic heading element */}<br>&lt;/header&gt;<br><br>&lt;main&gt;<br>    &lt;p&gt;The main content of your webpage goes here&lt;/p&gt; {/* Semantic paragraph element */}<br>&lt;/main&gt;<br><br>&lt;footer&gt; {/* Semantic footer element */}<br>   &lt;p&gt;Copyright information and other footer related stuff&lt;/p&gt;<br>&lt;/footer&gt;</pre><h4><strong>2. ARIA Attributes</strong></h4><ul><li>In some cases, semantic HTML might not be enough. Use ARIA (Accessible Rich Internet Applications) attributes to provide additional information to assistive technologies. For example, you can use <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-label">aria-label</a> to describe an image or <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Attributes/aria-describedby">aria-describedby</a> to link a description to an input field.</li><li>Use <a href="https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA">WAI-ARIA</a> (Accessibility Rich Internet Applications) roles and properties for enhancing accessibility when HTML can’t achieve what you need.</li></ul><pre>function ImageWithDescription() {<br>  return (<br>    &lt;div&gt;<br>    &lt;button aria-label=&quot;Close&quot; onClick={this.close}&gt;<br>    X<br>    &lt;/button&gt;<br>    &lt;img<br>      src=&quot;image.jpg&quot;<br>      alt=&quot;A descriptive image alt text&quot;  {/* Descriptive alt text */}<br>      aria-describedby=&quot;imageDescription&quot;  {/* Links to description */}<br>    /&gt;<br>    &lt;/div&gt;<br>  );<br>}</pre><h4><strong>3. Keyboard Navigation</strong></h4><ul><li>Ensure your application is fully navigable using the keyboard. This means allowing users to tab through focusable elements like buttons, links, and form fields. Use event handlers like onFocus and onBlur to manage focus states and provide visual cues.</li></ul><pre>function FocusableButton({ onClick }) {<br>  return (<br>    &lt;button type=&quot;button&quot; onFocus={() =&gt; console.log(&quot;Button Focused&quot;)} onClick={onClick}&gt;<br>      Click me<br>    &lt;/button&gt;<br>  );<br>}</pre><h4><strong>4. Screen Reader Support</strong></h4><ul><li>Focus on clear and concise text descriptions for your components. Use descriptive link text and avoid relying solely on color for conveying information. Screen readers present the content as text, so ensure it’s well-structured and understandable.</li></ul><pre>function ErrorMessage({ message }) {<br>  return (<br>    &lt;div role=&quot;alert&quot; aria-live=&quot;assertive&quot;&gt;  {/* Announces errors */}<br>      {message}<br>    &lt;/div&gt;<br>  );<br>}</pre><h4><strong>5. Focus Control</strong></h4><ul><li>Allow keyboard-only users to navigate your application by managing element focus on components. Using the autoFocus prop is an example of giving focus to a specific element when a component mounts.</li></ul><pre>class AutoFocusTextInput extends React.Component {<br>  componentDidMount() {<br>    this.textInput.focus();<br>  }<br><br>  render() {<br>    return (<br>      &lt;input<br>        type=&quot;text&quot;<br>        ref={(input) =&gt; { this.textInput = input; }}     // assign ref<br>      /&gt;<br>    );<br>  }<br>}</pre><h4><strong>6. Testing and Validation:</strong></h4><ul><li>There are various tools and techniques to test and validate the accessibility of your React application. Use browser developer tools to check the accessibility tree and identify potential issues. Additionally, consider using libraries react-axe that can automate accessibility checks during development.</li><li>The majority of accessibility problems can be caught by some static analysis tools, but manual testing and validation are important as well because accessibility is more than just meeting a checklist of rules.</li></ul><h4><strong>7. Alt attribute in images</strong></h4><p>Always provide useful, descriptive alternate text for images.</p><pre>&lt;img src={logo} alt=&quot;Logo Description&quot; /&gt;;</pre><h4><strong>8. Build Accessible Forms</strong></h4><p>You should ensure that every form element has a clear, accessible label.</p><pre>&lt;label htmlFor=&#39;name&#39;&gt; Name &lt;/label&gt;<br>&lt;input type=&#39;text&#39; id=&#39;name&#39; name=&#39;name&#39; /&gt;</pre><h4><strong>9. Accessible Colors and Contrast</strong></h4><ul><li>Be mindful of color and contrast to make sure that the content is fully legible for everyone. <a href="https://www.w3.org/TR/WCAG20/">WCAG2</a> provides specific contrast and text size guidelines.</li></ul><h4><strong>10. React Fragments</strong></h4><p>Use React Fragments (<strong>&lt;&gt;&lt;/&gt;</strong> or <strong>&lt;React.Fragment&gt;&lt;/React.Fragment&gt;</strong>) to group together multiple elements without adding extra nodes to the DOM. This helps maintain a clean document outline for screen reader users.</p><pre>&lt;&gt; <br>  &lt;ChildA /&gt;<br>  &lt;ChildB /&gt;<br>  &lt;ChildC /&gt;<br>&lt;/&gt;</pre><h4><strong>11. React Accessibility Linters</strong></h4><p>Tools like <strong>eslint-plugin-jsx-a11y</strong> can enforce a set of accessibility-related rules you can follow.</p><h3>Some Sources</h3><p>Here are some resources to get you started with accessibility in React:</p><ul><li><strong>React Accessibility Documentation:</strong> <a href="https://legacy.reactjs.org/docs/accessibility.html">https://legacy.reactjs.org/docs/accessibility.html</a></li><li><strong>MDN Web Docs — Accessibility in React:</strong> <a href="https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/React_accessibility">https://developer.mozilla.org/en-US/docs/Learn/Tools_and_testing/Client-side_JavaScript_frameworks/React_accessibility</a></li><li><strong>A11y Project:</strong> <a href="https://www.a11yproject.com/">https://www.a11yproject.com/pen_spark</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=991571d80e53" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Google Lighthouse beginner understanding]]></title>
            <link>https://thevinaysingh.medium.com/google-lighthouse-beginner-understanding-a00a10833b2b?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/a00a10833b2b</guid>
            <category><![CDATA[google]]></category>
            <category><![CDATA[reactjs]]></category>
            <category><![CDATA[google-lighthouse]]></category>
            <category><![CDATA[lighthouse]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Sat, 11 May 2024 06:23:56 GMT</pubDate>
            <atom:updated>2024-05-11T06:23:56.804Z</atom:updated>
            <content:encoded><![CDATA[<h4>What is the purpose of a lighthouse in the world?</h4><p>A lighthouse is a tower, building, or other type of physical structure designed to emit light</p><p>No matter where it is located the purpose of a lighthouse is always the same; to warn ships of danger and guide them safely on their way</p><h3>What is Google Lighthouse?</h3><ul><li>Google Lighthouse is an open-source, auditing tool developed by Google for improving the quality of web pages.</li><li>You can run it on any web page, be it public or requiring authentication.</li><li>It offers audits for performance, accessibility, progressive web apps, SEO, and more.</li></ul><h3>How it can be run?</h3><p>When you run Lighthouse, it gives a set of scores for these categories along with detailed recommendations on how to improve the webpage to achieve the highest score.</p><p>It can be run in several ways like from the Chrome DevTools, from the command line, or as a Node.js module.</p><h3>How does Lighthouse work?</h3><p>Lighthouse uses a mixture of real-device and simulated testing through a methodology called Lantern to provide feedback and calculates its metrics. For instance, it measures the timing as to when a page is first loaded, when it is interactive, and when the additional content is loaded.</p><h3>How to use Lighthouse in Google Chrome?</h3><p>In Google Chrome, go to the page you want to audit.</p><ul><li>Right-click and select Inspect.</li><li>Go to the Lighthouse tab positioned at the right of the panel.</li><li>Click Generate report.</li></ul><p>It’s a useful tool for developers, providing specific guidance for improving site performance and quality, and is used heavily in web development for measuring web performance.</p><h3>What does it assess?</h3><p>It assesses various aspects of a web page, including:</p><ul><li><strong>Performance:</strong> How fast a page loads and how responsive it feels to user interaction.</li><li><strong>Accessibility:</strong> How easy it is for users with disabilities to navigate and understand the content.</li><li><strong>Best Practices:</strong> Whether the page adheres to recommended coding practices for web development.</li><li><strong>SEO (Search Engine Optimization):</strong> How well-optimized the page is for search engines.</li><li><strong>Progressive Web App (PWA):</strong> Whether the page can function like a native app on mobile devices.</li></ul><p>Lighthouse generates a report that provides scores for each of these categories, along with actionable recommendations for improvement.</p><h3>Benefits of using Google Lighthouse?</h3><p>Lighthouse generates a report that provides scores for each of these categories, along with actionable recommendations for improvement. This can be incredibly helpful for web developers, designers, and content creators in ensuring their web pages are:</p><ul><li><strong>Fast and efficient:</strong> A slow-loading website can frustrate users and hurt SEO ranking.</li><li><strong>Accessible to all users:</strong> This includes people with visual impairments, hearing impairments, cognitive disabilities, and those using assistive technologies.</li><li><strong>Following best practices:</strong> This can improve the maintainability and security of the website.</li><li><strong>Optimized for search engines:</strong> A well-optimized website is more likely to appear in search results.</li><li><strong>PWA-ready:</strong> PWAs offer a better user experience on mobile devices and can even work offline.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a00a10833b2b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BharOS: Rise of  Indian mobile OS and App stores]]></title>
            <link>https://thevinaysingh.medium.com/bharos-rise-of-indian-mobile-os-and-app-stores-dfc86e3ba21c?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/dfc86e3ba21c</guid>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[mobile-app-store]]></category>
            <category><![CDATA[bharos]]></category>
            <category><![CDATA[mobile-operating-system]]></category>
            <category><![CDATA[android]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Sat, 23 Mar 2024 14:27:09 GMT</pubDate>
            <atom:updated>2024-03-26T13:43:14.738Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>BharOS</strong>: Rise of Indian mobile OS and App stores</h3><h3>Mobile Operation systems</h3><ul><li>Android</li><li>iOS</li><li><a href="https://en.wikipedia.org/wiki/BharOS"><strong>BharOS (formerly IndOS)</strong></a> is a mobile operating system based on <strong>Linux</strong> developed by <strong>JandK Operations Private Limited</strong>, a non-profit organization of <strong>IIT Madras</strong>. It’s a government-funded project aimed at creating a free and open-source alternative for use in government and public systems.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xby9tNKztVtoI41fpYGFPw.png" /></figure><h3>Mobile Application stores</h3><ul><li>Google Play store</li><li>iOS App Store</li><li><a href="https://apps.mgov.gov.in/"><strong>The Gov.in Appstore</strong></a></li></ul><h3>The future learning from the past stories</h3><p>Although India has been developing its OS for a long time, <strong>Bharat Operating System Solutions (Boss)</strong> was developed in <strong>2006</strong> by the <strong>Ministry of Electronics and Information Technology</strong> and <strong>IndOS</strong> was made in 2023 by IIT graduates</p><p>BharOS is being pitched as India’s answer to the Google-owned Android and Apple’s iOS, the two most dominant mobile operating systems in the world.</p><p>Even if the multiple OS in the Past fails to challenge the Google-Apple duopoly in the mobile ecosystem.</p><p>A lot of companies (Most of them were giant tech companies) have tried their hands at building a successful mobile operating system to take on Google’s Android over the last few years.</p><p><strong>Few stories of the past competitors</strong></p><h4>Story 1: Windows Phone OS</h4><p><strong>Microsoft</strong>’s Windows Phone OS had the potential to become one of the leading mobile operating systems globally. At its peak around the time of Windows Phone OS 8, it offered a superior user experience compared to Android. What really didn’t work out for Microsoft is that <strong>they failed to attract users due to the lack of apps compared to Android and iOS</strong>.<strong> </strong>Additionally, <strong>developers were not inclined to adopt the Windows Phone platform on a large scale</strong>.</p><p>It is scary, right?</p><h4>Story 2: CyanogenOS</h4><p>CyanogenOS was based on the <strong>Android Open Source Project (AOSP)</strong> and it partnered with brands like <strong>OnePlus</strong> and <strong>Micromax’s</strong> YU to launch phones with a custom CyanogenMod which promised a clean user interface with a lot of customization options. In fact, OnePlus’ first smartphone the OnePlus 1 came with CyanogenOS. Similarly, Micromax’s Yu series of smartphones also shipped with CyanogenOS and even <strong>Lenovo</strong> launched a phone called Zuk Z1 with CyanogenOS out-of-the-box.</p><p>These days many smartphones can get an official <a href="https://lineageos.org/">LineageOS</a> (the developer community forked the project and created LineageOS) build, but one needs to unlock the bootloader and install a custom recovery to use LineageOS. This is a cumbersome process, hence, the user base of LineageOS is limited to enthusiasts.</p><p>However, it is still alive and the recent version is <a href="https://lineageos.org/Sunsetting-LineageOS-18.1/">Sunsetting LineageOS 18.1</a></p><h4>Story 3: <a href="https://sailfishos.org/">SailfishOS</a></h4><p>Just like CyanogenOS, SailfishOS is Linux based mobile operating system with support for Android apps offering a unique user experience with a focus on privacy and security. Launched back in 2013, the operating system <strong>failed to make a mark in the smartphone market due to the lack of an app store like the Google Play Store</strong>.</p><p>However, Sailfish OS is still alive and it is in its fourth generation with ongoing development. One of its key features is a two-column user interface with easy app management.</p><h4>Story 4: Symbian OS</h4><p>This was a mobile operating system once widely used on smartphones. It was popular in the early 2000s and offered features like email, web browsing, and basic applications. However, it eventually lost ground to competitors like iOS and Android due to <strong>limitations in performance and app availability</strong>. Symbian OS itself is no longer actively developed and supported.</p><h4>Story 5: Blackberry OS</h4><p>Blackberry OS was once renowned for its security features. At one point, even the President of the United States exclusively used a Blackberry, a practice that has since been replaced by the use of an iPhone. Blackberry phones and their operating system were particularly well-suited for business professionals, albeit on the pricier side. However, with the availability of affordable Android smartphones, <strong>Blackberry struggled to capture the attention of users seeking budget-friendly devices with an excellent operating system</strong>.</p><p>Eventually, Blackberry abandoned its proprietary OS and began offering phones with Android OS but without the Google Play Store. Despite being based on the Android Open Source Project (AOSP), <strong>Blackberry devices failed to attract users, missing another opportunity to regain their former prominence</strong>.</p><p>Sad story, isn’t it?</p><h4>Learning from Past Stories</h4><ul><li>OS failed to attract users due to the lack of apps compared to Android and iOS.</li><li>developers were not inclined to adopt the Windows Phone platform on a large scale.</li><li>OS based on the Android Open Source Project (AOSP)<strong> </strong>failed due to technical challenges</li><li>OS failed due to a lack of app stores like Google Play Store or Apple App Store.</li><li>OS failed to provide constant security updates and improvements that raised questions about performance &amp; availability.</li><li>OS failed to build a strong community to support.</li><li>OS like BlackBerry couldn’t justify the cost while increasing the user base. That led users to shift to cost-effective OS</li></ul><h3>Rising Story: BharOS</h3><p>(Bharat is building its own story)</p><blockquote><strong>One thing to note here, I believe Android is more challenging than iOS. It’s because of variations in Hardware and Software vendors and its support around them.</strong></blockquote><h4>Here’s what we know about BharOS so far:</h4><ul><li><strong>Based on Android:</strong> BharOS is built on top of the <a href="https://source.android.com/"><strong>Android Open Source Project (AOSP)</strong></a> which gives it a familiar base for developers. <strong>This allows developers to port existing apps with some modifications</strong>.</li><li><strong>Focuses on Security and Privacy:</strong> It aims to offer a more secure environment compared to traditional Android, with features like <strong>minimal pre-installed apps</strong> reducing potential vulnerabilities and <strong>stricter app permissions </strong>giving users more control over what data apps can access.</li><li><strong>Early Stage:</strong> BharOS is currently under development, especially in the <strong>testing phase,</strong> and isn’t widely available to the public yet. Currently, it’s being tested for government use cases.</li></ul><h4>Story Building</h4><ul><li><strong>Changing mindset</strong>: Nowadays, Bharat is changing its mindset and proudly choosing <strong>Made in India</strong> over <strong>Made in Abroad</strong>.</li><li><strong>Technical potential</strong>: Bharat has great technical potential to build robust technological solutions. It has already been proven several times.</li><li><strong>Huge Customer Base</strong>: We know India has a large population country. The best thing for us is a huge portion of our population using smartphones nowadays.</li><li><strong>Trust: </strong>This is a government-funded project backed by the IIT Institute. So no question about trust. Trust is already built</li><li><strong>Security policy: </strong>This is already a key feature. Even marketing is being done with its security features.</li><li><strong>Android Compatibility</strong>: This is Linux based OS built on top of <a href="https://source.android.com/"><strong>Android Open Source Project (AOSP)</strong></a></li><li><strong>Developer support</strong>: BharOS is already promising that with some modifications app may switch to BharOS. It’s cool.</li><li><a href="https://medium.com/@thevinaysingh/navic-indias-own-gps-913764ff97b6"><strong>Navic</strong></a><strong> Hardware support</strong>: I believe, BharOS will have software support for <a href="https://medium.com/@thevinaysingh/navic-indias-own-gps-913764ff97b6">NavIC- India’s own GPS</a>. This is exciting.</li><li><a href="https://apps.mgov.gov.in/"><strong>The Gov.in Appstore</strong></a>: This is an Indian App store in it’s early stage which is an alternative to the Google Play Store and iOS App Store backed by the Indian government.</li><li><strong>Constant Government support</strong>: Albeit, this is a big factor that will play a crucial role in story building. All the initiatives need constant support and development.</li></ul><h3>Some Indian App stores</h3><h4><a href="https://apps.mgov.gov.in/">The Gov.in Appstore</a></h4><p>The Gov.in Appstore is an Indian government initiative designed to provide a secure platform for mobile applications related to public services.</p><p>Download the app store mobile app from <a href="https://apps.mgov.gov.in/details?appid=270">here</a>.</p><p>It functions as a directory for mobile applications created by various Indian government departments and agencies. Users can search for apps by category, state, and platform (Android or iOS) and will be directed to the relevant app store (Google Play Store or Apple App Store) for download.</p><p><strong>For Users:</strong></p><ul><li><strong>Access Public Services:</strong> This app store allows you to download various government apps on your phone. These apps offer a wide range of services, making it easier to interact with the government for things like bill payments, applications for certificates, or tracking official documents.</li></ul><p><strong>For Developers:</strong></p><ul><li><strong>Secure Hosting Platform:</strong> The Gov.in Appstore offers a free platform for Indian mobile app developers to host their government service-related apps.</li><li><strong>In-house Testing:</strong> The app store has a built-in testing process to identify and fix any security vulnerabilities before the app goes live.</li></ul><p><strong>Uploading and Managing Apps:</strong></p><p>Here’s a general idea of the process for uploading and managing apps on the Gov.in Appstore (keep in mind the specific requirements might subject to change):</p><ol><li><strong>Upload Your App:</strong> Once registered, you can upload your mobile application for government services.</li><li><strong>Review and Approval:</strong> The Gov.in Appstore team will review your app for security, functionality, and adherence to its guidelines.</li><li><strong>Publish Your App:</strong> If your app meets their requirements, it will be published on the app store for users to download.</li></ol><p>For detailed information on developer registration, app upload guidelines, and managing your apps, it’s recommended to visit the official Gov.in Appstore website: <a href="https://play.google.com/store/apps/dev?id=9076108670215860604&amp;hl=en_IN&amp;gl=US">https://play.google.com/store/apps/dev?id=9076108670215860604&amp;hl=en_IN&amp;gl=US</a></p><h3>Indus App Store</h3><p>Launched in February 2024, Indus Appstore is a new Indian alternative to Google Play Store for Android smartphones. Here’s what you need to know:</p><p><strong>Using Indus Appstore:</strong></p><ul><li><strong>Download Apps:</strong> Indus Appstore offers a wide variety of apps, including popular Indian apps and games. You can browse, search, download, and install apps similar to how you would on the Google Play Store.</li><li><strong>Localized Experience:</strong> A key feature of Indus Appstore is its focus on the Indian market. It supports 12 Indian languages and prioritizes Indian apps on its interface.</li></ul><p><strong>Uploading an App:</strong></p><ul><li><strong>Developer Friendly:</strong> Indus Appstore aims to attract developers by offering advantages like:</li><li><strong>Zero Listing Fees:</strong> Currently, there are no fees for listing apps on the Indus Appstore.</li><li><strong>Flexible Payment Gateways:</strong> Unlike Google Play Store’s cut on in-app purchases, Indus allows developers to use third-party payment gateways for a year without any commission.</li></ul><p><strong>How to Upload and Manage Apps:</strong></p><p>Specific details might change, but here’s a general idea:</p><ol><li><strong>Visit the Indus Appstore Website:</strong> Head over to Indus Appstore: <a href="https://www.indusappstore.com/">https://www.indusappstore.com/</a> for information on developer registration and app submission guidelines.</li><li><strong>Developer Registration:</strong> Look for a developer registration section on the website. You’ll likely need to create an account and provide required details about yourself or your development team.</li><li><strong>App Submission Process:</strong> Once registered, follow the app submission instructions outlined by Indus Appstore. This might involve uploading your app file, providing app description, and category selection.</li><li><strong>Review and Approval:</strong> The Indus Appstore team will review your app for security, functionality, and adherence to their guidelines.</li><li><strong>App Management:</strong> After approval, you should be able to manage your app listing and updates through the developer portal on the Indus Appstore website.</li></ol><p>For the latest information and any updates on the developer registration process, it’s best to consult the official Indus Appstore website.</p><h3>Developer’s note</h3><ul><li><strong>Missing App support</strong>: It is very much possible that at the beginning some apps might be missing in the supported app store in BharOS. Then it’s very important to give alternate options like PWA by redirecting from the App Store smartly to fulfill its user requirements if the app is not available yet in the App Store. I see Android is giving options to support or fulfill requirements not only for users but its developers too.</li><li><strong>Complexity</strong>: The iOS ecosystem is a little rigid but the Andriod ecosystem follows open-armed support. This means Android is more challenging than iOS. BharOS must be technically capable of addressing the complexity and challenges like Android OS.</li></ul><h3>Some sources</h3><ul><li><a href="https://www.youtube.com/watch?v=WViXTPv7uuM">‘BharOS’: Made-In-India Operating System For Mobile Phones</a></li><li><a href="https://www.linkedin.com/pulse/bharos-indias-own-operating-system-e-blitzine-kmv-4pr1f/">BharOS: India’s Own Operating System</a></li></ul><p><strong>This is the end of the story. Happy learning!!!</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=dfc86e3ba21c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native: List of UI libraries and their comparison]]></title>
            <link>https://thevinaysingh.medium.com/react-native-list-of-ui-libraries-and-their-comparison-06065a5c1c60?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/06065a5c1c60</guid>
            <category><![CDATA[react-native-paper]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[comparison]]></category>
            <category><![CDATA[react-native-elements]]></category>
            <category><![CDATA[react-native-ui-libraries]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Mon, 04 Dec 2023 15:06:57 GMT</pubDate>
            <atom:updated>2023-12-04T15:06:57.706Z</atom:updated>
            <content:encoded><![CDATA[<p>Why you should choose a UI library? Performance? Vulnerability? bundle?</p><h3>Agenda</h3><ul><li>List of Popular Libraries</li><li>Quick Comparisons</li><li>Conclusion</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z8zWmMZaU2bymE3hCff3Vw.png" /><figcaption>Comparison date 04 Dec 2023</figcaption></figure><h3>List of Popular Libraries</h3><h4>1. React Native Elements</h4><p>A popular library for building cross-platform native UI components. It provides a comprehensive set of components for basic UI elements, such as buttons, text inputs, and images.</p><p><strong>Repository</strong>: <a href="https://github.com/react-native-elements/react-native-elements">https://github.com/react-native-elements/react-native-elements</a></p><p><strong>Documentation</strong>: <a href="https://github.com/react-native-elements/react-native-elements">https://github.com/react-native-elements/react-native-elements</a></p><p><strong>Npm package</strong>: <a href="https://www.npmjs.com/package/react-native-elements">https://www.npmjs.com/package/react-native-elements</a></p><h4>2. React Native Paper</h4><p>A Material Design-inspired UI library for React Native. It provides a consistent and visually appealing look and feel across platforms.</p><p><strong>Repository</strong>: <a href="https://github.com/callstack/react-native-paper">https://github.com/callstack/react-native-paper</a></p><p><strong>Documentation</strong>: <a href="https://github.com/callstack/react-native-paper">https://github.com/callstack/react-native-paper</a>callstack/react-native-paper: <a href="https://www.npmjs.com/package/react-native-paper">https://www.npmjs.com/package/react-native-paper</a></p><h4>3. NativeBase</h4><p>A powerful library for building custom and complex UI components. It offers a flexible and performant approach to native UI development.</p><p><strong>Repository</strong>: <a href="https://github.com/GeekyAnts/NativeBase">https://github.com/GeekyAnts/NativeBase</a></p><p><strong>Documentation</strong>: <a href="https://docs-v2.nativebase.io/">https://docs-v2.nativebase.io/</a></p><p><strong>Npm package</strong>: <a href="https://www.npmjs.com/package/native-base">https://www.npmjs.com/package/native-base</a></p><h4>4. Shoutem UI</h4><p>A library focused on creating beautiful and functional UI components for React Native mobile apps. It provides a well-designed set of components and a customizable theming system.</p><p><strong>Repository</strong>: <a href="https://github.com/shoutem/ui">https://github.com/shoutem/ui</a></p><p><strong>Documentation</strong>: <a href="https://shoutem.github.io/docs/ui-toolkit/introduction">https://shoutem.github.io/docs/ui-toolkit/introduction</a></p><p><strong>Npm package</strong>: <a href="https://www.npmjs.com/package/@shoutem/ui">https://www.npmjs.com/package/@shoutem/ui</a></p><h4>5. React Native Material UI</h4><p>A Material Design-oriented UI library for React Native. It offers a comprehensive collection of components and adheres to Material Design guidelines.</p><p><strong>Repository</strong>: <a href="https://github.com/xotahal/react-native-material-ui">https://github.com/xotahal/react-native-material-ui</a></p><p><strong>Documentation</strong>: <a href="https://mui.com/">https://mui.com/</a></p><p><strong>Npm package</strong>: <a href="https://www.npmjs.com/package/react-native-material-ui">https://www.npmjs.com/package/react-native-material-ui</a></p><h4>6. UI Kitten</h4><p>A cross-platform UI library that follows the iOS and Android native design guidelines. It provides a set of components for building native-looking UI elements.</p><p><strong>Repository</strong>: <a href="https://github.com/akveo/react-native-ui-kitten">https://github.com/akveo/react-native-ui-kitten</a></p><p><strong>Documentation</strong>: <a href="https://akveo.github.io/react-native-ui-kitten/">https://akveo.github.io/react-native-ui-kitten/</a></p><p><strong>Npm package</strong>: <a href="https://www.npmjs.com/~ui-kitten">https://www.npmjs.com/~ui-kitten</a></p><h4>7. RNUI (React Native UI Library)</h4><p>React Native UI Library: A library focused on creating lightweight and performant UI components for React Native. It provides a bare-bones set of components that can be easily customized.</p><p><strong>Repository</strong>: <a href="https://github.com/rnkit">https://github.com/rnkit</a></p><p><strong>Documentation</strong>: <a href="https://www.npmjs.com/package/agora-rn-uikit">https://www.npmjs.com/package/agora-rn-uikit</a><br><strong>Npm package</strong>: <a href="https://www.npmjs.com/package/agora-rn-uikit">https://www.npmjs.com/package/agora-rn-uikit</a></p><h4>8. Teaset</h4><p>A UI library for building cross-platform native UI components with a focus on accessibility. It provides a set of accessible components that meet WCAG 2.0 standards.</p><p><strong>Repository</strong>: <a href="https://github.com/rilyu/teaset">https://github.com/rilyu/teaset</a></p><p><strong>Documentation</strong>: <a href="https://www.etsy.com/market/teaset">https://www.etsy.com/market/teaset</a></p><p><strong>Npm package</strong>: <a href="https://www.npmjs.com/package/teaset">https://www.npmjs.com/package/teaset</a></p><h4>9. Lottie for React Native</h4><p>A library for rendering Lottie animations in React Native apps. It allows you to integrate Lottie animations into your UI, enhancing the visual appeal and user engagement.</p><p><strong>Repository</strong>: <a href="https://github.com/airbnb/lottie-react-native">https://github.com/airbnb/lottie-react-native</a></p><p><strong>Documentation</strong>: <a href="http://airbnb.io/lottie/">http://airbnb.io/lottie/</a></p><p><strong>Npm package</strong>: <a href="https://www.npmjs.com/package/lottie-react-native">https://www.npmjs.com/package/lottie-react-native</a></p><h4>10. React Native Vector Icons</h4><p>A library for loading and rendering vector icons in React Native apps. It provides a wide range of popular icon sets and supports custom icon fonts.</p><p><strong>Repository</strong>: <a href="https://github.com/oblador/react-native-vector-icons">https://github.com/oblador/react-native-vector-icons</a></p><p><strong>Documentation</strong>: <a href="https://oblador.github.io/react-native-vector-icons/">https://oblador.github.io/react-native-vector-icons/</a></p><p><strong>Npm package</strong>: <a href="https://www.npmjs.com/package/react-native-vector-icons">https://www.npmjs.com/package/react-native-vector-icons</a></p><p>These UI libraries offer different strengths and cater to specific needs. Consider factors like the complexity of your app, the desired design style, and the level of customization you require when choosing a library.</p><h3>Quick Comparisons</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z8zWmMZaU2bymE3hCff3Vw.png" /><figcaption>Comparison date 04 Dec 2023</figcaption></figure><h4>Useful Insights</h4><ul><li><strong>React Native Elements:<br><em>Pros (5): huge </em></strong><em>stars,</em><strong><em> high </em></strong><em>usage trends, </em><strong><em>low</em></strong><em> bundle size, </em><strong><em>high</em></strong><em> performance, </em><strong><em>large 6631</em></strong><em> closed issues </em><strong><br><em>Cons (3)</em></strong><em>: </em><strong><em>132</em></strong><em> Open issues, </em><strong><em>medium</em></strong><em> vulnerabilities, </em><strong><em>huge 6631</em></strong><em> raised issues</em></li><li><strong>React Native Paper:<br><em>Pros (7): huge </em></strong><em>stars, </em><strong><em>high </em></strong><em>usage trends, </em><strong><em>low but greater than React Native Elements</em></strong><em> bundle size, </em><strong><em>fewer 57 </em></strong><em>open issues than </em><strong><em>React Native Elements</em></strong><em>, </em><strong><em>low</em></strong><em> vulnerabilities, </em><strong><em>less 1864</em></strong><em> raised issues, </em><strong><em>low</em></strong><em> vulnerabilities </em><strong><br><em>Cons (1)</em></strong><em>: </em><strong><em>medium</em></strong><em> performance</em></li><li><strong>NativeBase<br><em>Cons (6)</em></strong><em>: shows </em><strong><em>huge</em></strong><em> bundle size, </em><strong><em>large</em></strong><em> open issues, </em><strong><em>medium</em></strong><em> performance, </em><strong><em>medium</em></strong><em> vulnerabilities, </em><strong><em>huge 5027</em></strong><em> raised issues, and </em><strong><em>medium</em></strong><em> usage.</em></li><li><strong>Shoutem UI:<br><em>Cons(1)</em></strong><em>: </em><strong><em>low</em></strong><em> performance<br></em><strong><em>pros(3)</em></strong><em>: </em><strong><em>small</em></strong><em> bundle, </em><strong><em>less</em></strong><em> open issues, </em><strong><em>low</em></strong><em> vulnerabilities</em></li><li>The rest of the options have <strong><em>low</em></strong><em> performance</em> and <strong><em>low</em></strong><em> vulnerabilities</em> or <strong><em>high</em></strong><em> open issues</em>.</li></ul><h3>Conclusion</h3><p>As per my choice, I would prefer the below options to be used in the project</p><ol><li><strong>React Native Elements</strong></li><li><strong>React Native Paper</strong></li><li><strong>Shoutem UI</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C7BlvfKg7ovak3jyB8HXog.png" /></figure><ul><li><strong>React Native Elements</strong> has <strong>high performance</strong> and <strong>low bundle</strong> size but <strong>huge raised issue</strong> and <strong>medium vulnerabilities</strong> that makes little hard to choose as best one. but has other nice benefits too.</li><li><strong>Shoutem UI </strong>shows <strong>low performance</strong>, which makes it also hard to choose as best one.</li><li><strong>React Native Paper </strong>shows <strong>medium performance</strong> but <strong>low vulnerabilities</strong> from the security perspective and <strong>fewer raised issues</strong> with high usage which might be a good option. The bonus is it is developed by the Callstack team.</li></ul><h4><strong>React Native Elements vs </strong>React Native Paper</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*beaVixm3ER3J-F_2zoeDtA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Yn96z-xD1hYUIo3VWhIFRw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KkwhgSPIgbHaWWM-GrCtUw.png" /></figure><blockquote>Choose as per your convenience</blockquote><p>Happy learning!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=06065a5c1c60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ways to use pre-commit, pre-push hooks in React/React Native]]></title>
            <link>https://thevinaysingh.medium.com/ways-to-use-pre-commit-pre-push-hooks-in-react-react-native-22b851bc9331?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/22b851bc9331</guid>
            <category><![CDATA[lefthook]]></category>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[git-hooks]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Thu, 30 Nov 2023 18:27:16 GMT</pubDate>
            <atom:updated>2023-12-01T07:19:16.026Z</atom:updated>
            <content:encoded><![CDATA[<h3>Ways to use pre-commit, pre-push, and commit-msg hooks in React/React Native</h3><h3>Agenda</h3><ul><li><strong>What are Git hooks?</strong></li><li><strong>How to use pre-commit and pre-push?</strong></li><li><strong>1. Using husky and lint-staged</strong></li><li><strong>2. Using lefthook</strong></li><li><strong>3. Githubs Actions</strong></li><li><strong>Configure Commit message (commit-msg)</strong></li></ul><h3>What are Git hooks?</h3><p>Git hooks are scripts that Git executes before or after events such as commit, push, merge, and others.</p><p><strong>pre-commit</strong> and <strong>pre-push</strong> hooks are specific types of hooks that run before a commit or push operation, respectively.</p><h4>pre-commit Hook</h4><ul><li>The pre-commit hook is executed just before a commit is made. It allows you to inspect the changes that are about to be committed and possibly reject the commit if certain conditions are not met.</li><li><strong>Common use cases: </strong>running <strong>linters</strong>, <strong>code formatting checks</strong>, or other <strong>static analysis tools</strong></li></ul><h4>pre-push Hook</h4><ul><li>The pre-push hook is executed just before remote refs are updated during a push.</li><li><strong>Common use cases:</strong> running <strong>unit tests</strong>, <strong>integration tests</strong>, or other automated checks to prevent pushing code that might break the build or fail tests on the remote repository.</li></ul><h4>commit-msg Hook</h4><ul><li>The commit-msg hook is triggered during the process of creating a commit message but before the commit is actually created.</li><li><strong>Common use cases</strong> include enforcing <strong>commit message conventions</strong>, checking for specific content, or performing other validation tasks.</li></ul><p>Hooks are typically scripts or executables located in the .git/hooks directory of your Git repository. They are written in any scripting or programming language that the system supports (e.g., shell scripts, Python, Node.js).</p><h3>How to use pre-commit and pre-push?</h3><p>We have a couple of ways to enable pre-commit and pre-push hooks. Some of them are:</p><ul><li>Using husky and lint-staged</li><li>Using lefthook</li><li>Using Github actions</li></ul><p>The below sections will give a detailed view.</p><h3>1. Using husky and lint-staged</h3><h4>husky</h4><p>Husky is a popular npm package that allows developers to run custom scripts against their repository. Husky works with any project that uses a package.json file. Husky helps developers work with Git hooks more efficiently</p><h4>lint-staged</h4><p>Lint-staged is a tool that runs tasks on files that are staged in git. It can run multiple linters on staged files to fix and format code before committing. lint-staged will always pass a list of all staged files to the task, and ignoring any files should be configured in the task itself.</p><p><strong>Notes</strong>: Husky may be used individually.</p><h4>Steps to configure</h4><p><strong>1. Install husky and lint-staged:</strong></p><pre>npm install husky lint-staged --save-dev<br>// or<br>yarn add -D husky lint-staged</pre><p><strong>2. Configure husky script: </strong>This can be configured in 2 ways.</p><ul><li>Configure using package.json <br>- Add lint-staged and husky block</li></ul><pre>{<br>  &quot;scripts&quot;: {<br>    /*<br>    The &quot;prepare&quot;: &quot;husky install&quot; script in the package.json file is used<br>    to automatically set up Husky during the installation of a Node.js package.<br>    After the &quot;prepare&quot; script is executed during the installation process,<br>    you&#39;ll find Husky-related files and configurations in your project.<br>    This includes the .husky directory and the hooks<br>    (e.g., pre-commit, pre-push) in the .git/hooks` directory.<br>    */<br>    &quot;prepare&quot;: &quot;husky install&quot;,<br>    &quot;lint&quot;: &quot;eslint .&quot;,<br>    &quot;test&quot;: &quot;jest&quot;,<br>    // Add other scripts as needed<br>  },<br>  &quot;lint-staged&quot;: {<br>    &quot;*.{js,jsx,ts,tsx}&quot;: [&quot;npm run lint&quot;, &quot;npm test&quot;, &quot;git add&quot;]<br>    // Add other file patterns and tasks as needed<br>  },<br>  &quot;husky&quot;: {<br>    &quot;hooks&quot;: {<br>      &quot;pre-commit&quot;: &quot;lint-staged&quot;,<br>      &quot;pre-push&quot;: &quot;npm test&quot;<br>      // Add other hooks and tasks as needed<br>    }<br>  }<br>}</pre><ul><li>Configure by creating a file or folder:<br>- Create a lint-staged.js file at the root of your project<br>- Run npx husky install at root, this will create a .husky folder at the root of your project.<br>- To add a pre-push hook, create a .husky/pre-push file.<br>- To add a pre-commit hook, create a .husky/pre-commit file.<br>- You may add multiple commands in pre-push and pre-commit file.</li></ul><pre>// lint-staged.js<br>module.exports = {<br>  &#39;*.{js,jsx,ts,tsx}&#39;: [<br>    &#39;eslint --fix&#39;,<br>    &#39;prettier --write&#39;,<br>  ],<br>};</pre><pre># This pre-push file<br>#!/bin/bash<br><br>npm run test</pre><pre># This pre-commit file<br>#!/bin/bash<br><br>npm run lint</pre><h3>2. Using lefthook</h3><p>Lefthook is a Git hooks manager written in Go that simplifies the installation and configuration of Git hooks. It is a fast, efficient, and polyglot tool that can be used with both JavaScript and Ruby projects.</p><h4>Steps to configure</h4><p><strong>1. Install </strong>lefthook<strong> npm package: <br>- </strong>npm package @evilmartians/lefthook and lefthook are the same.</p><pre>npm install @evilmartians/lefthook --save-dev<br>// or<br>yarn add -D @evilmartians/lefthook</pre><p><strong>2. Create a </strong>lefthook.yml<strong> file: </strong>It might be created automatically while installing the package. If it is not create it manually.</p><p><strong>3. Define pre-commit hook in lefthook.yml</strong></p><pre># EXAMPLE USAGE:<br>#   Refer for explanation to following link:<br>#   https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md<br><br>pre-commit:<br>  # &quot; parallel: true&quot; is used for Parallel execution for large-scale apps.<br>  # For larger commits, one can utilize spell checks, type checks, ESLint,<br>  # and StyleLint in parallel, saving tons of time for developers.<br>  parallel: true<br>  commands:<br>    lint:<br>      glob: &#39;*.{js,ts,jsx,tsx}&#39; # glob filter for list of files<br>      run: npx eslint {staged_files} # {staged_files} or {all_files} - list of files<br>    types:<br>      glob: &#39;*.{js,ts, jsx, tsx}&#39;<br>      run: npx tsc --noEmit<br></pre><pre>pre-commit:<br>  parallel: true<br>  commands:<br>    eslint: &quot;npm run lint&quot;<br>    jest: &quot;npm test&quot;</pre><pre>pre-commit:<br>  lint:<br>    command: npm run lint<br>  test:<br>    command: npm run test</pre><p><strong>4. Define pre-push hook in lefthook.yml</strong></p><pre># EXAMPLE USAGE:<br>#   Refer for explanation to following link:<br>#   https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md<br><br>pre-push:<br>  parallel: true<br>  commands:<br>    packages-audit:<br>      tags: frontend security<br>      run: yarn audit # Perform a vulnerability audit against the installed packages.<br>    <br>    frontend-style:<br>      files: git diff --name-only master # files with, diff with master.<br>      glob: &quot;*.js&quot;<br>      run: yarn stylelint {push_files} # This may used in React project <br><br>    # The git diff --name-only @{push} command in Lefthook is used to<br>    # list the files that will be pushed to the remote repository.<br>    # It is typically used in a pre-push hook to ensure that only<br>    # the desired files are being pushed.<br>    # The @{push} syntax refers to the tip of the remote repository&#39;s push branch.<br>    lint:<br>      files: git diff --name-only @{push}<br>      glob: &#39;*.{js,ts,jsx,tsx}&#39;<br>      run: npx eslint {push_files} # may use yarn eslint too.<br>    <br>    types:<br>      files: git diff --name-only @{push}<br>      glob: &#39;*.{js,ts, jsx, tsx}&#39;<br>      run: npx tsc --noEmit<br>    <br>    test:<br>      run: yarn test</pre><p><strong>5. Define other hooks in lefthook.yml: </strong>you can take a look at <a href="https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md">detailed-lefthook-configuration</a> for more details.</p><pre># EXAMPLE USAGE:<br>#   Refer for explanation to following link:<br>#   https://github.com/evilmartians/lefthook/blob/master/docs/configuration.md<br><br>post-push:<br>  deploy:<br>    command: npm run deploy<br><br>commit-msg:<br>  parallel: true<br>  commands:<br>    commitlint:<br>      run: npx commitlint --edit</pre><p><strong>4. Test Lefthook commands: </strong>You may use<strong> </strong>lefthook run pre-commit command to test or run your lefthook command if lefthook is installed globally as a tool.</p><h3>3. Githubs Actions</h3><p>GitHub Actions provides a continuous integration and continuous delivery (CI/CD) platform that can also execute pre-commit and pre-push checks.</p><p>Configuring pre-commit and pre-push hooks using GitHub Actions involves creating a YAML file that defines the workflow steps, including the checks to be executed. Here’s a step-by-step guide:</p><ol><li><strong>Create a .github/workflows directory</strong>: Within your project repository, create a directory named .github/workflows. This directory will contain the YAML files that define your GitHub Actions workflows.</li><li><strong>Create a pre-commit.yml file</strong>: Inside the .github/workflows directory, create a file named pre-commit.yml. This file will define the pre-commit hooks for your project.</li><li><strong>Define pre-commit steps</strong>: In the pre-commit.yml file, define the steps to be executed before committing code. These steps typically involve running linters, tests, or other automated checks.</li></ol><pre>name: Pre-commit checks<br><br>on:<br>  push:<br>    branches: [ main ]<br>  pull_request:<br>    branches: [ main ]<br><br>jobs:<br>  pre-commit:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - uses: actions/checkout@v3<br><br>      - name: Install dependencies<br>        run: npm install<br><br>      - name: Run linters<br>        run: npm run lint<br><br>      - name: Run tests<br>        run: npm run test<br><br>      - name: Check formatting<br>        run: npm run format-check</pre><p><strong>4. Create a pre-push.yml file:</strong> Additionally, create a file named pre-push.yml to define the pre-push hooks. These hooks are executed before pushing code to a remote repository.</p><pre>name: Pre-push checks<br><br>on:<br>  push:<br>    branches: [ main ]<br><br>jobs:<br>  pre-push:<br>    runs-on: ubuntu-latest<br><br>    steps:<br>      - uses: actions/checkout@v3<br><br>      - name: Install dependencies<br>        run: npm install<br><br>      - name: Run tests<br>        run: npm run test<br><br>      - name: Check formatting<br>        run: npm run format-check</pre><p><strong>5. Commit and push the workflow files</strong>: Commit the pre-commit.yml and pre-push.yml files along with your code changes and push them to the remote repository.</p><p>GitHub Actions will automatically detect the workflow files and execute the defined steps whenever a push or pull request event occurs. This ensures that the pre-commit and pre-push checks are executed before any code is merged into the main branch.</p><h3>Configure Commit message (commit-msg)</h3><h4>1. Using commitlint and husky</h4><p>Commitlint is a tool used to enforce a consistent commit message style within a project. It helps maintain a clean and standardized commit history, making it easier for teams to understand changes, track issues, and automate release processes.</p><p>List of packages used in commitlint</p><ul><li><strong>[<em>Required</em>] commitlint or </strong><a href="https://www.npmjs.com/package/@commitlint/cli"><strong>@commitlint/cli</strong></a>: It is a tool for enforcing consistent commit messages in your React Native project.</li><li><strong>[<em>Recommended</em>] </strong><a href="https://www.npmjs.com/package/@commitlint/config-conventional"><strong>@commitlint/config-conventional</strong></a><strong>: </strong>It is a configuration preset for Commitlint that defines a set of conventional commit message rules.</li><li><strong>[<em>Optional</em>] </strong><a href="https://www.npmjs.com/package/commitlint-plugin-function-rules"><strong>commitlint-plugin-function-rules</strong></a><strong>: </strong>plugin to define rules as functions.</li></ul><blockquote>Note: commitlint npm package is an alias of @commitlint/cli npm package. Which means any one can be used and enough.</blockquote><p>The steps to configure are:</p><p><strong>1. Install as devDependencies</strong></p><pre>yarn add -D @commitlint/cli @commitlint/config-conventional commitlint-plugin-function-rules</pre><p><strong>2. Create </strong><strong>commitlint.config.js file at the root level</strong></p><pre>// Without @commitlint/config-conventional and commitlint-plugin-function-rules<br>module.exports = {<br>  rules: {<br>    &#39;subject-case&#39;: [2, &#39;always&#39;, &#39;sentence-case&#39;],<br>    &#39;subject-empty&#39;: [2, &#39;never&#39;],<br>    &#39;subject-full-stop&#39;: [2, &#39;never&#39;],<br>    &#39;type-enum&#39;: [<br>      2,<br>      &#39;always&#39;,<br>      [<br>        &#39;feat&#39;,<br>        &#39;fix&#39;,<br>        &#39;chore&#39;,<br>        &#39;docs&#39;,<br>        &#39;refactor&#39;,<br>        &#39;style&#39;,<br>        &#39;test&#39;,<br>      ],<br>    ],<br>    &#39;type-required&#39;: [2, &#39;always&#39;],<br>  },<br>};</pre><pre>// Using @commitlint/config-conventional and commitlint-plugin-function-rules<br>module.exports = {<br>  extends: [&#39;@commitlint/config-conventional&#39;],<br>  plugins: [&#39;commitlint-plugin-function-rules&#39;],<br>  rules: {<br>    &#39;header-max-length&#39;: [0], // level: disabled<br>    &#39;function-rules/header-max-length&#39;: [<br>      2, // level: error<br>      &#39;always&#39;,<br>      (parsed) =&gt; {<br>        // Allow longer headers for commits with &quot;deps&quot; scope.<br>        if (parsed.scope === &#39;deps&#39; &amp;&amp; parsed.header.length &lt;= 200) {<br>          return [true];<br>        }<br>        return [false, &#39;deps header must not be longer than 200 characters&#39;];<br>      },<br>    ],<br>  },<br>};</pre><p><strong>3. Add </strong>.husky/commit-msg<strong> file</strong></p><pre><br>#!/bin/sh<br><br>npx --no -- commitlint --edit ${1}</pre><h4>2. Using lefthook</h4><p>Install npm package @evilmartians/lefthook as devDependency and create lefthook.yml file at the root level.</p><p>You may add commit message rules in multiple ways</p><p><strong>1. Define pre-commit hook with commitlint : <br>- </strong>Define a pre-commit hook that runs a script to validate the commit message.<br>- Follow all the steps to configure <strong>commitlint</strong>, except <strong>husky</strong>.<br>- At the place of husky we will use <strong>lefthook</strong> to trigger commitlint rules.</p><pre># lefthook.yml<br><br>pre-commit:<br>  parallel: true<br>  commit-msg:<br>    command: npx commitlint --edit</pre><p><strong>2. Define pre-commit hook with script file: </strong>When you try to commit specified script will be executed.</p><pre># lefthook.yml <br>pre-commit:<br>  parallel: true<br>  validate-commit-msg:<br>    command: ./validate-commit-msg.sh<br><br># Or<br>pre-commit:<br>  parallel: true<br>  scripts:<br>    &quot;validate-commit-msg.sh&quot;:<br>      runner: bash</pre><pre># validate-commit-msg.sh<br>#!/bin/bash<br>commit_msg=$(git diff --cached HEAD HEAD@{1} --format=&quot;%B&quot;)<br>first_line=$(echo &quot;$commit_msg&quot; | head -n 1)<br>verbs=(add change create delete fix improve remove update)<br>if [[ ! $verbs =~ $first_line ]]; then<br>  echo &quot;Error: Commit message must start with a verb.&quot;<br>  exit 1<br>fi<br>exit 0</pre><p><strong>3. Define commit-msg hook</strong></p><pre>commit-msg:<br>  parallel: true<br>  scripts:<br>    &quot;template_checker&quot;: # It will use this .lefthook/commit-msg/template_checker<br>      runner: bash<br><br># Or<br>commit-msg:<br>  parallel: true<br>  commands:<br>    validate:<br>      run: .lefthook/commit-msg/template_checker<br><br># Or Run commitlint before commit<br>commit-msg:<br>  parallel: true<br>  commands:<br>    commitlint:<br>      run: npx commitlint --edit</pre><pre># .lefthook/commit-msg/template_checker<br><br>INPUT_FILE=$1<br>START_LINE=`head -n1 $INPUT_FILE`<br>PATTERN=&quot;^(ISSUE)-[[:digit:]]+: &quot;<br>if ! [[ &quot;$START_LINE&quot; =~ $PATTERN ]]; then<br>  echo &quot;Bad commit message, see example: ISSUE-123: some text&quot;<br>  exit 1<br>fi</pre><h3>Conclusion</h3><p>To find more details on all git hooks, follow this <a href="https://git-scm.com/docs/githooks#_hooks">official-git-hooks</a></p><p>Happy learning!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=22b851bc9331" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Complete configuration of Inversify and plugins in React Native]]></title>
            <link>https://thevinaysingh.medium.com/complete-configuration-of-inversify-and-plugins-in-react-native-13061f2b6bf6?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/13061f2b6bf6</guid>
            <category><![CDATA[babel]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[inversifyjs]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react-native-development]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Tue, 21 Nov 2023 19:21:33 GMT</pubDate>
            <atom:updated>2023-11-26T12:54:42.805Z</atom:updated>
            <content:encoded><![CDATA[<h3>Agenda</h3><ul><li><strong>What is InversifyJS?</strong></li><li><strong>Configuration</strong><br>1. Install required packages<br>2. Update babel.config.js<br>3. Update tsconfig.json</li><li><strong>Implementation</strong><br>1. Import reflect-metadata in the initial file<br>2. Create a DI container<br>3. Create Injectable class dependencies<br>4. Bind dependencies<br>5. Resolve dependencies</li><li><strong>NPM Packages [Detailed]<br></strong>1. reflect-metadata<br>2. inversify-react<br>3. @babel/plugin-proposal-decorators<br>4. @babel/plugin-transform-class-properties<br>5. @babel/plugin-transform-class-static-block<br>6. inversify-binding-decorators</li></ul><h3>What is InversifyJS?</h3><p>InversifyJS is a powerful and lightweight inversion of control (IoC) container for TypeScript and JavaScript applications. IoC containers manage the dependency injection (DI) process, allowing developers to write more modular, scalable, and maintainable code.</p><h4>Key concepts and features of InversifyJS include:</h4><ol><li><strong>Inversion of Control (IoC):</strong> In a traditional program, the flow of control is determined by the application code. In an IoC container like InversifyJS, the control flow is inverted: the framework calls into the application code.</li><li><strong>Dependency Injection (DI)</strong>: DI is a design pattern where a component’s dependencies are injected rather than created within the component. InversifyJS facilitates DI by allowing you to define and manage the dependencies of your components.</li><li><strong>IoC Container</strong>: InversifyJS provides a container that holds a configuration of dependencies and manages their instantiation and injection. The container acts as a registry for bindings between abstractions (interfaces) and their concrete implementations.</li><li><strong>Decorators</strong>: InversifyJS makes use of TypeScript decorators to define metadata about classes. This metadata is then used by the IoC container for automatic dependency resolution.</li><li><strong>Modularity and Scalability</strong>: InversifyJS encourages a modular and scalable code structure. Components are loosely coupled, making it easier to swap out implementations and add or remove features without affecting the entire application.</li><li><strong>Lazy Loading</strong>: InversifyJS supports lazy loading of dependencies, meaning that components are only created when needed. This can improve application startup performance.</li></ol><h3>Configuration</h3><h4>1. Install required packages</h4><p>To configure inversify in React native, you need to install the below 2 sets of packages:</p><p><strong>1. dependencies</strong></p><ul><li>[<strong>Required</strong>] <a href="https://github.com/inversify/InversifyJS/">inversify</a>: yarn add inversify</li><li>[<strong>Required</strong> | Collect metadata for dependencies used by decorator] <a href="https://www.npmjs.com/package/reflect-metadata">reflect-metadata</a>: yarn add reflect-metadata</li><li>[<strong>Recommended</strong> | Context Provider &amp; Hooks Support] <a href="https://www.npmjs.com/package/inversify-react">inversify-react</a>: yarn add inversify-react</li><li>[<strong>Optional | Utility</strong>] <a href="https://www.npmjs.com/package/inversify-binding-decorators">inversify-binding-decorators</a>: yarn add inversify-binding-decorators</li></ul><p><strong>2. devDependencies</strong></p><ul><li>[<strong>Required | Decorator Support</strong>] <a href="https://babeljs.io/docs/babel-plugin-proposal-decorators">@babel/plugin-proposal-decorators</a>: yarn add -D @babel/plugin-proposal-decorators</li><li>[<strong>Required for Android Platform| Decorator Support</strong>] <a href="https://babeljs.io/docs/babel-plugin-transform-flow-strip-types">@babel/plugin-proposal-class-properties</a>: yarn add -D @babel/plugin-transform-flow-strip-types</li><li>[<strong>Required | Transform class properties</strong>] <a href="https://babeljs.io/docs/babel-plugin-transform-class-properties">@babel/plugin-transform-class-properties</a>: yarn add -D @babel/plugin-transform-class-properties</li><li>[<strong>Recommended| Transform Static block</strong>] <a href="https://babeljs.io/docs/babel-plugin-transform-class-static-block">@babel/plugin-transform-class-static-block</a>: yarn add -D @babel/plugin-transform-class-static-block</li></ul><p>For Detailed information on these packages, see below section <strong>NPM Packages.</strong></p><h4>2. Update babel.config.js</h4><pre>module.exports = function (api) {<br>  api.cache(true);<br>  return {<br>    presets: [&#39;module:metro-react-native-babel-preset&#39;],<br>    plugins: [<br>      [&#39;@babel/plugin-transform-flow-strip-types&#39;],<br>      [&#39;@babel/plugin-proposal-decorators&#39;, {legacy: true}],<br>      [&#39;@babel/plugin-transform-class-static-block&#39;],<br>      [&#39;@babel/plugin-transform-class-properties&#39;, {loose: true}],<br>      // ...other plugins<br>    ],<br>  };<br>};</pre><h4>3. Update tsconfig.json</h4><pre>{<br>  &quot;extends&quot;: &quot;@tsconfig/react-native/tsconfig.json&quot;,<br>  &quot;compilerOptions&quot;: {<br>    &quot;experimentalDecorators&quot;: true,<br>    &quot;emitDecoratorMetadata&quot;: true,<br>    &quot;types&quot;: [&quot;reflect-metadata&quot;],<br>    // Other options<br>  }  <br>}</pre><h3>Implementation</h3><h4>1. Import reflect-metadata in the initial file</h4><pre>// index.js<br>import &#39;reflect-metadata&#39;;<br><br>// Other imports<br>...</pre><h4>2. Create a DI container</h4><p>Create a separate file container.ts. It is recommended and important.</p><pre>// container.ts<br>import {Container} from &#39;inversify&#39;;<br><br>export const container = new Container();</pre><h4>3. Create Injectable class dependencies</h4><pre>import {injectable, inject} from &#39;inversify&#39;;<br><br>// Define interface<br>interface IAppLogger{<br>  log(message: string): void;<br>}<br><br>interface User {<br>  id: number;<br>  fullname: string;<br>}<br>interface IAppRepository {<br>  getUserById(id: number): Promise&lt;User&gt;;<br>}<br><br>// Implement the interface<br>class AppRepository implements IAppRepository {<br>  async getUserById(id: number): Promise&lt;User&gt; {<br>    // ...<br>  }<br>}<br><br>@injectable()<br>class AppService {<br>  constructor(<br>    @inject(&#39;IAppRepository&#39;) private appRepository: IAppRepository<br>  ) {}<br>  async getUserById(id: number): Promise&lt;User&gt; {<br>    return await this.appRepository.getUserById(id);<br>  }<br>}<br><br>@injectable()<br>class AppLogger implements IAppLogger {<br>  log(message: string): void {<br>    console.log(message);<br>  }<br>}<br><br>@injectable()<br>class AppClass {<br>  @inject(AppLogger)<br>  private logger: IAppLogger;<br><br>  constructor() {}<br><br>  executeAFun() {<br>    this.logger.log(&#39;Executing..&#39;);<br>  }<br>}</pre><h4>4. Bind dependencies</h4><pre>// Bind the interface to its implementation<br>container.bind&lt;IAppRepository&gt;(IAppRepository).to(AppRepository);<br>container.bind&lt;IAppLogger&gt;(&#39;IAppLogger&#39;).to(AppLogger);</pre><h4>5. Resolve dependencies</h4><pre>// Resolve dependency and use the class<br>const appClassInstance = container.resolve&lt;AppClass&gt;(AppClass);<br>appClassInstance.executeAFun();<br><br>// Get dependency<br>const appService = container.get&lt;AppService&gt;(AppService);<br>const user = appService.getUserById(123)</pre><h3>NPM Packages</h3><ol><li>reflect-metadata</li><li>inversify-react</li><li>@babel/plugin-proposal-decorators</li><li>@babel/plugin-transform-class-properties</li><li>@babel/plugin-transform-class-static-block</li><li>inversify-binding-decorators</li></ol><h4>1. reflect-metadata</h4><p>The reflect-metadata package is an essential part of Inversify React Native, and it is used to make the framework work.</p><p>Here are some of the specific uses of reflect-metadata in Inversify React Native:</p><ul><li><strong>Store and retrieve metadata:</strong> about classes, properties, methods, and parameters. decorators are commonly used to define metadata that the IoC (Inversion of Control) container can use to perform dependency injection.</li><li><strong>Injecting dependencies into classes</strong>: Inversify uses metadata to determine which dependencies should be injected into a class. The metadata is stored on the class itself, and it is retrieved by Inversify when the class is instantiated. Decorators such as @injectable(), @inject(), and others are used to define the relationships between interfaces and their concrete implementations.</li><li><strong>Creating instances of classes</strong>: Inversify uses metadata to create instances of classes. The metadata is stored on the constructor of the class, and it is retrieved by Inversify when the class is instantiated.</li><li><strong>Validating dependencies</strong>: Inversify uses metadata to validate dependencies. The metadata is stored on the properties and parameters of a class, and it is used by Inversify to ensure that the dependencies are of the correct type.</li></ul><blockquote>Without the reflect-metadata package, Inversify would not be able to inject dependencies into classes or create instances of classes.</blockquote><p><strong>Quick configuration</strong></p><ul><li>Install package: yarn add reflect-metadata</li><li>Enabling Reflect Metadata by updating the tsconfig.json file:</li></ul><pre>{<br>  ...<br>  &quot;compilerOptions&quot;: {<br>    ...<br>    &quot;experimentalDecorators&quot;: true,<br>    &quot;emitDecoratorMetadata&quot;: true,<br>    &quot;types&quot;: [&quot;reflect-metadata&quot;], <br>  }<br>}</pre><ul><li>Enable metadata reflection:</li></ul><pre>import &quot;reflect-metadata&quot;;</pre><p>In this example, the @inject(&#39;ILogger&#39;) decorator is used to inject the ILogger class into the MyClass class. The metadata for the injection is stored on the logger property of the MyClass class. When the MyClass class is instantiated, Inversify will retrieve the metadata and inject the ILogger class into the logger property.</p><h4>2. inversify-react</h4><p>Hooks and decorators for <a href="http://inversify.io/">InversifyJS</a> + <a href="https://reactjs.org/">React</a>.</p><p>inversify-react is not a standalone package. It provides a number of extensions that make it easier to use Inversify in React Native applications, including:</p><ul><li><strong>React component decoration</strong>: Inversify-react provides a decorator that can be used to decorate your React components, making it easy to inject dependencies into them.</li><li><strong>Context provider</strong>: Inversify-react provides a context provider that can be used to make your dependencies available to your React components.</li><li><strong>Hooks</strong>: Inversify-react provides a number of hooks that can be used to interact with Inversify from your React components.</li></ul><pre>import React, {PropsWithChildren, memo} from &#39;react&#39;;<br>import {Provider} from &#39;inversify-react&#39;;<br>import {container} from &#39;./container&#39;<br><br>export const AppContainer = () =&gt; {<br>  return (<br>    &lt;Provider container={() =&gt; container}&gt;<br>    ...<br>    ...<br>    &lt;/Provider&gt;<br>   );<br>};</pre><pre>import {useContainer, useInjection} from &#39;inversify-react&#39;;<br><br>export const TYPES = {<br>  Logger: Symbol.for(&#39;Logger&#39;),<br>};<br><br>const container = useContainer();<br>const logger = useInjection&lt;ILogger&gt;(TYPES.Logger);</pre><p>Overall, inversify-react is a powerful and easy-to-use DI container that can make your React Native applications more modular, maintainable, and testable.</p><p>Visit <a href="https://www.npmjs.com/package/inversify-react">here</a> for more details.</p><h4>3. @babel/plugin-proposal-decorators</h4><p>The @babel/plugin-proposal-decorators Babel plugin is crucial when working with decorators in TypeScript or JavaScript. In the context of InversifyJS and React Native, this plugin is often used to enable the use of decorators, such as @injectable() and @inject(), which are essential for setting up dependency injection with InversifyJS.</p><blockquote>TypeScript does not have native support for the ECMAScript decorator proposal without this plugin.</blockquote><p><strong>Installation</strong>: yarn add -D @babel/plugin-proposal-decorators</p><p><strong>Babel Configuration file (babal.config.js)</strong>:<br>The { &quot;legacy&quot;: true } option is used when working with TypeScript, as it aligns with the legacy behavior of TypeScript decorators.</p><pre>{<br> &quot;plugins&quot;: [<br> [&quot;@babel/plugin-proposal-decorators&quot;, { &quot;legacy&quot;: true }],<br> // other plugins…<br> ]<br>}</pre><p>However, the { &quot;version&quot;: &quot;2023–05&quot;} option is recommended to get the benefits of the latest updates while using this plugin.</p><pre>{<br>  &quot;plugins&quot;: [<br>    [&quot;@babel/plugin-proposal-decorators&quot;, { &quot;version&quot;: &quot;2023-05&quot; }],<br>   // other plugins…<br>  ]<br>}</pre><p>For more details, visit <a href="https://babeljs.io/docs/babel-plugin-proposal-decorators#options">here</a></p><p><strong>Notes:<br>1. </strong>If you use version: “2023–05” and do not enable plugins<strong> </strong>@babel/plugin-transform-class-static-block and<strong> </strong>@babel/plugin-transform-class-properties, then you might get errors like<strong> <em>“</em></strong><em>ERROR TypeError: Cannot read property ‘getItem’ of undefined in FlatList</em><strong><em>” </em></strong><em>in Android”. </em>Check this <a href="https://github.com/facebook/react-native/issues/36828">thread</a>.</p><h4>4. @babel/plugin-transform-class-properties</h4><h4>4. @babel/plugin-transform-class-properties</h4><p>The @babel/plugin-transform-class-properties plugin is a Babel plugin that transforms static class properties and properties declared with the property initializer syntax into regular class properties.</p><p>This plugin is part of the Babel ecosystem and is often used in conjunction with other plugins to transpile modern JavaScript features into code compatible with various environments.</p><p>Here’s a breakdown of its purpose and usage</p><p><strong>1. Class Properties</strong>: Class properties enable you to declare and initialize properties directly within the class, simplifying the syntax and making the code more concise. Prior to the introduction of class properties, you would typically initialize instance properties in the class constructor.</p><pre>// Without class properties<br>class MyClass {<br>  constructor() {<br>    this.myProperty = 42;<br>  }<br>}<br><br>// With class properties<br>class MyClass {<br>  myProperty = 42;<br>}</pre><p><strong>2. Transformed Code: </strong>Once the @babel/plugin-proposal-class-properties plugin is applied, Babel transforms class properties into compatible code that runs on environments without native support for this ECMAScript feature.</p><pre>// Before transformation<br>class MyClass {<br>  myProperty = 42;<br>}<br><br>// After transformation<br>class MyClass {<br>  constructor() {<br>    this.myProperty = 42;<br>  }<br>}</pre><p><strong>3. Benefits: </strong>Using class properties makes the code more readable and reduces boilerplate code, especially in classes with multiple properties.</p><pre>// Before class properties<br>class Point {<br>  constructor(x, y) {<br>    this.x = x;<br>    this.y = y;<br>  }<br>}<br><br>// After class properties<br>class Point {<br>  x = 0;<br>  y = 0;<br>}</pre><p>In addition to transforming static class properties and properties plugin also supports the following features:</p><ul><li><strong>Field initializers</strong>: This feature allows you to initialize fields with expressions, such as function calls or object literals.</li><li><strong>Method shorthand</strong>: This feature allows you to define methods in a more concise way.</li><li><strong>Static methods</strong>: This feature allows you to define static methods on classes.</li><li><strong>Private fields</strong>: This feature allows you to define private fields on classes.</li></ul><p><strong>Enable plugin through in babel.config.js</strong>:</p><pre>module.exports = function (api) {<br>  api.cache(true);<br>  return {<br>    presets: [&#39;module:metro-react-native-babel-preset&#39;],<br>    plugins: [<br>      [&#39;@babel/plugin-proposal-decorators&#39;, {legacy: true}],<br>      [&#39;@babel/plugin-transform-class-properties&#39;, {loose: true}],<br>    ],<br>  };<br>};</pre><p><strong>Why </strong><strong>loose: true is used?</strong></p><p>When you use loose: true with @babel/plugin-proposal-class-properties, you are instructing Babel to generate a more efficient and less strict transformation for class properties. The loose mode sacrifices some strict adherence to the ECMAScript specification in favor of better performance and more concise output.</p><p>Visit <a href="https://babeljs.io/docs/babel-plugin-transform-class-properties">here</a> for more details</p><h4>5. @babel/plugin-transform-class-static-block</h4><p>the @babel/plugin-transform-class-static-block plugin is part of the Babel ecosystem, and it is designed to transform static blocks in JavaScript classes.</p><p>Static Blocks (Class Fields Initialization Proposal) allow developers to execute code at the class level, specifically during the creation of the class. Static blocks are declared using the static keyword followed by a pair of curly braces. The code inside these curly braces runs when the class is defined.</p><pre>class MyClass {<br>  static {<br>    // code to run during class initialization<br>    console.log(&#39;Static block executed&#39;);<br>  } <br><br>  // other class members<br>}</pre><p><strong>Enable plugin through babel.config.js</strong></p><pre>// babel.config.js<br>module.exports = {<br>  plugins: [<br>    [&#39;@babel/plugin-proposal-decorators&#39;, { legacy: true }],<br>    &#39;@babel/plugin-transform-class-static-block&#39;,<br>    // other plugins...<br>  ],<br>};</pre><p><strong>@babel/plugin-transform-class-properties vs @babel/plugin-transform-class-static-block</strong></p><p>@babel/plugin-transform-class-properties</p><ul><li><strong>Purpose</strong>: Transform static class properties and properties declared with the property initializer syntax into regular class properties.</li><li><strong>Effects</strong>: Improves code readability, reduces code complexity, improves type checking</li><li><strong>Use cases</strong>: General-purpose class property transformation</li></ul><p>@babel/plugin-transform-class-static-block</p><ul><li><strong>Purpose</strong>: Transform static blocks into private properties</li><li><strong>Effects</strong>: Improves code readability, reduces memory footprint, improves type safety</li><li><strong>Use cases</strong>: Static block transformation</li></ul><h4>6. inversify-binding-decorators</h4><p>inversify-binding-decorators is a set of decorators that simplifies the process of creating inversify bindings for classes in InversifyJS.</p><p>InversifyJS provides decorators like @injectable() and @inject() to declare classes as injectable and to specify dependencies for constructor parameters. inversify-binding-decorators extends this by providing additional decorators that allow you to define bindings in a more concise and expressive way.</p><p>Here are some decorators provided by inversify-binding-decorators:</p><ul><li>@provide is used to declare a class as injectable. It serves a similar purpose to @injectable() in InversifyJS.</li><li>@provideSingleton is a shorthand for providing a singleton binding.</li></ul><pre>import &#39;reflect-metadata&#39;;<br>import { Container } from &#39;inversify&#39;;<br>import { provide, provideSingleton } from &#39;inversify-binding-decorators&#39;;<br><br>@provideSingleton(MyService)<br>class MyService {<br>  // class implementation<br>}<br><br>@provide(ServiceWithDependency)<br>class ServiceWithDependency {<br>  constructor(private myService: MyService) {<br>    // constructor implementation<br>  }<br>}<br><br>const container = new Container()</pre><p>You may visit <a href="https://github.com/inversify/inversify-basic-example">official-inversify-example</a></p><h3>Conclusion</h3><p>I hope, it helps. Happy learning!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=13061f2b6bf6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Typescript compiler configuration in React Native]]></title>
            <link>https://thevinaysingh.medium.com/typescript-compiler-configuration-in-react-native-bf03aa816941?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/bf03aa816941</guid>
            <category><![CDATA[typescript-compiler]]></category>
            <category><![CDATA[tsconfig]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[compilers]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Mon, 20 Nov 2023 16:39:08 GMT</pubDate>
            <atom:updated>2023-11-20T16:39:08.069Z</atom:updated>
            <content:encoded><![CDATA[<h4>tsconfig.json</h4><h3>What is tsconfig.json?</h3><p>tsconfig.json is a JSON file that is used to configure the TypeScript compiler options and settings to compile TypeScript code into JavaScript code. The tsconfig.json file plays a crucial role in configuring the TypeScript compiler for a React Native project.</p><p>Example of tsconfig.json file</p><pre>// tsconfig.json<br>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;es2017&quot;, /* Specify ECMAScript target version: &#39;ES3&#39; (default), &#39;ES5&#39;, &#39;ES2015&#39;, &#39;ES2016&#39;, &#39;ES2017&#39;,&#39;ES2018&#39; or &#39;ESNEXT&#39;. */<br>    &quot;module&quot;: &quot;esnext&quot;,  /* Specify module code generation: &#39;none&#39;, &#39;commonjs&#39;, &#39;amd&#39;, &#39;system&#39;, &#39;umd&#39;, &#39;es2015&#39;, or &#39;ESNext&#39;. */<br>    &quot;jsx&quot;: &quot;react-native&quot;, /* Specify JSX code generation: &#39;preserve&#39;, &#39;react-native&#39;, or &#39;react&#39;. */<br>    &quot;lib&quot;: [&quot;esnext&quot;, &quot;dom&quot;],<br>    &quot;strict&quot;: true,<br>    &quot;allowJs&quot;: true, /* Allow javascript files to be compiled. */<br>    &quot;moduleResolution&quot;: &quot;node&quot;, /* Specify module resolution strategy: &#39;node&#39; (Node.js) or &#39;classic&#39; (TypeScript pre-1.6). */<br>    &quot;esModuleInterop&quot;: true,<br>    &quot;sourceMap&quot;: true,<br>    &quot;baseUrl&quot;: &quot;./&quot;,<br>    &quot;paths&quot;: {<br>      &quot;*&quot;: [&quot;types/*&quot;]<br>    },<br>    &quot;resolveJsonModule&quot;: true, /* Allows importing modules with a ‘.json’ extension, which is a common practice in node projects. */<br>    &quot;isolatedModules&quot;: true, /* Transpile each file as a separate module (similar to &#39;ts.transpileModule&#39;). */<br>    &quot;skipLibCheck&quot;: true, /* Skip type checking of declaration files. */<br>  },<br>  &quot;include&quot;: [&quot;src/**/*.ts&quot;, &quot;src/**/*.tsx&quot;, &quot;index.tsx&quot;],<br>  &quot;exclude&quot;: [&quot;node_modules&quot;],<br>  &quot;ts-node&quot;: {<br>    &quot;files&quot;: true<br>  },<br>}</pre><p>Here’s an overview of some common settings you might find in a tsconfig.json file for a React Native TypeScript project:</p><ol><li>compilerOptions Section</li><li>include and exclude Sections</li><li>ts-node and sourceMap Options</li><li>esModuleInterop Option</li><li>baseUrl and paths Options</li></ol><h3>1. compilerOptions Section:</h3><p>This section contains various compiler options that determine how TypeScript code is transpiled to JavaScript. Some important options include:</p><ul><li>target: Specifies the ECMAScript target version. For React Native, it&#39;s often set to esnext or es2017 to take advantage of the latest JavaScript features. You may set to es5, or es6. Default is es3</li><li>module: Defines the module system. For React Native, it&#39;s typically set to esnext or commonjs. You should set this option to commonjs if you are using a bundler like Webpack, or you should set it to esnext if you are using a module bundler like Rollup.</li><li>jsx: Specifies the JSX compiler to use. For React Native, it&#39;s usually set to react-native. you should set this option to preserve if you want to preserve the original JSX code in the compiled JavaScript code, or you should set it to react if you want the JSX code to be transformed into regular JavaScript code.</li><li>lib: Defines the set of available library files. Common values include [&quot;esnext&quot;, &quot;dom&quot;] for React Native projects.</li><li>strict: Enforces strict type checking. The default value is false, which means that the compiler will allow some loose coding practices. However, if you want the compiler to enforce more strict rules, you can set this option to true.</li><li>esModuleInterop: Simplifies interoperability between CommonJS and ES Modules. This option specifies whether the TypeScript compiler should generate code that is compatible with ES modules. You should set this option to true if you are using a module bundler like Rollup, or you should set it to false if you are using a bundler like Webpack.</li></ul><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;target&quot;: &quot;es2017&quot;,<br>    &quot;module&quot;: &quot;esnext&quot;,<br>    &quot;jsx&quot;: &quot;react-native&quot;,<br>    &quot;lib&quot;: [&quot;esnext&quot;, &quot;dom&quot;],<br>    &quot;strict&quot;: true,<br>    &quot;esModuleInterop&quot;: true,<br>  }<br>}</pre><h3>2. include and exclude Sections:</h3><p>The include and exclude sections determine which files should be included or excluded during compilation. In a React Native TypeScript project, you often include all files in the project directory:</p><pre>{<br>  &quot;include&quot;: [&quot;src/**/*.ts&quot;, &quot;src/**/*.tsx&quot;, &quot;index.tsx&quot;],<br>  &quot;exclude&quot;: [&quot;node_modules&quot;]<br>}</pre><h3>3. ts-node and sourceMap Options</h3><p>In development, you might want to enable sourceMap for better debugging. Additionally, if you’re using ts-node for running TypeScript files directly without transpiling, you can set the ts-node compiler options:</p><pre>{<br>  &quot;ts-node&quot;: {<br>    &quot;files&quot;: true<br>  },<br>  &quot;compilerOptions&quot;: {<br>    &quot;sourceMap&quot;: true<br>  }<br>}</pre><h3>4. baseUrl and paths Options:</h3><ul><li>baseUrl: Sets a base directory from which to resolve bare specifier module names. For example, in the directory structure</li></ul><pre>/*<br>project<br>├── ex.ts<br>├── hello<br>│   └── world.ts<br>└── tsconfig.json<br>With &quot;baseUrl&quot;: &quot;./&quot;, TypeScript will look for files starting at the same folder as the tsconfig.json<br><br>tsconfig.json<br>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;baseUrl&quot;: &quot;./&quot;,<br>  }<br>}<br>*/<br>import { helloWorld } from &quot;hello/world&quot;;<br>console.log(helloWorld);</pre><ul><li>As of TypeScript 4.1, baseUrl is no longer required to be set when using <a href="https://www.typescriptlang.org/tsconfig#paths">paths</a>.</li><li>path: A series of entries which re-map imports to lookup locations relative to the <a href="https://www.typescriptlang.org/tsconfig#baseUrl">baseUrl</a> if set, or to the tsconfig file itself otherwise</li></ul><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;baseUrl&quot;: &quot;./&quot;,<br>    &quot;paths&quot;: {<br>      &quot;*&quot;: [&quot;hello/*&quot;],<br>      &quot;app/*&quot;: [&quot;./src/app/*&quot;],<br>    }<br>  }<br>}</pre><h3>5. The Experimental Options</h3><ul><li>experimentalDecorators key is used to enable experimental support for ES7 decorators.</li><li>emitDecoratorMetadata key is used to enable experimental support for emitting type metadata for decorators.</li><li>noImplicitAny: This option specifies whether the TypeScript compiler should generate code that is type-safe. You should set this option to true to enable type checking, or you should set it to false to disable type checking. In some cases where no type annotations are present, TypeScript will fall back to a type of any for a variable when it cannot infer the type. default is true</li></ul><pre>{<br>  &quot;compilerOptions&quot;: {<br>    /* Experimental Options */<br>    &quot;experimentalDecorators&quot;: true,<br>    &quot;emitDecoratorMetadata&quot;: true, <br>    &quot;noImplicitAny&quot;: true<br>  },<br>}</pre><p>If it is enabled, it will give the error.</p><pre>function fn(s) {<br>Parameter &#39;s&#39; implicitly has an &#39;any&#39; type.<br>  console.log(s.subtr(3));<br>}</pre><h3>6. files section</h3><p>Specifies an allowlist of files to include in the program. An error occurs if any of the files can’t be found.</p><pre>{<br>  &quot;compilerOptions&quot;: {},<br>  &quot;files&quot;: [<br>    &quot;validFile.ts&quot;,<br>    &quot;types.ts&quot;,<br>    &quot;utilities.ts&quot;,<br>    &quot;tsc.ts&quot;<br>  ]<br>}</pre><h3>7. strictNullChecks</h3><p>strictNullChecks enables a stricter checking of null and undefined values. If it is set to true, the TypeScript compiler will start to flag errors when null and undefined values are assigned to types that should not accept them.</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;noImplicitAny&quot;: true,<br>    &quot;strictNullChecks&quot;: true<br>  }<br>}</pre><p>For example, the following code will cause an error:</p><pre>let x: number = undefined;<br><br>// Error: Type &#39;undefined&#39; is not assignable to type &#39;number&#39;.</pre><h3>8. types option</h3><p>The types option in the compilerOptions section of the tsconfig.json file is beneficial in TypeScript projects, including those in React Native. It allows you to explicitly specify which TypeScript declaration files (.d.ts files) should be included in the compilation process.</p><h4>Here’s why the types option is beneficial</h4><p><strong>1. Control over Included Declarations</strong></p><ul><li>TypeScript relies on declaration files to provide type information for libraries and external modules. By default, TypeScript includes declaration files for the JavaScript standard library (lib option) and for dependencies listed in the node_modules folder.</li><li>The types option allows you to explicitly specify which declaration files should be included, giving you more control over the type information available in your project.</li></ul><p><strong>2. Reduced Compilation Time</strong></p><ul><li>Including unnecessary declaration files can increase compilation time. By specifying only the needed declaration files using the types option, you can reduce the amount of type-checking and compilation work the TypeScript compiler needs to perform.</li><li>This is particularly useful in large projects where optimizing compilation times is important for development efficiency.</li><li>the types option can also help to reduce the size of your compiled JavaScript code. This is because the TypeScript compiler can use the types of external libraries and modules to generate more efficient JavaScript code.</li></ul><p><strong>3. Preventing Global Type Conflicts</strong></p><ul><li>In some cases, different declaration files might define conflicting types for global variables or modules. By specifying the types option, you can control which type definitions take precedence.</li><li>This is especially important when working with third-party libraries that may have their own type definitions.</li></ul><p><strong>4. Custom Type Definitions</strong></p><ul><li>If your project includes custom type definitions or typings that are not automatically picked up by TypeScript, you can use the types option to explicitly include them.</li><li>This is common when working with third-party libraries that don’t provide official TypeScript support but have community-contributed type definitions.</li></ul><h4>Example:</h4><p>types By default all <em>visible</em> ”@types” packages are included in your compilation. Packages in node_modules/@types of any enclosing folder are considered <em>visible</em>. For example, that means packages within ./node_modules/@types/, ../node_modules/@types/, ../../node_modules/@types/, and so on.</p><p>If types is specified, only packages listed will be included in the global scope. For instance:</p><pre>{<br>  &quot;compilerOptions&quot;: {<br>    &quot;types&quot;: [&quot;node&quot;, &quot;react-native&quot;, &quot;jest&quot; ]<br>  }<br>}</pre><p>This tsconfig.json file will <em>only</em> include ./node_modules/@types/node, ./node_modules/@types/jest and ./node_modules/@types/react-native. Other packages under node_modules/@types/* will not be included.</p><h4>Notes</h4><p>Keep in mind that if you specify the types option, TypeScript will exclude the default libraries (like lib.d.ts). Therefore, you might need to include them explicitly if necessary. The types option is a powerful tool for managing type information in your TypeScript projects and can contribute to a more efficient and predictable development process.</p><h3>Conclusion</h3><p>For more information visit <a href="https://www.typescriptlang.org/tsconfig">official-tsconfig.json</a></p><p>Happy Coding!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bf03aa816941" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Babel Configuration in React Native]]></title>
            <link>https://thevinaysingh.medium.com/babel-configuration-in-react-native-ed7437fd616c?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/ed7437fd616c</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[babel-configuration]]></category>
            <category><![CDATA[babel-plugin]]></category>
            <category><![CDATA[babel]]></category>
            <category><![CDATA[react]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Mon, 20 Nov 2023 11:17:38 GMT</pubDate>
            <atom:updated>2023-12-07T09:44:43.079Z</atom:updated>
            <content:encoded><![CDATA[<h3>React Native/React: Babel Configuration</h3><h3>Agenda</h3><ul><li>What is Babel?</li><li>How to enable Babel in React or React Native?</li><li>What are the Plugins in Babel?</li><li>List of useful Babel plugins in React?</li><li>List of useful Babel plugins in React Native?</li><li>api.cache(true)</li></ul><h3>What is Babel?</h3><ul><li>Babel is a free and <strong>open-source</strong> JavaScript <strong>transcompiler</strong> that is mainly used to <strong>convert ECMAScript 2015+ (ES6+)</strong> code into a backward-compatible version of JavaScript that can be run by older JavaScript engines, environments, such as React Native</li><li>In React Native, Babel is used to <strong>transform JSX</strong> code into <strong>regular JavaScript</strong> code, as well as to transform other modern JavaScript features, such as arrow functions and destructuring assignments.</li><li>Babel also offers <strong>support</strong> for the <strong>latest versions</strong> of JavaScript by sharing <strong>polyfills</strong> and <strong>plugins</strong>.</li></ul><p><strong>ES6 JavaScript:</strong></p><pre>const test = () =&gt; {<br>    let x = &quot;Hello&quot;;<br>    console.log(`${x} World`);<br>}<br><br>test();</pre><p><strong>To do that, you would use Babel to transcompile the ES6 to ES5:</strong></p><pre>&quot;use strict&quot;;<br><br>var test = function test() {<br>    var x = &quot;Hello&quot;;<br>    console.log(x + &quot; World&quot;);<br>};<br><br>test();</pre><p>This <strong>ES5 version</strong> of JavaScript is compatible with <strong>older browsers</strong> or <strong>JavaScript engines</strong>.</p><h3><strong>How to enable Babel in React or React Native?</strong></h3><p>To use Babel for <strong>transpiling</strong> your code, you should install it using npm (Node package manager) and set up an .babelrc or babel.config.js configuration file where you specify the presets you need, like “<strong>env</strong>” for transpiling all <strong>ES2015-ES2020</strong> code to <strong>ES5</strong>.</p><blockquote>Although babel is by default enabled in React and React Native projects while creating the project. If you already have the project, there will be a .babelrc or babel.config.json file at the root of your project.</blockquote><h4>React</h4><p><strong>Step 1</strong>: To enable Babel in a React project, you generally need to install the following npm packages:</p><ol><li><strong>@babel/core</strong>: This is the main Babel library that does all the transformations.</li><li><strong>@babel/preset-react</strong>: The “<strong>@babel/preset-react</strong>” preset is used to <strong>transpile JSX</strong> <strong>syntax</strong> and any <strong>other react-specific syntax</strong>.</li><li><strong>@babel/preset-env</strong>: The “<strong>@babel/preset-env</strong>” preset is used to <strong>transpile</strong> <strong>modern</strong> <strong>JavaScript</strong> features <strong>down to ES5</strong> for compatibility with older browsers.</li><li><strong>@babel/cli</strong>: This is the command-line tool for Babel that you would use to manually transpile your code if you’re not using a build tool or bundler.</li></ol><p>So in total four packages are generally needed as dev dependencies.</p><pre>npm install --save-dev @babel/core @babel/preset-react @babel/preset-env @babel/cli</pre><p><strong>Step 2</strong>: Then, you would configure Babel in your project by creating a .babelrc or babel.config.js file in your project root directory like so:</p><p>For .babelrc<strong>:</strong></p><pre>{<br>  &quot;presets&quot;: [&quot;@babel/preset-env&quot;, &quot;@babel/preset-react&quot;]<br>}</pre><p>For babel.config.json:</p><pre>module.exports = function () {<br>  return {<br>    // These presets are used together to allow you to write modern,<br>    // React code that will be compatible with many browsers.<br>    presets: [&quot;@babel/preset-env&quot;, &quot;@babel/preset-react&quot;],<br>  };<br>};</pre><h4>React Native</h4><p><strong>Step 1</strong>: To enable Babel in a React Native project, you generally need to install the following npm packages:</p><ol><li><strong>@babel/core</strong>: The main dependency that includes Babel’s core functionality.</li><li><strong>@babel/cli</strong>: allows Babel commands to be run from the command line.</li><li><strong>@babel/runtime</strong>: It is used for production and contains Babel’s helper functions and the regenerator runtime. It can help to reduce code duplication across compiled output.</li><li><strong>metro-react-native-babel-preset</strong>: This is a Babel preset from Metro bundler (which React Native uses) that <strong>includes</strong> all the <strong>necessary</strong> <strong>plugins</strong> and <strong>presets</strong> for a React Native project. It includes <strong>plugins</strong> for the <strong>latest JavaScript</strong>, <strong>React</strong>, <strong>Flow,</strong> and <strong>React Native specific transformations</strong>. So in total four packages are generally needed as dev dependencies.</li></ol><pre>npm install --save @babel/core @babel/runtime<br>npm install --save-dev @babel/cli metro-react-native-babel-preset</pre><p><strong>Step 2</strong>: Then, you would configure Babel in your project by creating a .babelrc or babel.config.js file in your project root directory like so:</p><p>For .babelrc<strong>:</strong></p><pre>{<br>  &quot;presets&quot;: [&quot;module:metro-react-native-babel-preset&quot;]<br>}</pre><p>For babel.config.json:</p><pre>module.exports = function () {<br>  return {<br>    presets: [&quot;module:metro-react-native-babel-preset&quot;],<br>  };<br>};<br><br>// Or<br>module.exports = {<br>  presets: [&#39;module:metro-react-native-babel-preset&#39;, &#39;@babel/preset-env&#39;],<br>};</pre><p>While metro-react-native-babel-preset covers the React Native-specific environment, you might also want to use @babel/preset-env to handle any ECMAScript features that are not supported by the JavaScript engines on the target devices.</p><h3>What are the Plugins in Babel?</h3><p>Babel’s code transformations are enabled by applying plugins (or <a href="https://babeljs.io/docs/presets">presets</a>) to your <a href="https://babeljs.io/docs/config-files">configuration file</a>.</p><p>In Babel, plugins are small bits of code that can be used to modify the AST (Abstract Syntax Tree) of your JavaScript code. They allow you to add new features, transform existing features, and generally customize the behavior of Babel during the transpilation process.</p><p><strong>Types of plugins</strong>:</p><ul><li><strong>Syntax plugins</strong>: These plugins allow you to use new syntax features that are not yet supported by all browsers. For example, the @babel/plugin-syntax-jsx plugin allows you to use JSX syntax in your code.</li><li><strong>Transform plugins</strong>: These plugins are used to modify the AST of your code. For example, the @babel/plugin-transform-react-jsx plugin transforms JSX code into regular JavaScript code that can be understood by browsers.</li><li><strong>Code generation plugins</strong>: These plugins generate new code based on the existing code in your AST. For example, the @babel/plugin-proposal-decorators plugin generates code for decorators, which is a proposed JavaScript feature.</li></ul><p><strong>Benefits of using plugins</strong>:</p><ul><li><strong>Extend the functionality of Babel</strong>: Plugins allow you to add new features to Babel that are not available by default.</li><li><strong>Customize the behavior of Babel</strong>: You can use plugins to tailor the behavior of Babel to your specific needs.</li><li><strong>Improve the performance of your code</strong>: Some plugins can help to improve the performance of your code by optimizing the AST.</li></ul><p><strong>How to use plugins</strong>:</p><ul><li><strong>Install the plugin</strong>: You can install plugins using NPM or Yarn. For example, to install the @babel/plugin-syntax-jsx plugin, you would run the following command:</li></ul><pre>npm install @babel/plugin-syntax-jsx</pre><ul><li><strong>Configure your Babel config file</strong>: You need to add the plugin to your babel.config.js file. The specific format will vary depending on the type of plugin.</li></ul><pre>module.exports = {<br>  ...<br>  ...<br>  plugins: [&#39;@babel/plugin-syntax-jsx&#39;],<br>};</pre><p><strong>Here are some additional resources that you may find helpful</strong>:</p><ul><li>Babel plugin documentation: <a href="https://babeljs.io/docs/plugins">https://babeljs.io/docs/plugins</a></li><li>List of Babel plugins: <a href="https://babeljs.io/docs/plugins-list">https://babeljs.io/docs/plugins-list</a></li><li>Babel blog post on plugins: <a href="https://babeljs.io/">https://babeljs.io/</a></li></ul><h3>List of useful Babel plugins in React?</h3><p>Here are some useful Babel plugins often used in React development:</p><ol><li><strong>@babel/plugin-transform-react-jsx</strong>: This is the plugin that handles converting JSX into React.createElement calls that can be executed by the browser.</li><li><strong>@babel/plugin-transform-react-inline-elements</strong>: This plugin transforms React JSX elements to inline their object literals improving runtime speed.</li><li><strong>@babel/plugin-proposal-class-properties</strong>: This plugin allows developers to use the class properties syntax, which means you can use the simplified syntax to declare class methods and you can pass arrow functions and bound methods inside your React components.</li><li><strong>@babel/plugin-syntax-dynamic-import</strong>: This plugin enables support for the dynamic import() function syntax, which allows you to asynchronously load and run modules.</li><li><strong>@babel/plugin-proposal-optional-chaining</strong>: This plugin allows the use of optional chaining syntax in JavaScript which provides an easier way to access nested properties without checking if the property exists or not.</li><li><strong>@babel/plugin-transform-runtime</strong>: The transform-runtime plugin makes sure that helper functions are inserted once in your code and that they reuse the code.</li><li><strong>@babel/plugin-proposal-nullish-coalescing-operator</strong>: This plugin allows the use of the nullish coalescing operator (“??”) in JavaScript, which provides a way to set default values for undefined or null values.</li></ol><h3>List of useful Babel plugins in React Native?</h3><p>Some useful Babel plugins often used in React Native development:</p><ol><li><strong>@babel/plugin-transform-react-jsx</strong>: This plugin transpiles JSX to JavaScript.</li><li><strong>@babel/plugin-proposal-class-properties</strong>: Allows the use of an updated syntax for class properties, including properties used in React components.</li><li><strong>@babel/plugin-transform-runtime</strong>: Reduces duplication in Babel-compiled output.</li><li><strong>@babel/plugin-proposal-optional-chaining</strong>: This enables the optional chaining “?” feature in your React Native project.</li><li><strong>@babel/plugin-syntax-dynamic-import</strong>: Babel plugin to enable dynamic imports in your JavaScript code, which is particularly useful for code splitting.</li><li><strong>@babel/plugin-proposal-nullish-coalescing-operator</strong>: Transpiles the nullish coalescing operator “??”.</li><li><a href="https://babeljs.io/docs/babel-plugin-proposal-decorators"><strong>@babel/plugin-proposal-decorators</strong></a>: This Babel plugin is mainly used for supporting decorator syntax.</li></ol><h3>api.cache(true)</h3><p>The api.cache(true) in babel.config.js in React Native enables caching of the Babel configuration function. This means that Babel will only evaluate the configuration function once, and then reuse the cached result for subsequent compilations. This can improve the performance of the build process.</p><p>Here is an example of how to use api.cache(true) in babel.config.js:</p><pre>module.exports = function (api) {<br>  api.cache(true);<br>  return {<br>    presets: [&#39;babel-preset-expo&#39;],<br>    plugins: [&#39;react-native-reanimated/plugin&#39;],<br>  };<br>};</pre><p>In this example, the api.cache(true) function is called at the top of the module. This tells Babel to cache the result of the configuration function. The configuration function itself returns an object that defines the presets and plugins that Babel should use.</p><p><strong>Other config function API</strong>: <a href="https://babeljs.io/docs/config-files#config-function-api">https://babeljs.io/docs/config-files#config-function-api</a></p><h3>Conclusion</h3><p>Happy Learning!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ed7437fd616c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[All types of Deep Linking configuration and testing in iOS (Native)]]></title>
            <link>https://thevinaysingh.medium.com/all-types-of-deep-linking-configuration-and-testing-in-ios-native-68ccec93080c?source=rss-b1cedfe63062------2</link>
            <guid isPermaLink="false">https://medium.com/p/68ccec93080c</guid>
            <category><![CDATA[deep-linking]]></category>
            <category><![CDATA[branchio]]></category>
            <category><![CDATA[deferred-deep-link]]></category>
            <category><![CDATA[universal-links]]></category>
            <category><![CDATA[ios]]></category>
            <dc:creator><![CDATA[Vinay Singh]]></dc:creator>
            <pubDate>Fri, 10 Nov 2023 17:44:49 GMT</pubDate>
            <atom:updated>2023-11-10T17:44:49.358Z</atom:updated>
            <content:encoded><![CDATA[<h3>All types of Deep Linking configuration and Testing in iOS (Native)</h3><h3>Agenda</h3><ul><li><strong>1. Basic Deep Linking Configuration (Custom URL Schemes)</strong></li><li><strong>2. Basic Deep Linking Configuration (Universal Links)</strong></li><li><strong>3. Deferred Deep Linking Configuration</strong><br>- Deferred Deep linking using branch.io setup<br>- Deferred Deep linking using AppsFlyer setup<br>- Deferred Deep linking using Adjust setup</li><li><strong>Testing Deep links</strong><br>- Testing as a User<br>- Testing as Developer</li></ul><h3>1. Basic Deep Linking Configuration (Custom URL Schemes)</h3><blockquote>With the custom URL schemes, we can launch the application from anywhere. Custom URL schemes are also being used to check if the application is installed or not.</blockquote><p><strong>It works successfully when the app is installed</strong>.</p><p>Apple supports common schemes associated with system apps, such as mailto, tel, sms, and facetime. Native iOS apps and web apps running in Safari on any platform can use these schemes to integrate with system apps.</p><pre>frank@wwdcdemo.example.com<br>tel:1-408-555-5555<br>facetime://user@example.com<br>sms:1-408-555-1212</pre><h4><strong>Step 1: Create a Custom URL Scheme</strong></h4><p>To create a custom URL scheme for your app, follow these steps:</p><ul><li>Open Xcode project. Select the app’s target and navigate to the Info tab.</li><li>Expand the URL Types section, and click + to add a new URL Type.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rkID9KOiKfoDcEWXAecxpA.png" /><figcaption>Project &gt; Target &gt; Info &gt; URL Types Section &gt; Click “<strong>+&quot;</strong></figcaption></figure><ul><li>Set a URL identifier (it can be any unique identifier). It is helpful when adding multiple URL Types. It doesn’t impact the functionality of the custom URL scheme.</li><li>In the “URL Schemes” field, enter the custom URL scheme you want, e.g., myapp. Once configured, your app can be opened using a URL like myapp://path/to/deeplink</li><li>Note: A new dictionary will be added to the app’s Info.plist</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/708/1*M2Vg2kD9nlq5lSnH6iL5-w.png" /></figure><h4>Step 2: Register the Custom URL Scheme (LSApplicationQueriesSchemes)</h4><p>iOS 9 introduced LSApplicationQueriesSchemes which is a type of Launch Services Key in iOS that allows other apps to query if the app is installed before opening the deep linking custom URL schemes. LSApplicationQueriesSchemes is a key in the Info.plist file.</p><p>LSApplicationQueriesSchemes is also used to whitelist other apps that your app can query. This is a security measure to prevent apps from querying other apps without permission.</p><pre>// Check if the app that the deep link is directed to is installed and supports deep linking.<br>if (UIApplication.shared.canOpenURL(deepLinkURL)) {<br>    // Open the app and pass the deep link parameters to it.<br>    UIApplication.shared.open(deepLinkURL, options: nil, completionHandler: nil)<br>}</pre><p>Make sure to register the custom URL scheme in your app’s Info.plist</p><ul><li>Open your Info.plist file inside the app name directory.</li><li>Add a new key, LSApplicationQueriesSchemes (an array) if not added.</li><li>Add an item to the array for a custom URL scheme, e.g. myapp</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/594/1*2tUvBz3aY83Bb1mojLrQxw.png" /></figure><h4>Step 3 Handle Deep Links in Your App</h4><p>To handle deep links using your custom URL scheme, you should implement the application(_:open:options:) method in your AppDelegate. Here&#39;s an example of how to handle a deep link with a custom URL scheme:</p><pre>// Approach 1<br>func application(<br>  _ application: UIApplication,<br>  open url: URL,<br>  options: [UIApplicationOpenURLOptionsKey: Any] = [:]<br>) -&gt; Bool {<br>// Determine who sent the URL.<br>  let sendingAppID = options[.sourceApplication]<br>  print(&quot;source application = \(sendingAppID ?? &quot;Unknown&quot;)&quot;)<br>  // Process the URL.<br>  guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true),<br>    let albumPath = components.path,<br>    let params = components.queryItems<br>  else {<br>    print(&quot;Invalid URL or album path missing&quot;)<br>    return false<br>  }<br>  // ...<br>}</pre><pre>// Approach 2<br>func application(<br>  _ application: UIApplication,<br>  open url: URL,<br>  options: [UIApplicationOpenURLOptionsKey: Any] = [:]<br>) -&gt; Bool {<br>    if let scheme = url.scheme,<br>        scheme.localizedCaseInsensitiveCompare(&quot;myapp&quot;) == .orderedSame,<br>        let view = url.host {<br>        <br>        var parameters: [String: String] = [:]<br>        URLComponents(url: url, resolvingAgainstBaseURL: false)?.queryItems?.forEach {<br>            parameters[$0.name] = $0.value<br>        }<br>        <br>        redirect(to: view, with: parameters)<br>    }<br>    return true<br>}</pre><pre>// Approach 3<br>func application(_ application: UIApplication,<br>                 open url: URL,<br>                 options: [UIApplicationOpenURLOptionsKey : Any] = [:] ) -&gt; Bool {<br>    // Determine who sent the URL.<br>    let sendingAppID = options[.sourceApplication]<br>    print(&quot;source application = \(sendingAppID ?? &quot;Unknown&quot;)&quot;)<br><br>    // Process the URL.<br>    guard let components = NSURLComponents(url: url, resolvingAgainstBaseURL: true),<br>        let albumPath = components.path,<br>        let params = components.queryItems else {<br>            print(&quot;Invalid URL or album path missing&quot;)<br>            return false<br>    }<br><br>    if let photoIndex = params.first(where: { $0.name == &quot;index&quot; })?.value {<br>        print(&quot;albumPath = \(albumPath)&quot;)<br>        print(&quot;photoIndex = \(photoIndex)&quot;)<br>        return true<br>    } else {<br>        print(&quot;Photo index missing&quot;)<br>        return false<br>    }<br>}</pre><h4>Step 4: Test Your Deep Links</h4><p>Refer to the below <strong>Testing</strong> section</p><h4>Important Notes</h4><ul><li>In this type of deep linking, the App will always ask for permission(pop-up)</li><li>Won’t work if the app is not installed.</li></ul><h3>2. Basic Deep Linking Configuration (Universal Links)</h3><blockquote>Universal links are a type of link that opens your app if it is installed or opens the website associated with your app in Safari if it is not installed on the user’s device.</blockquote><ul><li>It is similar to Android App links.</li><li>These are standard HTTP or HTTPS links that can open your app if it is installed, or fall back to your website if it is not.</li><li>Universal links are more secure and support link attribution and measurement.</li><li>Major update from iOS 9 and later versions is the method to support iOS 8 and the lower versions is deprecated.</li><li>Apple provides <a href="https://developer.apple.com/support/app-store/">estimates of how many users have upgraded to iOS 9</a>.</li></ul><h4>Step 1: Create an Associated Domain</h4><p>Universal Links requires to set up an associated domain for the app. To do this, go to the Apple Developer portal:</p><ul><li>Log in to your Apple Developer account.</li><li>Select “Certificates, Identifiers &amp; Profiles.”</li><li>Under “Identifiers,” choose your app’s identifier.</li><li>Enable the “Associated Domains” capability.</li><li>Add your associated domain in the format applinks:yourdomain.com.</li></ul><h4>Step 2: Add the associated domain(s) entitlement to the app</h4><p>In Xcode, open the project and Select app target.</p><ul><li>Under the Signing &amp; Capabilities tab, ensure that the “Associated Domains” section is there. If not then click + Capability, search, and add Associated Domain.</li><li>Add domain(s) in the format applinks:yourdomain.com. Here, you need to give your domain/subdomain in this formatapplinks:&lt;fully qualified domain&gt; but don’t include path and query components or a trailing slash (/).</li><li>Include a list of the domains that your app wants to handle as universal links. Limit this list to no more than about 20 to 30 domains. <a href="https://developer.apple.com/library/archive/documentation/General/Conceptual/AppSearch/UniversalLinks.html#//apple_ref/doc/uid/TP40016308-CH12-SW2">Apple doc</a></li><li>It is optional. But may add web credentials in the format webcredentials:yourdomain.com. iOS apps can use web credentials to authenticate users with websites that are associated with the app.</li></ul><p>Examples:-<br>- Domain:applinks:www.mywebsite.com <br>- Subdomain: applinks:*.mywebsite.com<br>- Subdomain: applinks:*.users.mywebsite.com</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M7o2ihEWdq581-pA.png" /></figure><h4>Step 3: Create an Apple App Site Association (AASA) File</h4><p>An AASA file is a JSON file that contains information about the URLs and paths the app should respond to.</p><ul><li>This is a JSON file named apple-app-site-association (without an extension).</li><li>It may be hosted on https://your-domain/.well-known/apple-app-site-association or https://your-domain/apple-app-site-association from where iOS will make a request expecting a JSON and validate the stuff.</li><li>This file is only fetched once when the user first installs or upgrades the app.</li><li>Apple’s servers will regularly check this file for updates.</li><li>For more info, Visit Apple’s official page <a href="https://developer.apple.com/documentation/xcode/supporting-associated-domains">Supporting associated domains</a></li></ul><p><strong>A Full example of an AASA file:</strong></p><pre>{<br>  /* This service allows app to handle universal links. */<br>  &quot;applinks&quot;: {<br>    &quot;apps&quot;: [&quot;YOUR_APP_ID&quot;]<br>  },<br>  <br>  /**<br>  This service allows app to share web credentials with websites<br>  that are associated with app. This is known as Associated Domains.<br>  */<br>  &quot;webcredentials&quot;: {<br>    &quot;domains&quot;: [&quot;example.com&quot;]<br>  },<br>  /**<br>  This service allows app to be associated with domains.<br>  This means that app can handle universal links for those domains,<br>  and it can also share web credentials with those domains.<br>  */<br>  &quot;associated_domains&quot;: [&quot;example.com&quot;]<br>  <br>  /**<br>  This service allows app to provide App Clips.<br>  App Clips are small, self-contained experiences that are designed <br>  to be launched quickly and easily.<br>  Users can launch App Clips from links, QR codes, and NFC tags.<br>  */<br>  &quot;appclips&quot;: {<br>    &quot;apps&quot;: [&quot;YOUR_APP_ID&quot;]<br>  },<br>  <br>  /**<br>  This service allows app to use Apple Pay.<br>  Apple Pay is a mobile payment and digital wallet service that<br>  allows users to make payments using their iPhones, iPads, and Macs.<br>  */<br>  &quot;applepay&quot;: {<br>    /**<br>    This service allows app to use Apple Pay capabilities.<br>    Apple Pay capabilities include the ability to support shipping, delivery,<br>    and the ability to support recurring payments.<br>    */<br>    &quot;capabilities&quot;: [&quot;shippingAndDelivery&quot;, &quot;recurringPayments&quot;]<br>  },<br>  /**<br>  This service allows app to use the Apple ID service.<br>  The Apple ID service allows users to sign in to apps and websites<br>  using their Apple ID and password.<br>  */<br>  &quot;identity&quot;: {<br>    /**<br>    This service allows app to use Apple ID capabilities.<br>    Apple ID capabilities include the ability to sign in with Apple,<br>    and the ability to request user contact information.<br>    */<br>    &quot;capabilities&quot;: [&quot;signInWithApple&quot;, &quot;requestUserContactInformation&quot;]<br>  },<br>  <br>  /**<br>  This service allows app to receive push notifications.<br>  Push notifications are messages that are sent to users&#39; devices even when<br>  the apps are not running.<br>  */<br>  &quot;push&quot;: {<br>    /**<br>    Push notification capabilities include the ability to send push<br>    notifications to users even when the app is not running in the foreground.<br>    */<br>    &quot;capabilities&quot;: [&quot;foreground&quot;]<br>  },<br>  <br>  /**<br>  This service allows app to access files on the user&#39;s device.<br>  This includes files that are stored in iCloud Drive, as well as files<br>  that are stored in the app&#39;s sandbox.<br>  */<br>  &quot;files&quot;: {<br>    /**<br>    File capabilities include the ability to read and write files in iCloud<br>    Drive, and the ability to read and write files in the app&#39;s sandbox.<br>    */<br>    &quot;capabilities&quot;: [&quot;readAndWriteICloudDrive&quot;, &quot;readAndWriteSandbox&quot;]<br>  },<br>  /**<br>  This service allows app to use near-field communication (NFC).<br>  NFC is a wireless communication technology that allows devices<br>  to exchange data when they are brought close together.<br>  */<br>  &quot;nfc&quot;: {<br>    /**<br>    NFC capabilities include the ability to read and write NFC tags, and <br>    the ability to launch App Clips from NFC tags.<br>    */<br>    &quot;capabilities&quot;: [&quot;readAndWriteNFCTags&quot;, &quot;launchAppClips&quot;]<br>  }<br>}</pre><p><strong>Example of AASA file to configure only universal links:</strong></p><pre>{<br>  /* Encapsulates all of the configuration for Universal Links */<br>  &quot;applinks&quot;: {<br>    /**<br>    This array typically lists other apps that might be related to the app or <br>    that can handle Universal Links on the same domain<br>    */<br>    &quot;apps&quot;: [],<br>    <br>    /**<br>    A list of apps and the universal links they handle for a domain.<br>    This array provides details about how the app with the specified appID <br>    should handle Universal Links for specific paths.<br>    */<br>    &quot;details&quot;: [<br>      <br>      /**<br>      The app with TeamID.BundleID is set to handle Universal Links for <br>      paths starting with /articles/ and /products/<br>      */<br>      {<br>        <br>        /**<br>        It&#39;s unique to app and helps iOS ensure that Universal Links<br>        are securely associated with this app.<br>        Visti &quot;https://developer.apple.com/account&quot; to retrieve TeamID <br>        from the Membership section.<br>        */<br>        &quot;appIDs&quot;: [&quot;TeamID.BundleID&quot;], // [ &quot;ABCDE12345.com.example.app&quot;]<br>        /**<br>        This array lists the paths or routes for which the app specified by <br>        appID should be opened. When a user clicks a Universal Link <br>        that matches one of these paths, the app will be launched.<br>        */<br>        &quot;paths&quot;: [<br>           &quot;*&quot;, // Use * to specify your entire website<br>           &quot;/articles/*&quot;, // Or entire paths with articles/ supported <br>           &quot;/products/*&quot;, // Or entire paths with articles/ supported<br>           &quot;/support/contact&quot;, // Specific path<br>           &quot;NOT /videos/wwdc/2010/*&quot;, // Use NOT to disable path<br>         ]<br>        // &quot;components&quot;: [&quot;/path1/*&quot;, &quot;/path2/deep-link&quot;]<br>        /**<br>        May use components as well to have more granular control on paths/urls<br>        More info visit https://developer.apple.com/documentation/bundleresources/applinks/details/components<br>        */<br>        &quot;components&quot;: [<br>           {<br>              &quot;#&quot;: &quot;no_universal_links&quot;, // # is used for fragment<br>              &quot;exclude&quot;: true, // exclude is used to exclude the path/fragment<br>              &quot;comment&quot;: &quot;Matches any URL with a fragment that equals no_universal_links and instructs the system not to open it as a universal link.&quot;<br>           },<br>           {<br>              &quot;/&quot;: &quot;/buy/*&quot;, // key &quot;/&quot; is used to specify path<br>              &quot;comment&quot;: &quot;Matches any URL with a path that starts with /buy/.&quot;<br>           },<br>           {<br>              &quot;/&quot;: &quot;/help/website/*&quot;,<br>              &quot;exclude&quot;: true,<br>              &quot;comment&quot;: &quot;Matches any URL with a path that starts with /help/website/ and instructs the system not to open it as a universal link.&quot;<br>           },<br>           {<br>              &quot;/&quot;: &quot;/help/*&quot;,<br>              &quot;?&quot;: { &quot;articleNumber&quot;: &quot;????&quot; }, // Specify query params <br>              &quot;comment&quot;: &quot;Matches any URL with a path that starts with /help/ and that has a query item with name &#39;articleNumber&#39; and a value of exactly four characters.&quot;<br>           }<br>         ]<br>      },<br>      <br>      /**<br>      while the app with TeamID.OtherBundleID is set to handle<br>      paths starting with /events/.<br>      */<br>      {<br>          &quot;appID&quot;: &quot;TeamID.OtherBundleID&quot;,<br>          &quot;paths&quot;: [&quot;/events/*&quot;]<br>      }<br>    ]<br>  },<br>  /**<br>  Use this service for shared web credentials. This is used to<br>  share credentials between iOS apps and their website counterparts.<br>  This allows users to save their username and password in their<br>  iCloud keychain when logging into websites.<br>  When they run a native app to access the same account at some point,<br>  the app has access to the credentials stored for the website so there<br>  is no need to reenter them.<br>  Note:<br>  1. Accessing shared web credentials requires permission<br>  from the app, the website, and the user.<br>  2. You need to specify webcredentials in XCode if added in AASA file.<br>  <br>  visit https://developer.apple.com/documentation/security/shared_web_credentials<br>  */<br>  &quot;webcredentials&quot;: {<br>      &quot;apps&quot;: [ &quot;ABCDE12345.com.example.app&quot; ], // Required<br>      &quot;action&quot;: &quot;webcredentials&quot;, // Required<br>      <br>      /** Optional.<br>      specifies a specific domain to which the web credentials apply.<br>      If not provided, the web credentials apply to the entire associated domain<br>      */<br>      &quot;domains&quot;: [&quot;example.com&quot;],<br>      &quot;webcredentialsUse&quot;: &quot;passthrough&quot;, // Optional, The default value is embedding<br>   },<br>}</pre><h4>Differences between paths and components?</h4><ul><li>The main difference between paths and components is that paths are simpler to specify, but components allow for more granular control. For example, you can use components to match URLs based on their query parameters or fragments.</li><li>Another difference is that paths are greedy, while components are not. This means that when the system is matching a URL to a path, it will try to match the longest path pattern possible. However, when the system is matching a URL to a components object, it will only try to match the conditions in the object.</li></ul><h4>Which should you use components?</h4><p>If you only need to match URLs based on their paths, then you should use the paths section. However, if you need to match URLs based on their query parameters or fragments, or if you need more granular control over the matching process, then you should use the components section.</p><h4>What is webcredentialsUse?</h4><p>The webcredentialsUse key in an Apple App Site Association (AASA) file specifies how your app can use web credentials for a given domain. The possible values are:</p><ul><li>embedding: Your app can embed web credentials in its own code or in a third-party library.</li><li>passthrough: Your app can pass web credentials to a web view or to a third-party library.</li><li>none: Your app cannot use web credentials for the domain.</li></ul><h4>Step 4: Handle Deep Links in Your App</h4><p>Update your app delegate to respond to the user activity object the system provides when a universal link routes to the app</p><pre>// Approach 1<br>func application(<br>  _ app: UIApplication,<br>  open url: URL,<br>  options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -&gt; Bool {<br>    // Check if the URL is for your app<br>    if url.scheme == &quot;myapp&quot; {<br>        // Extract data from the URL, e.g., to determine which screen to show<br>        // Navigate to the relevant screen<br>        return true<br>    }<br>    return false<br>}</pre><pre>// Approach 2<br>func application(<br>  _ app: UIApplication,<br>  continue userActivity: NSUserActivity,<br>  restorationHandler: @escaping ([UIUserActivityRestoring]?) -&gt; Void) -&gt; Bool {<br>    if userActivity.activityType == NSUserActivityTypeBrowsingWeb {<br>        let webpageURL = userActivity.webpageURL<br>        // Handle the URL and navigate to the appropriate content in your app<br>    }<br>    return true<br>}</pre><pre>// Approach 3<br>func application(_ application: UIApplication,<br>                 continue userActivity: NSUserActivity,<br>                 restorationHandler: @escaping ([UIUserActivityRestoring]?) -&gt; Void) -&gt; Bool<br>{<br>    // Get URL components from the incoming user activity.<br>    guard userActivity.activityType == NSUserActivityTypeBrowsingWeb,<br>        let incomingURL = userActivity.webpageURL,<br>        let components = NSURLComponents(url: incomingURL, resolvingAgainstBaseURL: true) else {<br>        return false<br>    }<br>    <br>    // Check for specific URL components that you need.<br>    guard let path = components.path,<br>    let params = components.queryItems else {<br>        return false<br>    }    <br>    print(&quot;path = \(path)&quot;)<br><br>    if let albumName = params.first(where: { $0.name == &quot;albumname&quot; } )?.value,<br>        let photoIndex = params.first(where: { $0.name == &quot;index&quot; })?.value {<br><br>        print(&quot;album = \(albumName)&quot;)<br>        print(&quot;photoIndex = \(photoIndex)&quot;)<br>        return true<br><br>    } else {<br>        print(&quot;Either album name or photo index missing&quot;)<br>        return false<br>    }<br>}</pre><p>For more details, visit <a href="https://developer.apple.com/documentation/xcode/supporting-universal-links-in-your-app"><strong><em>Apple doc (Supporting universal links)</em></strong></a></p><h4>Step 5: Testing Universal Links</h4><p>Testing is similar to Basic Deep Linking Configuration (Custom URL Schemes). For more details, refer to the <strong>Testing</strong> section below.</p><h4>Notes</h4><ul><li>Won’t ask for permission</li><li>Won’t open the browser if the app is installed.</li><li>Fallback URL if the app is not installed.</li><li>Static backend with SSL needed.</li></ul><h4>Sources</h4><ul><li><a href="https://www.branch.io/resources/blog/how-to-setup-universal-links-to-deep-link-on-apple-ios/">How to Set Up Universal Links to Deep Link on Apple iOS</a></li></ul><h4>3. Deferred Deep Linking Configuration</h4><blockquote>Deferred deep linking, which ensures that users are directed to specific content or features within your app even if it’s not installed when they click on a link, typically requires additional support beyond Android App Links alone.</blockquote><p>This process is “deferred” because it works by redirecting users to the appropriate content after the app is installed and opened for the first time.</p><h4>Some 3rd party platforms used to configure Deferred deep linking</h4><ul><li><strong>Branch.io: </strong>Read below or follow <a href="https://help.branch.io/developers-hub/docs/ios-basic-integration">the official doc to setup</a></li><li><strong>AppsFlyer: </strong>Read below or<strong> </strong>Follow <a href="https://dev.appsflyer.com/hc/docs/install-ios-sdk">the official doc to setup</a></li><li><strong>Adjust: </strong>Read below or Follow <a href="https://help.adjust.com/en/article/get-started-ios-sdk">the official doc to setup</a></li></ul><h4>Option 1: Deferred Deep linking using Branch</h4><blockquote>Branch is a leading mobile linking platform that simplifies deep linking and attribution for mobile apps. It offers a comprehensive suite of features for deferred deep linking, including automatic app install, user attribution, custom deep link routing, A/B testing, and deep link analytics.</blockquote><p><strong>Step 1: Configure Branch Dashboard<br></strong>You will need the following things<br>- Custom URL Scheme<br>- Team ID from <a href="https://developer.apple.com/account">Apple Developer Account</a><br>- Bundle identifier<br>- Associated domains that you will use in XCode.<br>In the end, you will get the branch_key for live and test that you need in XCode.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*ez5gkj0ETOzHfnnH.png" /><figcaption>Source <a href="https://help.branch.io/developers-hub/docs/ios-basic-integration">branch.io</a></figcaption></figure><p><strong>Step 2: Configure Associated Domains and Info.Plist</strong></p><ul><li>Update Info.Plist adding keys branch_key and branch_universal_link_domains with values you got from the Branch Dashboard.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9onuMxJk6XRBRSTeaVj9gQ.png" /><figcaption>Source <a href="https://help.branch.io/developers-hub/docs/ios-basic-integration">branch.io</a></figcaption></figure><ul><li>Add the same associated domains in XCode that you have used in the Branch dashboard. e.g.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/760/0*QBs-fH91ccUDwivW.png" /><figcaption>Source <a href="https://help.branch.io/developers-hub/docs/ios-basic-integration">branch.io</a></figcaption></figure><p><strong>Step 3: Integrate Branch SDK </strong>Add pod dependency in Podfile and Run pod install &amp;&amp; pod update to install the project dependencies. Confirm in your target’s <strong>General</strong> tab that a Pods_... dependency is now listed.</p><pre># If using Swift, include the following line:<br>use_frameworks!<br>  ...<br><br> # For Branch iOS SDK 2.0.0+<br> pod &#39;BranchSDK&#39;<br><br> ...<br>end</pre><p><strong>Step 4: Initialize Branch SDK</strong></p><pre>import SwiftUI<br>import BranchSDK<br><br>class AppDelegate: UIResponder, UIApplicationDelegate {<br>    ...<br>    func application(<br>      _ application: UIApplication,<br>      didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -&gt; Bool {<br>        // Initialize Branch with your API key<br>        Branch.setUseTestBranchKey(true) // Set to false in production<br>        Branch.getInstance().initSession(launchOptions: launchOptions) { (params, error) in<br>            // Handle deep link parameters here (if any)<br>            if let deepLinkParams = params {<br>                print(&quot;Deep Link Params: \(deepLinkParams)&quot;)<br>            }<br>        }<br><br>        // Other app launch setup...<br>        <br>        return true<br>    }<br>    ...  <br>}</pre><pre>import SwiftUI<br>import BranchSDK<br><br>@main<br>struct MyApplication: App {<br>    ...<br>    @UIApplicationDelegateAdaptor(AppDelegate.self) private var appDelegate<br>    <br>    var body: some Scene {<br>        WindowGroup {<br>            ContentView()<br>                .onOpenURL(perform: { url in<br>                    Branch.getInstance().handleDeepLink(url)<br>                })<br>        }<br>    }<br>  ...<br>}</pre><p><strong>Step 5: Handle Deep Link URLs<br></strong>Create a ViewController to Handle Deep Links</p><pre>import UIKit<br>import BranchSDK<br><br>class ViewController: UIViewController {<br><br>    @IBOutlet weak var deepLinkLabel: UILabel!<br><br>    override func viewDidLoad() {<br>        super.viewDidLoad()<br>        // Do any additional setup after loading the view.<br><br>        // Check if there&#39;s a deep link<br>        if let deepLink = Branch.getInstance().getLatestReferringParams() {<br>            updateDeepLinkLabel(deepLink)<br>        }<br>    }<br><br>    func updateDeepLinkLabel(_ params: [AnyHashable: Any]) {<br>        // Display deep link information<br>        deepLinkLabel.text = &quot;Deep Link Params:\n\(params)&quot;<br>    }<br>}</pre><p><strong>Step 6: Generate and Share URLs<br></strong>You may use Branch Dashboard or generate programmatically like below</p><pre>import BranchSDK<br><br>// Create a BranchUniversalObject object with the canonical identifier of the content you want to link to.<br>let branchUniversalObject = BranchUniversalObject(canonicalIdentifier: &quot;my-content-identifier&quot;)<br><br>// Create a BranchLinkProperties object and set the properties of the deep link.<br>let branchLinkProperties = BranchLinkProperties()<br>branchLinkProperties.feature = &quot;my-feature&quot;<br>branchLinkProperties.campaign = &quot;my-campaign&quot;<br><br>// Use the getShortUrl() method on the BranchUniversalObject object to generate the short deep link URL.<br>let shortDeepLinkURL = branchUniversalObject.getShortUrl(with: branchLinkProperties)<br><br>// Print the short deep link URL to the console.<br>print(shortDeepLinkURL)</pre><p><strong>Step 7: Test deep link URLs </strong>Refer below Testing section</p><h4>Option 2: Deferred Deep linking using <strong>AppsFlyer</strong></h4><blockquote>AppsFlyer is another popular mobile marketing analytics platform that provides deferred deep linking capabilities. It offers a range of features for tracking and measuring marketing campaigns, including attribution, in-app events, and cost-per-install analysis.</blockquote><p><strong>Step 1: Create a AppsFlyer account<br></strong>Create AppsFlyer account at <a href="https://www.appsflyer.com/">AppsFlyer’s website</a> and get &lt;YOUR_APP_ID&gt; and &lt;YOUR_DEV_KEY&gt;</p><p><strong>Step 2: Integrate AppsFlyer SDK </strong>Add pod dependency. Then, run pod install in your project directory.</p><pre>pod &#39;AppsFlyerFramework&#39;</pre><p><strong>Step 3: Initialize AppsFlyer SDK</strong></p><pre>import AppsFlyerLib<br><br>@UIApplicationMain<br>class AppDelegate: UIResponder, UIApplicationDelegate, AppsFlyerLibDelegate {<br>    <br>    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {<br>        // Initialize AppsFlyer<br>        AppsFlyerLib.shared().appsFlyerDevKey = &quot;YOUR_DEV_KEY&quot;<br>        AppsFlyerLib.shared().appleAppID = &quot;YOUR_APP_ID&quot; // Without id prefix<br>        AppsFlyerLib.shared().isDebug = true // Set this to false in production.<br>        AppsFlyerLib.shared().delegate = self<br>        AppsFlyerLib.shared().anonymizeUser = false // Set this to true for GDPR compliance if needed.<br><br>        // Handle deep link here if the app was launched via a deep link.<br>        if let deepLink = launchOptions?[.url] as? URL {<br>            handleDeepLink(deepLink)<br>        }<br><br>        return true<br>    }<br><br>    // Implement the AppsFlyerLibDelegate method to handle deep link attribution<br>    func onAppOpenAttribution(_ attributionData: [AnyHashable : Any]!) {<br>        if let deepLink = attributionData[&quot;deep_link_value&quot;] as? String {<br>            handleDeepLink(deepLink)<br>        }<br>    }<br><br>    // Custom function to handle the deep link<br>    func handleDeepLink(_ deepLink: String) {<br>        // Parse the deep link and navigate to the relevant content or feature in your app.<br>        // For example, you can use URL components to extract parameters and perform navigation.<br>        if let urlComponents = URLComponents(string: deepLink) {<br>            // Extract parameters and perform navigation based on your deep link structure.<br>        }<br>    }<br>    <br>    // Other AppDelegate methods...<br>}</pre><p><strong>Step 4: Create a Universal Link<br></strong>To enable deferred deep linking, you need to create a Universal Link for your app through your Apple Developer account. Universal Links allow iOS to route users to the correct content or feature within your app after installation.</p><ol><li>In your Apple Developer account, go to your app’s capabilities settings.</li><li>Enable “Associated Domains” and add your domain that supports Universal Links.</li><li>Configure your website to handle Universal Links by adding the necessary JSON file and associating it with your app.</li></ol><p>For a detailed guide on how to set up Universal Links, refer to Apple’s official documentation: <a href="https://developer.apple.com/documentation/xcode/allowing_apps_and_websites_to_link_to_your_content/enabling_universal_links">Set Up Universal Links</a>.</p><p><strong>Step 6: Generate and Share URLs </strong>No specific code is needed.</p><pre>// Define your deep link parameters<br>let deepLinkParameters: [String: String] = [<br>    &quot;product_id&quot;: &quot;12345&quot;,<br>    &quot;utm_source&quot;: &quot;facebook&quot;,<br>    &quot;utm_campaign&quot;: &quot;summer_sale&quot;<br>]<br><br>// Your app&#39;s custom URL scheme (replace with your app&#39;s scheme)<br>let customScheme = &quot;myapp&quot;<br><br>// Construct the deep link URL<br>var deepLinkURLComponents = URLComponents()<br>deepLinkURLComponents.scheme = customScheme<br>deepLinkURLComponents.host = &quot;product&quot;<br>deepLinkURLComponents.queryItems = deepLinkParameters.map { key, value in<br>    URLQueryItem(name: key, value: value)<br>}<br><br>if let deepLinkURL = deepLinkURLComponents.url {<br>    print(&quot;Deep link URL: \(deepLinkURL.absoluteString)&quot;)<br>}</pre><p><strong>Step 7: Test deep link URLs </strong>Refer below Testing section</p><h4>Option 3: Deferred Deep linking using <strong>Adjust</strong></h4><blockquote>Adjust is another mobile attribution platform that provides deep linking functionality. It allows you to create deep links and track user interactions with your app. Adjust offers detailed analytics and reporting to help you measure the performance of your marketing efforts.</blockquote><p><strong>Step 1: Create an Adjust account</strong></p><p>If you don’t already have an Adjust account, sign up for one on the Adjust website and get YOUR_ADJUST_APP_TOKEN</p><p><strong>Step 2: Integrate Adjust SDK</strong></p><pre>// Get pod from repository<br>pod &#39;Adjust&#39;, &#39;~&gt; 4.33.3&#39;<br><br>// Get source directly from GitHub<br>pod &#39;Adjust&#39;, :git =&gt; &#39;https://github.com/adjust/ios_sdk.git&#39;, :tag =&gt; &#39;4.33.3&#39;</pre><p><strong>Step 3: Initialize Adjust SDK</strong></p><pre>import Adjust<br><br>class AppDelegate: UIResponder, UIApplicationDelegate, AdjustDelegate {<br><br>    func application(_ application: UIApplication, didFinishLaunchingWithOptions<br> <br>launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {<br>        // Initialize the Adjust SDK<br>        Adjust.appDidLaunch(ADJConfig(appToken: &quot;YOUR_ADJUST_APP_TOKEN&quot;))<br><br>        return true<br>    }<br>}</pre><p><strong>Step 4: Enable Universal Link<br></strong>To enable deep linking in your app, you’ll need to configure your app to handle deep links. This typically involves implementing URL schemes or Universal Links. This is essential for deep linking to work in your app.</p><p><strong>Step 5: Handle Deep Link URLs</strong></p><pre>import Adjust<br><br>class AppDelegate: UIResponder, UIApplicationDelegate, AdjustDelegate {<br><br>    func application(<br>      _ application: UIApplication,<br>      didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {<br>        // Initialize the Adjust SDK<br>        let yourAppToken = &quot;{YourAppToken}&quot;<br>        let environment = ADJEnvironmentSandbox as? String<br>        let adjustConfig = ADJConfig(<br>            appToken: yourAppToken,<br>            environment: environment)<br><br>        // To set the verbosity of logging<br>        adjustConfig?.logLevel = ADJLogLevelVerbose<br><br>        Adjust.appDidLaunch(adjustConfig)<br><br>        // Add a deferred deep link listener<br>        Adjust.addDelegate(self)<br><br>        return true<br>    }<br><br>    func adjustDeeplinkResponse(_ url: URL) -&gt; Bool {<br>        // Handle the deep link<br>        handleDeepLink(url)<br>    <br>        // Return true to indicate that we want the Adjust SDK to open the deep link<br>        return true<br>    }<br>  <br>    func handleDeepLink(_ url: URL) {<br>        // Get the product ID from the deep link<br>        let productId = url.pathComponents.last<br>    <br>        // Open the product page for the given product ID<br>        let productPage = ProductViewController()<br>        productPage.productId = productId<br>        navigationController?.pushViewController(productPage, animated: true)<br>    }<br>  }</pre><p><strong>Step 6: Generate and Share URLs Generate <br></strong>No specific code is needed. Generate URLs from Adjust Dashboard. <strong><br></strong>Adjust Deep link URL: adjust://example.com/products/123 <br>Adjust Campaign URL: <a href="https://app.adjust.com/c/YOUR_ADJUST_APP_TOKEN/YOUR_ADJUST_CAMPAIGN_ID">https://app.adjust.com/c/YOUR_ADJUST_APP_TOKEN/YOUR_ADJUST_CAMPAIGN_ID</a></p><p><strong>Step 7: Test deep link URLs </strong>Refer to the below Testing section</p><h3>Testing</h3><h4>Testing as a User:</h4><p><strong>Click on Links:</strong></p><ul><li>Open a web browser, email, or any app that supports deep linking.</li><li>Click on a deep link shared via a website, email, or any other platform.</li></ul><p><strong>Check App Installation</strong>:</p><ul><li>If the app is already installed, it should open and navigate to the relevant content.</li><li>If the app is not installed, it might take you to the App Store for installation. After installation, it should open and take you to the specific content.</li></ul><h4>Testing as a Developer:</h4><p><strong>Manually Enter Deep Links:</strong></p><ul><li>Open a web browser on your iOS device.</li><li>Manually enter the deep link URL and press Enter.</li></ul><p><strong>Xcode Simulator:</strong></p><ul><li>Run your app in the Xcode Simulator.</li><li>Open Safari within the simulator and manually enter the deep link URL.</li></ul><p><strong>Test with Universal Links:</strong></p><ul><li>If your app uses Universal Links, you can test deep links directly from Safari.</li><li>Open Safari on the device and enter the deep link URL. It should open your app.</li></ul><p><strong>Use URL Schemes:</strong></p><ul><li>If your app uses custom URL schemes, you can test deep linking by entering the URL scheme in Safari or any other app that supports URL schemes.</li></ul><p><strong>ADB Command (for Universal Links):</strong></p><ul><li>If your app uses Universal Links, you can use the xcrun simctl openurl command to simulate a Universal Link in the simulator:</li></ul><pre># Simulator<br>xcrun simctl openurl &lt;simulator_udid&gt; &lt;url_scheme&gt;:&lt;deep_link_parameters&gt;<br><br># Deep link url: myapp://product/1234<br># Get the UDID of the Simulator device that you want to test on.<br>simulator_udid=$(xcrun simctl list devices | grep -Po &#39;(?&lt;=UDID: )\w+&#39;)<br># Test the deep link.<br>xcrun simctl openurl &quot;$simulator_udid&quot; myapp://product/1234</pre><pre># Real Device<br>xcrun simctl openurl &lt;device_ip_address&gt; &lt;url_scheme&gt;:&lt;deep_link_parameters&gt;<br><br># You can find IP address of the device in the device&#39;s Settings app.<br>xcrun simctl openurl 192.168.1.100 myapp://product/1234</pre><p><strong>From other apps (Programmatically)</strong></p><pre>// Approach 1<br>// Get the URL scheme and deep link parameters.<br>let urlScheme = &quot;myapp://&quot;<br><br>// Check if the app is installed and supports deep linking.<br>if UIApplication.shared.canOpenURL(URL(string: urlScheme)!) {<br>  // The app is installed and supports deep linking.<br>  let deepLinkParameters = &quot;product/1234&quot;<br>  // Create a deep link URL.<br>  let deepLinkURL = URL(string: &quot;\(urlScheme):\(deepLinkParameters)&quot;)!<br>  <br>  // Open the app and pass it the deep link.<br>  UIApplication.shared.open(deepLinkURL, options: nil, completionHandler: nil)<br>} else {<br>    // The app is not installed or does not support deep linking.<br>}</pre><pre>// Approach 2<br>// Using open(_:options:completionHandler:) in UIKit<br>if let appURL = URL(string: &quot;https://myphotoapp.example.com/albums?albumname=vacation&amp;index=1&quot;) {<br>    UIApplication.shared.open(appURL) { success in<br>        if success {<br>            print(&quot;The URL was delivered successfully.&quot;)<br>        } else {<br>            print(&quot;The URL failed to open.&quot;)<br>        }<br>    }<br>} else {<br>    print(&quot;Invalid URL specified.&quot;)<br>}</pre><pre>// Approach 3<br>// Using openURL action in SwiftUI<br>struct OpenURLExample: View {<br>  @Environment(\.openURL) private var openURL<br>  var body: some View {<br>      Button {<br>        if let url = URL(string: &quot;https://www.example.com&quot;) {<br>          openURL(url)<br>        }<br>      } label: {<br>        Label(&quot;Get Help&quot;, systemImage: &quot;person.fill.questionmark&quot;)<br>      }<br>    }<br>  }</pre><p><strong>Test with App Links:</strong></p><ul><li>If your app uses Facebook App Links, you can test by entering the App Link URL in Safari or by using the “Share” functionality in other apps.</li></ul><p><strong>Use a Deep Link Testing Tool:</strong></p><ul><li>There are online tools that simulate deep link behavior. For example, <a href="https://www.branch.io/deepviewsimulator">Branch.io Deepview Tester</a> allows you to test how a deep link would behave without leaving your browser.</li></ul><p>Remember to test on different iOS devices and versions to ensure compatibility. Additionally, test both scenarios — when the app is installed and when it’s not — to ensure a smooth user experience.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68ccec93080c" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>