<?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 Tarun Jain on Medium]]></title>
        <description><![CDATA[Stories by Tarun Jain on Medium]]></description>
        <link>https://medium.com/@tarun.j_30452?source=rss-1ed2e2ea0c03------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*9WplIy_eOBaFZe-lI6FWzw.jpeg</url>
            <title>Stories by Tarun Jain on Medium</title>
            <link>https://medium.com/@tarun.j_30452?source=rss-1ed2e2ea0c03------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 19:54:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tarun.j_30452/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[Fixing 16KB Memory Page Size Issue in React Native]]></title>
            <link>https://medium.com/@tarun.j_30452/fixing-16kb-memory-page-size-issue-in-react-native-af33df7c73c8?source=rss-1ed2e2ea0c03------2</link>
            <guid isPermaLink="false">https://medium.com/p/af33df7c73c8</guid>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[google-play]]></category>
            <category><![CDATA[google]]></category>
            <category><![CDATA[16-kb-page-size]]></category>
            <dc:creator><![CDATA[Tarun Jain]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 08:02:34 GMT</pubDate>
            <atom:updated>2025-10-16T13:33:34.713Z</atom:updated>
            <content:encoded><![CDATA[<p>If your React Native app is showing small .so files (around 4KB) in your release APK or crashing on some devices, it means some libraries are not compiled properly. Here’s how you can fix this issue step-by-step in simple language.</p><h3>🧩 Step 1: Check your React Native version</h3><p>First, make sure your app is updated to <strong>at least React Native 0.79.5</strong> (or the latest version).</p><p>👉 Go to this link: <a href="https://react-native-community.github.io/upgrade-helper/">React Native Upgrade Helper</a></p><ul><li>Select your current version and the target version.</li><li>Follow the changes shown and update your files.</li></ul><p>Then run your app to confirm it’s working:</p><pre>npx react-native run-android</pre><p>If it runs fine, go ahead and make a release build.</p><h3>🧱 Step 2: Create a release APK</h3><p>Run these commands in your project folder:</p><pre>cd android<br>./gradlew clean assembleRelease</pre><p>Now you’ll get your release APK here:</p><pre>android/app/build/outputs/apk/release/app-release.apk</pre><h3>🧮 Step 3: Check if your libraries are 4KB or 16KB</h3><ol><li>Open <strong>Android Studio</strong>.</li><li>Click on <strong>Build → Analyze APK</strong>.</li><li>Select your app-release.apk file.</li><li>Open the lib folder inside the APK.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*r6coJYa2sYcAsxQ0LtnCkA.png" /></figure><p>Now check the sizes of the .so files (native libraries). If you see many files showing <strong>4KB</strong>, then those are the problem.</p><p>Example: You may see something like this —</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1018/1*PUCgJ2VDMXFQCtsbcxF85Q.png" /></figure><pre>libreanimated.so  → 4KB ❌<br>libworklets.so → 4KB ❌</pre><h3>🕵️ Step 4: Find which library is causing the issue</h3><p>Search for that .so file name inside your node_modules folder.</p><p>Example:</p><pre>find node_modules -name &quot;libreanimated.so&quot;</pre><p>If you find it inside react-native-reanimated, it means that library needs an update.</p><h3>🔄 Step 5: Update the library</h3><p>Now update that library to the latest version. Example:</p><pre>npm install react-native-reanimated@latest<br># or<br>yarn add react-native-reanimated@latest</pre><p>Do this for all libraries showing 4KB .so files.</p><p>After updating, clean and rebuild the project:</p><pre>cd android<br>./gradlew clean assembleRelease</pre><p>This helps build all native libraries properly.</p><p>Dealing with the 16 KB memory issue in Google Play Console can be annoying, but it’s not hard to solve.<br>With a few adjustments — like boosting Gradle memory, updating your tools, and optimizing your app’s assets — you can build and release your app smoothly without any interruptions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af33df7c73c8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Fixing Splash Screen swift issue in React Native 8 (Android & iOS)]]></title>
            <link>https://medium.com/@tarun.j_30452/fixing-splash-screen-swift-issue-in-react-native-8-android-ios-ee68d6f04279?source=rss-1ed2e2ea0c03------2</link>
            <guid isPermaLink="false">https://medium.com/p/ee68d6f04279</guid>
            <category><![CDATA[splash]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[swift]]></category>
            <category><![CDATA[mobile-app-development]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Tarun Jain]]></dc:creator>
            <pubDate>Tue, 15 Jul 2025 06:41:32 GMT</pubDate>
            <atom:updated>2025-07-17T10:08:58.033Z</atom:updated>
            <content:encoded><![CDATA[<p>Want to show a <strong>splash screen</strong> when your app starts? Great idea! It gives your app a clean, professional look while it loads. In this guide, I’ll show you step-by-step how to add a splash screen to both <strong>Android</strong> and <strong>iOS</strong> using the popular react-native-splash-screen library.</p><p>Let’s get started!</p><h3>✅ Step 1: Install the Library</h3><p>Run this command in your project:</p><pre>npm install react-native-splash-screen</pre><p>or</p><pre>yarn add react-native-splash-screen</pre><h3>📱 Step 2: Android Setup</h3><h3>2.1 Add Code to MainActivity.java</h3><p>Open this file:<br> android/app/src/main/java/.../MainActivity.kt</p><p>Add this line inside onCreate():</p><pre>import org.devio.rn.splashscreen.SplashScreen;</pre><pre>SplashScreen.show(this, R.style.AppTheme, false); // &lt;- Add this</pre><p>So your file will look like:</p><pre>override fun onCreate(savedInstanceState: Bundle?) {<br>     SplashScreen.show(this, R.style.AppTheme, false);// here<br>     super.onCreate(null)<br> }</pre><h3>2.2 Create the Splash Layout</h3><p>Create a new file:<br> android/app/src/main/res/layout/launch_screen.xml</p><p>Add this:</p><pre>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;<br>&lt;RelativeLayout<br>    xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;<br>    android:orientation=&quot;vertical&quot;<br>    android:layout_width=&quot;match_parent&quot;<br>     android:background=&#39;@color/splash_background_color&#39;<br>    android:layout_height=&quot;match_parent&quot;&gt;<br>    &lt;ImageView<br>         android:layout_width=&quot;match_parent&quot;<br>         android:layout_height=&quot;match_parent&quot;<br>         android:src=&quot;@drawable/launch_screen&quot;<br>        android:scaleType=&quot;centerCrop&quot;<br>     /&gt;<br>    &lt;ImageView<br>        android:layout_width=&quot;wrap_content&quot;<br>        android:layout_height=&quot;wrap_content&quot;<br>        android:src=&quot;@drawable/ic_app_name&quot;<br>        android:layout_marginHorizontal=&quot;50dp&quot;<br>        android:layout_centerInParent=&quot;true&quot;/&gt;<br>&lt;/RelativeLayout&gt;</pre><blockquote><em>🔁 Replace </em><em>ic_app_logo with your app logo. Put your logo in the </em><em>drawable folder.<br></em>That’s it for Android!</blockquote><h3>🍎 Step 3: iOS Setup (For Swift-based projects like RN 0.77+)</h3><p>Starting in RN 0.77, iOS uses Swift instead of Objective-C. So we need to follow these new steps:</p><h3>3.1 Create a Bridging Header</h3><p>In your iOS folder, create a file called:</p><pre>YourProject/ios/YourProject/YourProject-Bridging-Header.h</pre><p>Add this line inside:</p><pre>#import &quot;RNSplashScreen.h&quot;</pre><h3>3.2 Add the File in Xcode</h3><ol><li>Open your project in <strong>Xcode</strong>.</li><li>Right-click your project name → click <strong>Add Files to “YourProject”</strong>.</li><li>Select the file you just created.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EYNev5CgbfKGZzDHOoAy-g.png" /></figure><h3>3.3 Link file in build setting</h3><p>Search for Objective-C Bridging Header in Build Settings, then you will see the linked header file listed there.&quot; now link created header file here</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0cXVUvvzuTm9I9bU89kibA.png" /></figure><h3>3.4 Update AppDelegate.swift</h3><p>Open AppDelegate.swift and update it like this:</p><pre>import UIKit<br>import React<br>import React_RCTAppDelegate<br>import ReactAppDependencyProvider<br>import Firebase</pre><pre>@main<br>class AppDelegate: RCTAppDelegate {<br>  override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = nil) -&gt; Bool {<br>    FirebaseApp.configure()<br>    self.moduleName = &quot;YourAppModuleName&quot; // &lt;- Change this to your app name<br>    self.dependencyProvider = RCTAppDependencyProvider()<br>    <br>    self.initialProps = [:]<br>    let result = super.application(application, didFinishLaunchingWithOptions: launchOptions)<br>    RNSplashScreen.show() // &lt;- Show the splash screen here<br>    return result<br>  }</pre><pre>override func customize(_ rootView: RCTRootView!) {<br>    super.customize(rootView)<br>  }</pre><pre>override func sourceURL(for bridge: RCTBridge) -&gt; URL? {<br>    self.bundleURL()<br>  }</pre><pre>override func bundleURL() -&gt; URL? {<br>    #if DEBUG<br>      return RCTBundleURLProvider.sharedSettings().jsBundleURL(forBundleRoot: &quot;index&quot;)<br>    #else<br>      return Bundle.main.url(/service/forresource: &quot;main&quot;, withExtension: &quot;jsbundle&quot;)<br>    #endif<br>  }<br>}</pre><h3>💡 Step 4: Hide Splash Screen After App Loads</h3><p>In your main App component (App.tsx or App.js), add this:</p><pre>import SplashScreen from &#39;react-native-splash-screen&#39;;<br>import { useEffect } from &#39;react&#39;;</pre><pre>useEffect(() =&gt; {<br>  SplashScreen.hide(); // &lt;- Hide the splash when app is ready<br>}, []);</pre><h3>🎉 Done!</h3><p>You now have a working splash screen on <strong>both Android and iOS</strong> in your React Native app!</p><h3>🧠 Bonus Tips</h3><ul><li>Keep your splash image simple and light (avoid complex animations).</li><li>You can show the splash screen for longer by adding a timeout before hiding it.</li><li>Make sure your logo is centered and looks good on all screen sizes.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ee68d6f04279" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[️ Fixing SafeAreaView Not Working in React Native After Upgrading to targetSdkVersion 35 (Android…]]></title>
            <link>https://medium.com/@tarun.j_30452/%EF%B8%8F-fixing-safeareaview-not-working-in-react-native-after-upgrading-to-targetsdkversion-35-android-feb956c0e08b?source=rss-1ed2e2ea0c03------2</link>
            <guid isPermaLink="false">https://medium.com/p/feb956c0e08b</guid>
            <category><![CDATA[target-sdk-version]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[safeareaview]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[android-14]]></category>
            <dc:creator><![CDATA[Tarun Jain]]></dc:creator>
            <pubDate>Tue, 08 Jul 2025 10:48:06 GMT</pubDate>
            <atom:updated>2025-10-03T05:26:37.951Z</atom:updated>
            <content:encoded><![CDATA[<h3>🛡️ Fixing SafeAreaView Not Working in React Native After Upgrading to targetSdkVersion 35 (Android 14 &amp; 15)</h3><p>Upgraded your targetSdkVersion to <strong>35</strong> in your React Native app and suddenly noticed that SafeAreaView is not working on Android? You&#39;re not alone.</p><p>This issue stems from <strong>Android 14’s edge-to-edge layout enforcement</strong>, which can break layouts that don’t handle system window insets properly.</p><p>In this guide, we’ll show you:</p><ul><li>What’s causing the issue</li><li>How to quickly fix it using styles.xml</li></ul><h3>🚨 The Problem</h3><p>When upgrading from:</p><pre>targetSdkVersion = 34</pre><p>to:</p><pre>targetSdkVersion = 35</pre><p>You may notice that:</p><ul><li>Your app overlaps with the <strong>status bar</strong> or <strong>navigation bar</strong></li><li>SafeAreaView no longer behaves as expected on <strong>Android</strong></li><li>Content appears underneath system UI elements</li></ul><p>This happens because Android 14 enforces <strong>edge-to-edge layouts by default</strong> for all apps targeting SDK 34 and above.</p><h3>✅ The Quick Fix: Opt Out in styles.xml</h3><p>To temporarily fix this without rewriting your layout logic, <strong>opt out of edge-to-edge enforcement</strong> in your theme:</p><h3>🛠 Step-by-step:</h3><ol><li>Open: android/app/src/main/res/values/styles.xml</li><li>Inside your main app theme, add:</li></ol><pre>&lt;item name=&quot;android:windowOptOutEdgeToEdgeEnforcement&quot;&gt;true&lt;/item&gt;</pre><h3>Example:</h3><pre>&lt;resources&gt;<br>  &lt;style name=&quot;AppTheme&quot; parent=&quot;Theme.AppCompat.Light.NoActionBar&quot;&gt;<br>    &lt;item name=&quot;android:windowTranslucentStatus&quot;&gt;true&lt;/item&gt;<br>    &lt;item name=&quot;android:windowDrawsSystemBarBackgrounds&quot;&gt;true&lt;/item&gt;<br>    &lt;item name=&quot;android:fitsSystemWindows&quot;&gt;false&lt;/item&gt;<br>    &lt;item name=&quot;android:windowOptOutEdgeToEdgeEnforcement&quot;&gt;true&lt;/item&gt;<br>  &lt;/style&gt;<br>&lt;/resources&gt;</pre><p>🔁 Rebuild your app — and SafeAreaView should now behave like it did in SDK 34.</p><h3>📌 Conclusion</h3><p>If SafeAreaView stops working after targeting SDK 35:</p><p>✅ <strong>Quick Fix</strong>: Add</p><pre>&lt;item name=&quot;android:windowOptOutEdgeToEdgeEnforcement&quot;&gt;true&lt;/item&gt;</pre><p>to your theme in styles.xml.</p><p>⚙️ <strong>Best Practice</strong>: Use react-native-safe-area-context for accurate insets across Android and iOS — now and in future Android versions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=feb956c0e08b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ React Native FlatList Performance Guide: Smooth Scrolling and Fast Rendering]]></title>
            <link>https://medium.com/@tarun.j_30452/react-native-flatlist-performance-guide-smooth-scrolling-and-fast-rendering-64e48451389f?source=rss-1ed2e2ea0c03------2</link>
            <guid isPermaLink="false">https://medium.com/p/64e48451389f</guid>
            <category><![CDATA[speed-optimization]]></category>
            <category><![CDATA[optimization]]></category>
            <category><![CDATA[flatlist]]></category>
            <category><![CDATA[listings]]></category>
            <category><![CDATA[smooth]]></category>
            <dc:creator><![CDATA[Tarun Jain]]></dc:creator>
            <pubDate>Tue, 08 Jul 2025 10:35:49 GMT</pubDate>
            <atom:updated>2025-07-08T10:35:49.203Z</atom:updated>
            <content:encoded><![CDATA[<h3>✅ What You’ll Learn:</h3><ul><li>How to create a performant blog list screen using FlatList</li><li>Use of useCallback for optimization</li><li>Layout design for blog items</li><li>Performance settings for smooth scrolling</li></ul><h3>🔧 Step 1: Set Up Your React Native Project</h3><p>If you haven’t already, create a new React Native project:</p><pre>npx react-native init BlogListApp<br>cd BlogListApp<br>npx react-native run-android # or run-ios</pre><h3>🧩 Step 2: Sample Blog Data</h3><p>Create a mock data array to simulate your blog list.</p><pre>js// blogData.js<br>export const blogs = [<br>  {<br>    id: &#39;1&#39;,<br>    title: &#39;React Native Performance Tips&#39;,<br>    description: &#39;How to optimize your React Native apps...&#39;,<br>    thumbnail: &#39;https://via.placeholder.com/150&#39;,<br>  },<br>  {<br>    id: &#39;2&#39;,<br>    title: &#39;Using FlatList Effectively&#39;,<br>    description: &#39;Master FlatList for long lists and smooth UI...&#39;,<br>    thumbnail: &#39;https://via.placeholder.com/150&#39;,<br>  },<br>  // Add more mock items...<br>];</pre><h3>💡 Step 3: Create BlogList Component</h3><p>Here’s the full component that uses FlatList + useCallback.</p><pre>tsx// BlogList.js<br>import React, { useCallback } from &#39;react&#39;;<br>import {<br>  FlatList,<br>  Text,<br>  View,<br>  Image,<br>  StyleSheet,<br>  TouchableOpacity,<br>} from &#39;react-native&#39;;<br>import { blogs } from &#39;./blogData&#39;;<br><br>const BlogList = () =&gt; {<br><br>  const renderItem = useCallback(({ item }) =&gt; {<br>    return (<br>      &lt;TouchableOpacity style={styles.card}&gt;<br>        &lt;Image source={{ uri: item.thumbnail }} style={styles.image} /&gt;<br>        &lt;View style={styles.textContainer}&gt;<br>          &lt;Text style={styles.title}&gt;{item.title}&lt;/Text&gt;<br>          &lt;Text style={styles.description}&gt;{item.description}&lt;/Text&gt;<br>        &lt;/View&gt;<br>      &lt;/TouchableOpacity&gt;<br>    );<br>  }, []);<br><br>  const keyExtractor = useCallback((item) =&gt; item.id, []);<br><br>  return (<br>    &lt;FlatList<br>      data={blogs}<br>      renderItem={renderItem}<br>      keyExtractor={keyExtractor}<br>      initialNumToRender={5}<br>      maxToRenderPerBatch={10}<br>      windowSize={5}<br>      removeClippedSubviews={true}<br>      contentContainerStyle={styles.listContainer}<br>    /&gt;<br>  );<br>};<br><br>const styles = StyleSheet.create({<br>  listContainer: {<br>    padding: 16,<br>  },<br>  card: {<br>    flexDirection: &#39;row&#39;,<br>    backgroundColor: &#39;#fff&#39;,<br>    marginBottom: 12,<br>    borderRadius: 10,<br>    overflow: &#39;hidden&#39;,<br>    elevation: 3, // for Android shadow<br>    shadowColor: &#39;#000&#39;, // for iOS shadow<br>    shadowOffset: { width: 0, height: 2 },<br>    shadowOpacity: 0.1,<br>    shadowRadius: 4,<br>  },<br>  image: {<br>    width: 100,<br>    height: 100,<br>  },<br>  textContainer: {<br>    flex: 1,<br>    padding: 12,<br>    justifyContent: &#39;center&#39;,<br>  },<br>  title: {<br>    fontSize: 16,<br>    fontWeight: &#39;600&#39;,<br>  },<br>  description: {<br>    fontSize: 14,<br>    color: &#39;#666&#39;,<br>    marginTop: 4,<br>  },<br>});<br>export default BlogList;</pre><h3>🖼 Step 4: Use It in App.js</h3><p>Replace your App.js with this to show the blog list.</p><pre>// App.js<br>import React from &#39;react&#39;;<br>import { SafeAreaView, StatusBar } from &#39;react-native&#39;;<br>import BlogList from &#39;./BlogList&#39;;<br>const App = () =&gt; {<br>  return (<br>    &lt;SafeAreaView style={{ flex: 1 }}&gt;<br>      &lt;StatusBar barStyle=&quot;dark-content&quot; /&gt;<br>      &lt;BlogList /&gt;<br>    &lt;/SafeAreaView&gt;<br>  );<br>};<br>export default App;</pre><h3>⚙️ Step 5: Run the App</h3><pre>npx react-native run-android<br># or<br>npx react-native run-ios</pre><p>You should now see a <strong>scrollable list of blog cards</strong>, smoothly rendered.</p><h3>🚀 Step 6: Performance Tips</h3><ul><li><strong>Use </strong><strong>useCallback for </strong><strong>renderItem</strong><br> It stops the list from reloading items again and again. Makes scrolling smoother.</li><li><strong>Give a unique </strong><strong>keyExtractor</strong><br> Use something like item.id. This helps React know which item is which.</li><li><strong>Load fewer items first</strong><br> Use initialNumToRender={5}. It loads only 5 items at the start for faster screen opening.</li><li><strong>Limit items loaded during scroll</strong><br> Use maxToRenderPerBatch={10}. It controls how many items load at once while scrolling.</li><li><strong>Use </strong><strong>windowSize to control memory</strong><br> Example: windowSize={5} keeps only nearby items in memory. Saves space and improves speed.</li><li><strong>Hide off-screen items on Android</strong><br> Use removeClippedSubviews={true}. It removes hidden items to improve performance on Android.</li><li><strong>Move list item to a separate component</strong><br> And use React.memo() around it. This avoids redrawing unchanged items.</li><li><strong>Avoid inline functions in render</strong><br> Instead of writing functions directly in render, define them outside using useCallback.</li><li><strong>Avoid unnecessary state updates</strong><br> Don’t update screen-wide state unless needed. It can slow down your list.</li><li><strong>Keep each item simple</strong><br> Don’t add too many images or nested views inside each item. Keep it light for better performance.</li></ul><p>By following these simple FlatList performance tips, you can build smooth, fast, and memory-efficient lists in your React Native app — ensuring a better experience for your users, especially on slower devices.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64e48451389f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stripe Payment Gateway Integration In React Native 7]]></title>
            <link>https://medium.com/@tarun.j_30452/stripe-payment-gateway-integration-in-react-native-7-3b9cc057786b?source=rss-1ed2e2ea0c03------2</link>
            <guid isPermaLink="false">https://medium.com/p/3b9cc057786b</guid>
            <category><![CDATA[stripe-payment]]></category>
            <category><![CDATA[card-payment-gateway]]></category>
            <category><![CDATA[card-payment]]></category>
            <category><![CDATA[stripe-integration]]></category>
            <category><![CDATA[react-native-stripe]]></category>
            <dc:creator><![CDATA[Tarun Jain]]></dc:creator>
            <pubDate>Fri, 10 May 2024 12:13:47 GMT</pubDate>
            <atom:updated>2024-05-10T12:13:47.218Z</atom:updated>
            <content:encoded><![CDATA[<p>Imagine implementing a payment gateway using the traditional method: when a user clicks the buy button, you would load HTML in a WebView. Then, you would need to continuously monitor URL changes to identify the success and failure endpoints while discarding any other URL changes. Finally, you would have to confirm the payment status with the application server. This process can be quite tedious and time-consuming.<br>With the release of the <a href="https://stripe.com/docs/libraries/react-native"><strong>Stripe React Native SDK</strong></a>, accepting payments or setting up subscriptions via Stripe has become incredibly easy.</p><p>Integrating the Stripe Payment Gateway into a React Native app involves a few steps.</p><h3>Step 1: Set up your Stripe Account</h3><ol><li>Create a Stripe Account: If you haven’t already, sign up for a Stripe account at <a href="https://dashboard.stripe.com/register">https://dashboard.stripe.com/register</a>.</li><li>Get API Keys: In the dashboard, navigate to the Developers section and find your API keys. You’ll need these keys to authenticate your requests to Stripe’s API.</li></ol><h3>Step 2: Install Dependencies</h3><p>You’ll need to install the Stripe SDK and other dependencies in your React Native project.</p><pre>npm install @stripe/stripe-react-native</pre><h3>Step 3: Initialize Stripe:</h3><p>Replace &quot;your_publishable_key&quot; with your actual publishable key obtained from the Stripe Dashboard.</p><pre>async function initialize() {<br>        const publishableKey = your_publishable_key;<br>        await initStripe({<br>          publishableKey,<br>          merchantIdentifier: &#39;merchant.com.stripe.react.native&#39;,<br>        });<br>        <br>      }<br>  initialize();</pre><h3>Step 4: Get paymentIntentClientSecret from backend api:</h3><p>To get payment intent client secret from api you need to send amount and currency to the api on the response you will get paymentIntentClientSecret.</p><h3>Step 5: Init Payment Sheet:</h3><p>When we received paymentIntentClientSecret then we will send this to the initPaymentSheet in following way:</p><pre>await initPaymentSheet({<br>      paymentIntentClientSecret: paymentIntentClientSecret,<br>      customFlow: true,<br>      merchantDisplayName: &#39;TEST NAME&#39;,<br>    });</pre><h3>Step 6: Creating a Payment Sheet:</h3><p>Stripe provides a Payment Sheet component that you can use to collect payment details securely. Now we are ready to start payment sheet in which we will do payment by card.</p><pre>const handlePayment = async () =&gt; {<br>    try {<br>      const {error, paymentOption} = await presentPaymentSheet();<br>      if (error) {<br>        onClose(error);<br>      } else {<br>        console.log(&#39;Payment successful&#39;, paymentOption);<br>      }<br>    } catch (e) {<br>      onClose(e);<br>    }<br>  };</pre><p>Call handlePayment function from your pay button on click on it you will get payment sheet as below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/369/1*ZZAlmFudGVYNNBm6c0Cp8w.png" /></figure><p>When we fill all our card details and click on continue button then your payment will be success now still payment is incomplete you need to call one more function to confirm payment.</p><h3>Step 7: Confirm payment:</h3><p>In previous function we just need to add confirm payment function to capture payment on stripe</p><pre>const handlePayment = async () =&gt; {<br>    try {<br>      const {error, paymentOption} = await presentPaymentSheet();<br>      if (error) {<br>        onClose(error);<br>      } else {<br>        console.log(&#39;Payment successful&#39;, paymentOption);<br>        confirmPayment();<br>      }<br>    } catch (e) {<br>      onClose(e);<br>    }<br>  };<br><br>  const confirmPayment = async () =&gt; {<br>    const {error} = await confirmPaymentSheetPayment();<br>    if (error) {<br>      onClose(error);<br>    } else {<br>      Alert(&#39;Payment Successfully Done&#39;);<br>    }<br>  };</pre><p>Enhancing User Experience and Security with Stripe in React Native</p><p>Integrating the Stripe Payment Gateway into a React Native app not only streamlines payment processing but also offers opportunities to enhance user experience and ensure transaction security. Let’s delve deeper into optimizing these aspects:</p><p>1. Customizing Payment Sheet UI:</p><ul><li>Leverage Stripe’s Payment Sheet customization options to match your app’s design language seamlessly.</li><li>Incorporate branding elements and intuitive user interfaces to instill trust and familiarity.</li></ul><p>2. Handling Errors Gracefully:</p><ul><li>Implement robust error handling mechanisms to provide clear feedback to users in case of payment failures or network issues.</li><li>Utilize Stripe’s error codes and messages to diagnose issues efficiently and guide users through troubleshooting steps.</li></ul><p>3. Implementing Localization:</p><ul><li>Support multiple languages and currencies to cater to a diverse user base.</li><li>Utilize React Native’s internationalization libraries along with Stripe’s localization features to deliver a localized payment experience.</li></ul><p>4. Optimizing Performance:</p><ul><li>Minimize latency by optimizing network requests and payload sizes.</li><li>Leverage caching mechanisms to store frequently accessed data, such as API responses and payment tokens, locally on the device.</li></ul><p>5. Enhancing Security:</p><ul><li>Utilize Stripe’s built-in security features, such as PCI compliance and tokenization, to safeguard sensitive payment information.</li><li>Implement additional layers of security, such as biometric authentication or two-factor authentication, to protect user accounts and transactions.</li></ul><p>6. Streamlining Checkout Process:</p><ul><li>Reduce friction in the checkout process by pre-filling user details, such as shipping addresses and payment methods, whenever possible.</li><li>Implement one-click or express checkout options to expedite the payment process for returning customers.</li></ul><p>7. Providing Real-time Updates:</p><ul><li>Keep users informed about the status of their transactions with real-time updates and notifications.</li><li>Utilize WebSocket or push notification services to deliver instant updates on payment processing, order fulfillment, and delivery status.</li></ul><p>8. Ensuring Compliance:</p><ul><li>Stay up-to-date with regulatory requirements and industry standards, such as GDPR and PSD2, to ensure compliance with data protection and payment regulations.</li><li>Regularly review and audit your payment processing workflows to identify and address any compliance issues proactively.</li></ul><p>By incorporating these strategies into your React Native app’s integration with the Stripe Payment Gateway, you can deliver a seamless, secure, and user-friendly payment experience that fosters trust and satisfaction among your customers.</p><p>We now understand how <a href="https://github.com/stripe/stripe-react-native"><strong>@stripe/stripe-react-native</strong></a><strong> </strong>is functionality-rich and extremely easy to implement. It has methods and components that are readily usable in our app.</p><p>Components take care of UI, validations, and security, thus saving lots of development time.</p><p>The SDK also offers a payment sheet with a beautiful UI and a list of parameters through which we can customize the payment sheet with different payment options. A complete guide to using the payment sheet is beautifully documented here in the <a href="https://stripe.com/docs/payments/accept-a-payment?platform=react-native&amp;ui=payment-sheet"><strong>official docs</strong>.</a></p><h3>References</h3><ol><li><a href="https://www.cronj.com/blog/react-native-in-app-purchase/">React Native IAP Tutorial</a></li><li><a href="https://reactnative.dev/">https://reactnative.dev/</a></li><li><a href="https://www.cronj.com/blog/react-redux-a-complete-guide-to-beginners/">React Redux Tutorial</a></li><li><a href="https://www.cronj.com/blog/best-reactjs-alternatives/">Alternatives to React</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3b9cc057786b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Steps To Use Consumable In-App Purchases in React Native Version 7/8]]></title>
            <link>https://medium.com/@tarun.j_30452/steps-to-use-consumable-in-app-purchases-in-react-native-version-7-e6750239166a?source=rss-1ed2e2ea0c03------2</link>
            <guid isPermaLink="false">https://medium.com/p/e6750239166a</guid>
            <dc:creator><![CDATA[Tarun Jain]]></dc:creator>
            <pubDate>Fri, 22 Dec 2023 10:02:35 GMT</pubDate>
            <atom:updated>2025-06-19T13:19:45.169Z</atom:updated>
            <content:encoded><![CDATA[<p>In-app purchases (IAP) in React Native involve the integration of native code for both iOS and Android platforms, as React Native itself doesn’t provide a built-in module for handling in-app purchases.<br>In the context of In-App Purchases (IAP), there are several types of purchases that users can make within a mobile application. The terminology and specific types of purchases may vary slightly between platforms (iOS and Android), but generally, the following types are common:</p><ol><li><strong>Consumable Purchases:</strong></li></ol><ul><li>Definition: Consumable purchases are items that users can buy and use up. These are typically things like virtual currency, extra lives, power-ups, or any other virtual goods that can be depleted or consumed within the app.</li><li>Example: Buying virtual coins or gems in a game.</li></ul><p><strong>2. Non-Consumable Purchases:</strong></p><ul><li>Definition: Non-consumable purchases are items that users buy once and have permanent access to. These are typically features or content that doesn’t get used up.</li><li>Example: Unlocking a premium feature, removing ads, or purchasing additional content like an extra level or chapter in a book app.</li></ul><p><strong>3. Auto-Renewable Subscriptions:</strong></p><ul><li>Definition: Auto-renewable subscriptions allow users to access content or features on an ongoing basis. These subscriptions automatically renew at the end of the subscription period unless the user cancels.</li><li>Example: Monthly or yearly subscription for premium content, access to premium features, or ad-free experience.</li></ul><p>Implementing consumable purchases in an In-App Purchase (IAP) system involves several steps, and the specific details can vary depending on the platform (iOS, Android) and the tools/libraries you are using. Below are the general steps to implement consumable purchases in a React Native app using the <a href="https://www.npmjs.com/package/react-native-iap">react-native-iap</a> library:</p><h3>1. Install the library:</h3><p>If you haven’t already installed the <a href="https://www.npmjs.com/package/react-native-iap">react-native-iap</a> library, you can do so using npm or yarn:</p><p><strong>yarn add react-native-iap <br>npm install react-native-iap</strong></p><h3>2. Apple Account Setup and Create an In-App Purchase :</h3><p><strong>Note</strong> :- We need to accept tax agreement from app store account.</p><p>To implement consumable purchases on the Apple App Store for your iOS app, you need to follow several steps. Here’s a general outline of the process:</p><h3>a). Set Up Your App in App Store Connect:</h3><ul><li>Create an App ID:</li><li>Go to the Apple Developer Center.</li><li>Navigate to “Certificates, IDs &amp; Profiles” and create an App ID for your app.</li><li>Create an App in App Store Connect:</li><li>Go to <a href="https://appstoreconnect.apple.com/">App Store Connect</a>.</li><li>Click on “My Apps” and then the “+” button to create a new app.</li></ul><h3>b). Set Up In-App Purchase Products:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/701/1*om3_ypgx1iRw0QqU39Pspg.png" /></figure><ul><li>Create a New In-App Purchase (IAP):</li><li>In the App Store Connect dashboard, go to “Features” &gt; “In-App Purchases.”</li><li>Click the “+” button to add a new in-app purchase.</li><li>Choose “Consumable” as the type.</li><li>Configure the Consumable Product:</li><li>Fill in the necessary details for your consumable product, including the product ID, reference name, and pricing.</li><li>Specify the consumable nature of the product.</li><li>Add a Language-Specific Description:</li><li>Provide a description for your in-app purchase in each language you support.</li><li>Now Click on save. Now check that your product is ready to submit or not if not then something is still pending.</li><li>After saving when you will go back you will receive following screen</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-5uCmneck-Ylkfy1Qvr6lw.png" /></figure><h3>3. Set Up Xcode:</h3><ul><li>Configure Xcode:</li><li>Open your Xcode project.</li><li>Configure your app’s bundle identifier to match the App ID you created.</li><li>Enable In-App Purchase capability in Xcode.</li></ul><p><strong>Note</strong> :- <strong>We need to add build to test flight after enabling capablities from xcode</strong></p><h3>4. Integrate In-App Purchase Code:</h3><pre>import React from &#39;react&#39;;<br>import { useIAP, requestPurchase, isIosStorekit2, PurchaseError } from &#39;react-native-iap&#39;;<br><br>export default function InAppComponent() {<br>const {<br>        products,<br>        currentPurchase,<br>        finishTransaction,<br>        getProducts,<br>        requestPurchase<br>    } = useIAP();<br>const [loading, setLoading] = useState(false);<br><br>const productSkus = Platform.select({<br>  ios: [&#39;com.app.testapp&#39;], //will receive from apple account<br>  android: [],<br>  default: [],<br>}) as string[];<br><br>useEffect(() =&gt; {<br>    handleGetProducts();<br>  }, []);<br><br>const handleGetProducts = async () =&gt; {<br>    try {<br>      setLoading(true)<br>      await getProducts({ skus: productSkus });<br>    } catch (error) {<br>      setLoading(false)<br>      console.log({ message: &#39;handleGetProducts&#39;, error });<br>    }<br>  };<br><br> const handleBuyProduct = async (sku: Sku) =&gt; {<br>        try {<br>            setLoading(true);<br>            await requestPurchase({ sku });<br>        } catch (error) {<br>            handleError(error, &#39;handleBuyProduct&#39;);<br>        } finally {<br>            setLoading(false);<br>        }<br>    };<br><br>const handleError = (error: any, context: string) =&gt; {<br>        console.log(<br>            &#39;Exception while making Request&#39;,<br>            error,<br>        );<br>    };<br><br> useEffect(() =&gt; {<br>     const checkCurrentPurchase = async () =&gt; {<br>            try {<br>                if (<br>                    (isIosStorekit2() &amp;&amp; currentPurchase?.transactionId) ||<br>                    currentPurchase?.transactionReceipt<br>                ) {<br>                    await finishTransaction({<br>                        purchase: currentPurchase,<br>                        isConsumable: true,<br>                    });<br>                    onApiCall(currentPurchase);<br>                }<br>            } catch (error) {<br>                handleError(error, &#39;checkCurrentPurchase&#39;);<br>            }<br>        };<br><br>        checkCurrentPurchase();<br>    }, [currentPurchase, finishTransaction]);<br><br>  const onApiCall = (params: any) =&gt; {<br>       console.log(params,&quot;Call Api Here&quot;)<br>        setLoading(false);<br>    };<br><br>  return (<br>   &lt;&gt;<br>{products.map((product, index) =&gt; (<br>                &lt;TouchableOpacity<br>                    onPress={() =&gt; handleBuyProduct(product.productId)}<br>                    key={index}<br>                &gt;<br>                    &lt;Text&gt;<br>                        {product?.title} for{&#39; &#39;}<br>                        &lt;Text&gt;<br>                            {product?.localizedPrice}<br>                        &lt;/Text&gt;<br>                    &lt;/Text&gt;<br>                &lt;/TouchableOpacity&gt;<br>            ))}<br>&lt;/&gt;<br>  );<br>}</pre><p>Certainly, let’s go through the provided React Native code step by step:</p><p><strong>1. Import Statements:<br></strong>Import necessary modules and functions from ‘react-native-iap’ library.</p><p><strong>2. Product SKUs Definition:<br></strong>Define product SKUs based on the platform (iOS in this case).</p><p><strong>3. handleGetProducts Function:<br></strong>Upon the initial page render, fetch all the products that are associated with your Apple Store account. Use these products to establish a connection with In-App Purchase (IAP). Map the <strong>‘products’</strong> to display them in your view.</p><p><strong>4. handleBuyProduct Function:<br></strong>After listing the products, utilize the <strong>handleBuyProduct</strong> function to initiate the purchase process. Pass the unique productId (created by you) as an argument. Upon execution, the handleBuyProduct function will automatically return a response in the currentPurchase variable. You can then send this response to your API for storage.</p><h3>Conclusion</h3><p>In this comprehensive guide, we delved into the world of in-app purchases in React Native, exploring the fundamentals, implementation steps, best practices, and tips for successfully integrating in-app purchase functionality into mobile applications.</p><h3>References</h3><ol><li><a href="https://www.cronj.com/blog/react-native-in-app-purchase/">React Native IAP Tutorial</a></li><li><a href="https://reactnative.dev/">https://reactnative.dev/</a></li><li><a href="https://www.cronj.com/blog/react-redux-a-complete-guide-to-beginners/">React Redux Tutorial</a></li><li><a href="https://www.cronj.com/blog/best-reactjs-alternatives/">Alternatives to React</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e6750239166a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>