<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Virali Vasa</title>
    <description>The latest articles on DEV Community by Virali Vasa (@virali_vasa).</description>
    <link>https://dev.to/virali_vasa</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2298533%2F1ecdbc5f-401b-4465-aa32-61168dba8b56.png</url>
      <title>DEV Community: Virali Vasa</title>
      <link>https://dev.to/virali_vasa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/virali_vasa"/>
    <language>en</language>
    <item>
      <title>React Native 0.76 version is here</title>
      <dc:creator>Virali Vasa</dc:creator>
      <pubDate>Wed, 06 Nov 2024 10:53:20 +0000</pubDate>
      <link>https://dev.to/virali_vasa/react-native-076-version-is-here-3chh</link>
      <guid>https://dev.to/virali_vasa/react-native-076-version-is-here-3chh</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fde5u9dvmkzjfd17s5l88.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fde5u9dvmkzjfd17s5l88.png" alt="React Native" width="800" height="712"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source: Wikipedia&lt;/p&gt;

&lt;p&gt;Starting with &lt;strong&gt;React Native 0.76&lt;/strong&gt;, the new architecture (Fabric and TurboModules) is enabled by default, bringing significant improvements in performance, flexibility, and ease of development. &lt;/p&gt;

&lt;p&gt;Here’s a quick update of &lt;strong&gt;what’s new&lt;/strong&gt; in React Native 0.76:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;New Architecture Enabled by Default-&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Fabric Renderer&lt;/strong&gt;: The Fabric rendering engine is now the default, enabling faster and more efficient UI updates, better compatibility with concurrent rendering, and smoother animations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;TurboModules&lt;/strong&gt;: By using TurboModules, the communication between JavaScript and native code is more efficient, reducing the overhead associated with the traditional bridge.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;strong&gt;New Features and Improvements&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Hermes by Default: The Hermes JavaScript engine, which optimizes performance and memory usage, is the default JavaScript runtime. Hermes offers faster startup times and lower memory usage, especially on Android devices.&lt;/p&gt;

&lt;p&gt;React Native 0.76 introduces &lt;strong&gt;two new style props&lt;/strong&gt;— &lt;strong&gt;boxShadow&lt;/strong&gt; and &lt;strong&gt;filter&lt;/strong&gt; —specific to the new architecture, providing familiar styling options similar to the web.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;boxShadow&lt;/strong&gt;&lt;br&gt;
Adds shadows to elements, controlling position, color, size, and blurriness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;: Takes a CSS-like string (e.g., '5 5 5 0 rgba(255, 0, 0, 0.5)') or a JS object with parameters (e.g., {offsetX: 5, offsetY: 5, blurRadius: 5, spreadDistance: 0, color: 'rgba(255, 0, 0, 0.5')}).&lt;br&gt;
Improvements: Fixes previous shadow limitations on Android, supports inset shadows, and now works on views without background color.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limitations&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The default shadow color is black, not the parent’s color&lt;/li&gt;
&lt;li&gt;Android normal shadows are supported on Android 9+&lt;/li&gt;
&lt;li&gt;Android inset shadows are supported on Android 10+&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;filter&lt;/strong&gt;&lt;br&gt;
Adds filters for brightness, saturation, hue, and blurs to elements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Syntax&lt;/strong&gt;: Accepts a CSS-like string (e.g., 'saturate(0.5) grayscale(0.25)') or an array of JS objects (e.g., [{saturate: 0.5}, {grayscale: 0.25}]).&lt;br&gt;
dropShadow differs from boxShadow by only casting shadows on pixels with nonzero alpha and lacks a spread distance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Limitations&lt;/strong&gt;:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;iOS supports only brightness and opacity, and no outside-the-bounds effects.&lt;/li&gt;
&lt;li&gt;Android blur and drop-shadow supported on Android 12+.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Improved Metro Bundler: Metro has been enhanced with faster startup and reload times, which helps speed up the development experience, especially in large projects.&lt;/p&gt;

&lt;p&gt;Enhanced DevTools: The development tools are richer, with better React DevTools integration and improved error logging, making it easier to debug and understand performance issues.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;New APIs and Module Improvements&lt;/strong&gt;&lt;br&gt;
Animated Layout Animations: &lt;strong&gt;Fabric&lt;/strong&gt; enables enhanced support for layout animations, allowing more fluid and intuitive UI changes. With Fabric, you can now animate component mount and unmount with ease, improving user experience.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Streamlined Native Module Setup&lt;/strong&gt;&lt;br&gt;
Native modules in 0.76 are easier to set up and integrate, especially with the new architecture in place. The updates reduce boilerplate and make it easier for modules to work seamlessly with both Fabric and TurboModules.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;React 18+ Integration&lt;/strong&gt;&lt;br&gt;
React Native 0.76 integrates React 18 features more deeply, especially around concurrent rendering, which improves responsiveness and smoothness. For instance, Fabric’s support for React 18's concurrent features helps manage rendering priorities better.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Android Gradle Plugin 8 and JDK 17 Support&lt;/strong&gt;&lt;br&gt;
The default Android Gradle plugin has been upgraded to support AGP 8 and JDK 17, ensuring better compatibility with recent versions of Android Studio and offering improved build performance.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;7.** Enhanced Accessibility Features**&lt;br&gt;
Improved support for accessibility features like voice-over, TalkBack, and screen readers, enhancing the overall accessibility of React Native applications.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Default TypeScript Setup&lt;/strong&gt;
New projects created with React Native 0.76 come with TypeScript configuration by default, reflecting the community’s growing preference for TypeScript.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Since the new architecture is enabled by default, you don’t need additional configuration to use Fabric and TurboModules in 0.76. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;However, make sure you&lt;/em&gt;:&lt;/p&gt;

&lt;p&gt;Update any third-party libraries to their latest versions, as they may need to be compatible with the new architecture.&lt;br&gt;
Test your app thoroughly to ensure that Fabric and TurboModules don't cause unexpected issues, especially in parts of your app that heavily use native modules.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Migration Considerations&lt;/strong&gt;&lt;br&gt;
If you’re upgrading an older app, run react-native upgrade to manage the process. Check for any deprecated APIs or incompatible libraries, and consider migrating older custom native modules to the TurboModules format for better performance.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Example&lt;/strong&gt; Project Creation in 0.76&lt;br&gt;
To start a new React Native 0.76 project, run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx react-native@latest init your-app-name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With React Native 0.76, you’re set up with all these enhancements out-of-the-box, allowing you to build faster, more responsive, and modern applications right from the start.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy reading !!!!&lt;/em&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>moment.js Alternative - Luxon</title>
      <dc:creator>Virali Vasa</dc:creator>
      <pubDate>Thu, 31 Oct 2024 12:16:38 +0000</pubDate>
      <link>https://dev.to/virali_vasa/momentjs-alternative-luxon-32m</link>
      <guid>https://dev.to/virali_vasa/momentjs-alternative-luxon-32m</guid>
      <description>&lt;h2&gt;Introduction:&lt;/h2&gt;

&lt;p&gt;The Moment.js team has officially declared:&lt;/p&gt;

&lt;blockquote&gt;
    "We now generally consider Moment to be a legacy project in maintenance mode. It is not dead, but it is indeed done."
&lt;/blockquote&gt;

&lt;p&gt;Although Moment.js remains widely used in many existing projects, the team discourages using it for new development. Instead, they recommend alternative libraries that are better suited to modern applications. Among these, &lt;strong&gt;Luxon&lt;/strong&gt; is one of the top choices.&lt;/p&gt;




&lt;h2&gt;Why Luxon?&lt;/h2&gt;

&lt;p&gt;Luxon is a powerful library for handling dates, times, time zones, and formatting, similar to Moment.js. It is particularly well-supported in newer React Native versions (&amp;gt;=0.70), where it works seamlessly. However, older React Native versions may lack the &lt;code&gt;Intl&lt;/code&gt; support needed for some of Luxon's advanced functionality. If using React Native &amp;gt;=0.60, you’ll need to configure the build flavor of JSC in your &lt;code&gt;android/app/build.gradle&lt;/code&gt; file:&lt;/p&gt;

&lt;pre&gt;&lt;code&gt;-def jscFlavor = 'org.webkit:android-jsc:+'
+def jscFlavor = 'org.webkit:android-jsc-intl:+'
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;For further formatting information, refer to the Luxon &lt;a href="https://moment.github.io/luxon/#/formatting" rel="noopener noreferrer"&gt;documentation&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;Installation:&lt;/h3&gt;

&lt;p&gt;Luxon supports Node.js 6+, and you can install it via NPM or Yarn:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;npm&lt;/span&gt; &lt;span class="nx"&gt;install&lt;/span&gt; &lt;span class="o"&gt;--&lt;/span&gt;&lt;span class="nx"&gt;save&lt;/span&gt; &lt;span class="nx"&gt;luxon&lt;/span&gt;
&lt;span class="err"&gt;#&lt;/span&gt; &lt;span class="nx"&gt;or&lt;/span&gt;
&lt;span class="nx"&gt;yarn&lt;/span&gt; &lt;span class="nx"&gt;add&lt;/span&gt; &lt;span class="nx"&gt;luxon&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;Luxon Basics in React/React Native&lt;/h2&gt;

&lt;p&gt;Here are some commonly used functions in Luxon to get you started:&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;DateTime&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;luxon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Current DateTime&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  
&lt;span class="c1"&gt;// =&amp;gt; DateTime 2024-10-31T16:02:34.785+05:30&lt;/span&gt;

&lt;span class="c1"&gt;// Convert to JavaScript Date object for use in date pickers&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toJSDate&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="c1"&gt;// =&amp;gt; Date Thu Oct 31 2024 16:02:34 GMT+0530 (India Standard Time)&lt;/span&gt;

&lt;span class="c1"&gt;// Custom date formatting&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MM/dd/yyyy&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;toFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;yyyy-MM-dd h:mm a&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Parse an ISO string&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;selectedDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;2024-10-04T16:11:47.000-05:00&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;setZone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;

&lt;span class="c1"&gt;// Get start and end of the current day&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;local&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;startOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;day&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;local&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;endOf&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;day&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c1"&gt;// Add days to current date&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;plus&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;days&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;6&lt;/span&gt; &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="c1"&gt;// =&amp;gt; DateTime 2024-11-06T16:02:34.820+05:30&lt;/span&gt;

&lt;span class="c1"&gt;// Relative difference (e.g., "3 days ago")&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toRelativeCalendar&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;span class="c1"&gt;// Format for specific day of the week&lt;/span&gt;
&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;selectedDate&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;setZone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt; &lt;span class="p"&gt;}).&lt;/span&gt;&lt;span class="nf"&gt;toFormat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cccc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;Custom Formatting Examples&lt;/h2&gt;

&lt;p&gt;For advanced formatting, Luxon provides versatile methods:&lt;/p&gt;

&lt;h3&gt;Calculate time difference in hours and minutes (UTC)&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timeFormatForHoursWorkedInUTC&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;utcDateString&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;utcDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;utcDateString&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;zone&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;utc&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;currentDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;utc&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;timeDifferenceMs&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;currentDate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;diff&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;utcDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="k"&gt;as&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;milliseconds&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hours&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;timeDifferenceMs&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;minutes&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;floor&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;timeDifferenceMs&lt;/span&gt; &lt;span class="o"&gt;%&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="o"&gt;/&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;1000&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;hours&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;padStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;:&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;minutes&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;toString&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;padStart&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;0&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="c1"&gt;//output:  `01:30`&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;br&gt;
Some more examples:&lt;br&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;DateTime&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;luxon&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Example ISO Date String&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;exampleDate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;2024-10-31T16:11:47.000-05:00&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// 1. Short Date (e.g., "10/31/2024")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATE_SHORT&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "10/31/2024"&lt;/span&gt;

&lt;span class="c1"&gt;// 2. Medium Date (e.g., "Oct 31, 2024")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATE_MED&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "Oct 31, 2024"&lt;/span&gt;

&lt;span class="c1"&gt;// 3. Full Date (e.g., "Thursday, October 31, 2024")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATE_FULL&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "Thursday, October 31, 2024"&lt;/span&gt;

&lt;span class="c1"&gt;// 4. Huge Date (e.g., "Thursday, October 31, 2024 AD")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATE_HUGE&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "Thursday, October 31, 2024 AD"&lt;/span&gt;

&lt;span class="c1"&gt;// 5. Simple Time (e.g., "4:11 PM")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TIME_SIMPLE&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "4:11 PM"&lt;/span&gt;

&lt;span class="c1"&gt;// 6. Short Time with Seconds (e.g., "16:11:47")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;TIME_WITH_SECONDS&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "16:11:47"&lt;/span&gt;

&lt;span class="c1"&gt;// 7. Short Date and Time (e.g., "10/31/2024, 4:11 PM")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATETIME_SHORT&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "10/31/2024, 4:11 PM"&lt;/span&gt;

&lt;span class="c1"&gt;// 8. Medium Date and Time (e.g., "Oct 31, 2024, 4:11 PM")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATETIME_MED&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "Oct 31, 2024, 4:11 PM"&lt;/span&gt;

&lt;span class="c1"&gt;// 9. Full Date and Time with Timezone (e.g., "October 31, 2024, 4:11 PM UTC-5")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATETIME_FULL&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "October 31, 2024, 4:11 PM UTC-5"&lt;/span&gt;

&lt;span class="c1"&gt;// 10. Huge Date and Time (e.g., "Thursday, October 31, 2024 AD, 4:11 PM")&lt;/span&gt;
&lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;fromISO&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;exampleDate&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;toLocaleString&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;DateTime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DATETIME_HUGE&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;span class="c1"&gt;// Output: "Thursday, October 31, 2024 AD, 4:11 PM"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;h2&gt;Conclusion:&lt;/h2&gt;

&lt;p&gt;Luxon offers a modern, flexible, and efficient solution for date and time handling, making it an excellent alternative to Moment.js. With its extensive timezone support, intuitive syntax, and compatibility with both Node and the browser, Luxon can cover nearly all your date-time needs in React and React Native projects.&lt;/p&gt;

&lt;p&gt;Happy coding! 😊&lt;/p&gt;



</description>
      <category>moment</category>
      <category>luxon</category>
      <category>validation</category>
    </item>
    <item>
      <title>Troubleshooting Common Issues of React Native Firebase- Cloud Messaging</title>
      <dc:creator>Virali Vasa</dc:creator>
      <pubDate>Thu, 31 Oct 2024 06:12:06 +0000</pubDate>
      <link>https://dev.to/virali_vasa/troubleshooting-common-issues-of-react-native-firebase-cloud-messaging-36i3</link>
      <guid>https://dev.to/virali_vasa/troubleshooting-common-issues-of-react-native-firebase-cloud-messaging-36i3</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9a116kx14094217n3mv5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9a116kx14094217n3mv5.png" alt="React Native Firebase" width="256" height="276"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Source: npm @react-native-firebase/app&lt;/p&gt;

&lt;h2&gt;
  
  
  Are you facing issues while implementing React Native Firebase Cloud Messaging?
&lt;/h2&gt;

&lt;p&gt;Getting notifications up and running smoothly on both Android and iOS can sometimes be challenging, given the unique configurations each platform demands.&lt;br&gt;
This guide will walk you through the important steps to set up Firebase Cloud Messaging (FCM) in React Native and tackle some common errors:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Configuring Firebase:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Download GoogleService-Info.plist (iOS) and google-services.json (Android).&lt;/p&gt;

&lt;p&gt;Select the downloaded &lt;strong&gt;GoogleService-Info.plist&lt;/strong&gt; file from your computer, and ensure the "Copy items if needed" checkbox is enabled&lt;/p&gt;

&lt;p&gt;Download the &lt;strong&gt;google-services.json&lt;/strong&gt; file and place it inside of your project at the following location:&lt;br&gt;
 &lt;code&gt;/android/app/google-services.json&lt;/code&gt;.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Enable Push Notifications for iOS in Xcode:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;Push Notifications&lt;/em&gt; capability needs to be added to the project. This can be done via the "Capability" option under the "Signing &amp;amp; Capabilities" tab:&lt;br&gt;
Click on the "+ Capabilities" button.&lt;br&gt;
Search for "Push Notifications".&lt;/p&gt;

&lt;p&gt;Once selected, the capability will be shown below the other enabled capabilities. If no option appears when searching, the capability may already be enabled&lt;/p&gt;

&lt;p&gt;The Background Modes capability needs to be enabled, along with both the Background fetch and Remote notifications sub-modes. This can be added via the "Capability" option on the "Signing &amp;amp; Capabilities" tab.&lt;/p&gt;

&lt;p&gt;Now, ensure that both the "Background fetch" and the "Remote notifications" sub-modes are enabled&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Setup Guide for React Native FCM&lt;/strong&gt;: &lt;/p&gt;

&lt;p&gt;Follow the &lt;a href="https://rnfirebase.io/messaging/usage" rel="noopener noreferrer"&gt;official Firebase Cloud Messaging setup guide&lt;/a&gt;. This guide includes essential steps to get started with sending and receiving notifications on Android and iOS. Once you’ve completed these steps, you can test notifications directly from the Firebase Console under Messaging by composing a new campaign. &lt;/p&gt;




&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;:&lt;br&gt;
For M1 Mac users, issues with CocoaPods are common when setting up React Native Firebase. Here are some quick solutions:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Use arch -x86_64&lt;/em&gt; -
M1 Macs may encounter compatibility issues with CocoaPods. Run commands with arch -x86_64 to use the x86_64 architecture:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;arch -x86_64 pod install&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Update CocoaPods Repository&lt;/em&gt;-
If you face errors related to outdated pod versions, update your CocoaPods repo:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;arch -x86_64 pod repo update&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Fix ffi Error&lt;/em&gt;-
You might encounter an ffi library error. To fix it, install the ffi gem specifically for your architecture:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;sudo arch -x86_64 gem install ffi&lt;/code&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;Re-Install Pods&lt;/em&gt; -
After these steps, re-run the pod installation command:&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;arch -x86_64 pod install&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Following these steps should help resolve architecture-specific issues on M1 Macs when installing and managing pods for your React Native project.&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Note&lt;/em&gt;:&lt;br&gt;
For Android 13+ devices, you need to request runtime permissions for push notifications explicitly. Add the following permissions to your AndroidManifest.xml:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;&amp;lt;uses-permission android:name="android.permission.POST_NOTIFICATIONS" /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then, in your code, request notification permissions at runtime. You can handle Android permissions directly like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;

&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;Platform&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;PermissionsAndroid&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;react-native&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;requestNotificationPermission&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
&lt;span class="c1"&gt;// Version &amp;gt;= 33(`~project/build.gradle`)&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;Platform&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;OS&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;android&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;granted&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;PermissionsAndroid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;request&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
      &lt;span class="nx"&gt;PermissionsAndroid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;PERMISSIONS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;POST_NOTIFICATIONS&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;granted&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="nx"&gt;PermissionsAndroid&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;RESULTS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;GRANTED&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Notification permission granted&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Notification permission denied&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Call requestNotificationPermission() during app initialization or before subscribing to notifications to ensure the user has granted permission.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Ensuring Compatibility&lt;/strong&gt;:  &lt;/p&gt;

&lt;p&gt;Before diving into the setup, make sure that both &lt;code&gt;@react-native-firebase/app&lt;/code&gt; and &lt;code&gt;@react-native-firebase/messaging&lt;/code&gt; packages are installed in your project and are compatible.&lt;br&gt;
Consistent versions are crucial to avoiding unexpected integration issues. To verify version compatibility, refer to the official &lt;a href="https://rnfirebase.io/releases" rel="noopener noreferrer"&gt;React Native Firebase Release Documentation&lt;/a&gt;. &lt;br&gt;
Make sure you have the latest versions of both packages installed to avoid compatibility issues.&lt;/p&gt;

&lt;p&gt;If you’re testing on an iOS device, note the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Physical iOS devices are generally required to receive push notifications.&lt;/li&gt;
&lt;li&gt;If you're on macOS 13+ with Apple Silicon, you can also use an iOS Simulator running iOS 16+ for testing.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;&lt;strong&gt;Troubleshooting Tips&lt;/strong&gt;:&lt;/p&gt;

&lt;p&gt;After completing the setup, you may still run into issues. Here are some common problems and solutions:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Simulator Not Receiving Notifications&lt;/strong&gt;:&lt;br&gt;&lt;br&gt;
   If notifications aren’t appearing in the iOS simulator, try the following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Restart or reset the simulator by erasing all content and settings.&lt;/li&gt;
&lt;li&gt;Retry after resetting, as sometimes a simulator restart can fix the issue. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;After troubleshooting this myself for a couple of hours, I found that a quick restart was the simplest solution!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Check Steps and Common Issues&lt;/strong&gt;: &lt;br&gt;
   Double-check the setup steps in the &lt;a href="https://rnfirebase.io/messaging/usage" rel="noopener noreferrer"&gt;Firebase guide&lt;/a&gt; to ensure everything is configured correctly. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Error Installing CocoaPods&lt;/strong&gt;: &lt;br&gt;
   If you encounter installation errors, such as:&lt;/p&gt;


&lt;pre&gt;&lt;br&gt;
   error: RPC failed; curl stream was reset&lt;br&gt;
   error: 6428 bytes of body are still expected&lt;br&gt;
   &lt;/pre&gt;

&lt;p&gt;This could be due to network issues. Try switching from Wi-Fi to a mobile hotspot (or vice versa) and retry the installation. Sometimes, changing your network can solve connection-related pod installation issues. If this doesn’t resolve the problem, you may need to try additional troubleshooting tips, such as clearing the CocoaPods cache or updating Xcode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Allowing HTTP URLs in iOS (App Transport Security)&lt;/strong&gt;:&lt;br&gt;
   If you’re using an HTTP URL for API requests (as opposed to HTTPS), you’ll need to update your iOS &lt;code&gt;Info.plist&lt;/code&gt; file to avoid blocked connections due to App Transport Security (ATS) restrictions. Add the following lines in your &lt;code&gt;Info.plist&lt;/code&gt; file:&lt;/p&gt;


&lt;pre&gt;&lt;code&gt;&lt;br&gt;
   &amp;lt;key&amp;gt;NSAppTransportSecurity&amp;lt;/key&amp;gt;&lt;br&gt;
   &amp;lt;dict&amp;gt;&lt;br&gt;
     &amp;lt;key&amp;gt;NSAllowsArbitraryLoads&amp;lt;/key&amp;gt;&lt;br&gt;
     &amp;lt;true/&amp;gt;&lt;br&gt;
     &amp;lt;key&amp;gt;NSExceptionDomains&amp;lt;/key&amp;gt;&lt;br&gt;
     &amp;lt;dict&amp;gt;&lt;br&gt;
       &amp;lt;key&amp;gt;localhost&amp;lt;/key&amp;gt;&lt;br&gt;
       &amp;lt;dict&amp;gt;&lt;br&gt;
         &amp;lt;key&amp;gt;NSExceptionAllowsInsecureHTTPLoads&amp;lt;/key&amp;gt;&lt;br&gt;
         &amp;lt;true/&amp;gt;&lt;br&gt;
       &amp;lt;/dict&amp;gt;&lt;br&gt;
     &amp;lt;/dict&amp;gt;&lt;br&gt;
   &amp;lt;/dict&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;p&gt;This will allow your app to make HTTP requests without interference. Be cautious with this setting in production apps and try to limit it to development environments where possible.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Ensure App Transport Security (ATS) Compatibility&lt;/strong&gt;:&lt;br&gt;
   For iOS, ensure that any HTTPS endpoints you’re using are ATS-compliant. If you’re testing with staging servers or self-signed certificates, make sure they are ATS-compatible, as Firebase requires a secure connection to communicate with APNs (Apple Push Notification Service).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion:&lt;/strong&gt;&lt;br&gt;
Setting up Firebase Cloud Messaging in React Native can be straightforward, but minor setup mistakes or device configuration quirks can lead to issues. Following this guide and troubleshooting tips should help you get notifications running smoothly. For any additional issues, you can check out the official documentation, forums, or GitHub discussions to find solutions shared by other developers.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Happy coding !!!!&lt;/em&gt;&lt;/p&gt;

</description>
      <category>firebase</category>
      <category>reactnative</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
