<?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 Marvel Apps on Medium]]></title>
        <description><![CDATA[Stories by Marvel Apps on Medium]]></description>
        <link>https://medium.com/@MarvelApps_?source=rss-38384c210b06------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*b6G1XxBPIsfy8bG_bcLqnw.png</url>
            <title>Stories by Marvel Apps on Medium</title>
            <link>https://medium.com/@MarvelApps_?source=rss-38384c210b06------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 00:14:13 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@MarvelApps_/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[CI/CD in Flutter with Fastlane Match and Github Actions]]></title>
            <link>https://medium.com/@MarvelApps_/ci-cd-in-flutter-with-fastlane-match-and-github-actions-302d840d0f76?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/302d840d0f76</guid>
            <category><![CDATA[fastlane]]></category>
            <category><![CDATA[continous-deployment]]></category>
            <category><![CDATA[cicd]]></category>
            <category><![CDATA[continous-integration]]></category>
            <category><![CDATA[github-actions]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Mon, 03 Mar 2025 07:30:09 GMT</pubDate>
            <atom:updated>2025-03-03T07:30:09.210Z</atom:updated>
            <content:encoded><![CDATA[<p>Continuous Integration and Continuous Deployment (CI/CD) are essential for delivering high-quality applications efficiently. In the Flutter ecosystem, Fastlane simplifies automating deployments, while Git ensures secure and version-controlled storage of sensitive credentials. This guide walks through setting up CI/CD in Flutter using Fastlane Match and Github Actions.</p><h3>Why Fastlane Match?</h3><p>Fastlane Match helps manage iOS code signing certificates and provisioning profiles efficiently by storing them securely in a private Git repository. It ensures that all team members and CI/CD pipelines have access to the latest credentials, avoiding manual certificate management.</p><h3>Prerequisites</h3><p>Before proceeding, ensure you have the following:</p><ul><li>A Flutter project with iOS configuration set up.</li><li>An Apple Developer Account.</li><li>Xcode installed on a macOS machine.</li><li>A GitHub repository with the Flutter project.</li></ul><h3>Step 1: Install Fastlane</h3><p>Fastlane is a powerful tool that automates tasks such as building, testing, and uploading iOS apps.</p><ol><li>Navigate to your Flutter project’s ios directory:</li></ol><pre>cd ios</pre><p>2. Install Fastlane using Bundler:</p><pre>sudo gem install bundler bundle init</pre><p>3. Add Fastlane to your Gemfile:</p><pre>gem &#39;fastlane&#39;</pre><p>4. Install dependencies:</p><pre>bundle install</pre><p>5. Initialize Fastlane:</p><pre>fastlane init</pre><h3>Step 2: Configure Fastlane for iOS</h3><p>Fastlane uses lanes to define different workflows. Modify fastlane/Fastfile to include the following:</p><pre>platform :ios do<br>  desc &quot;Build and upload app to TestFlight&quot;<br>  lane :beta do<br>    build_app(<br>      scheme: &quot;Runner&quot;,<br>      export_method: &quot;app-store&quot;<br>    )<br>    upload_to_testflight<br>  end<br>end</pre><h3>Authenticate with App Store Connect</h3><p>To upload builds, you need an App Store Connect API key.</p><ol><li>Go to <a href="https://appstoreconnect.apple.com/">App Store Connect</a> &gt; Users and Access &gt; Keys.</li><li>Generate a new API key.</li><li>Store the key in fastlane/Appfile:</li></ol><pre>json_key_file &quot;./appstore_connect_api_key.json&quot;</pre><h3>Step 3: Set Up GitHub Actions</h3><p>GitHub Actions automates running Fastlane for CI/CD.</p><ol><li>Create a .github/workflows/ios.yml file:</li></ol><pre>name: iOS CI/CD<br><br>on:<br>  push:<br>    branches:<br>      - main<br>  pull_request:<br>    branches:<br>      - main<br>jobs:<br>  build:<br>    runs-on: macos-latest<br>    steps:<br>      - name: Checkout Repository<br>        uses: actions/checkout@v3<br>      - name: Setup Flutter<br>        uses: subosito/flutter-action@v2<br>        with:<br>          flutter-version: &quot;stable&quot;<br>      - name: Install Dependencies<br>        run: flutter pub get<br>      - name: Install CocoaPods<br>        run: |<br>          cd ios<br>          pod install<br>      - name: Install Fastlane<br>        run: |<br>          cd ios<br>          bundle install<br>      - name: Run Fastlane Beta<br>        run: |<br>          cd ios<br>          bundle exec fastlane beta<br>        env:<br>          APP_STORE_CONNECT_API_KEY: ${{ secrets.APP_STORE_CONNECT_API_KEY }}</pre><h3>Step 4: Secure Secrets</h3><p>Store sensitive information in GitHub Secrets:</p><ol><li>Navigate to your repository on GitHub.</li><li>Go to <strong>Settings &gt; Secrets and Variables &gt; Actions</strong>.</li><li>Add APP_STORE_CONNECT_API_KEY and paste the contents of your App Store Connect API key JSON file.</li></ol><h3>Step 5: Trigger the Workflow</h3><p>Push changes to the main branch, and GitHub Actions will automatically build and deploy your iOS app to TestFlight.</p><h3>Conclusion</h3><p>By setting up Fastlane with GitHub Actions, you create an efficient CI/CD pipeline for your Flutter iOS app. This automation saves time, reduces errors, and accelerates the deployment process, allowing you to focus more on development and innovation.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=302d840d0f76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide to Flutter HtmlWYSIWYGTextField Package]]></title>
            <link>https://medium.com/@MarvelApps_/a-beginners-guide-to-flutter-htmlwysiwygtextfield-package-35eb254ae593?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/35eb254ae593</guid>
            <category><![CDATA[textfield]]></category>
            <category><![CDATA[mobile-application-dev]]></category>
            <category><![CDATA[htmlwysiwygtextfield]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 09:16:35 GMT</pubDate>
            <atom:updated>2025-02-28T10:36:30.708Z</atom:updated>
            <content:encoded><![CDATA[<p>Flutter is an amazing framework for building beautiful mobile applications, and sometimes, you need a rich text field in your app. That’s where the HtmlWYSIWYGTextField package comes in! This package allows you to add a text field with various formatting options, including links, bullets, copy-paste, font size, bold, italic, and even button customisation.</p><p>If you’re new to Flutter or just want an easy way to add a rich text field, this guide is for you!</p><h3>What is HtmlWYSIWYGTextField ?</h3><p>HtmlWYSIWYGTextField is a <strong>WYSIWYG (What You See Is What You Get)</strong> text field that helps users format text easily. It supports different text styles, lists and links.</p><h3>Features of HtmlWYSIWYGTextField :</h3><ul><li><strong>Rich Text Editing</strong>: Add bold, italic, underline, and different fonts.</li><li><strong>Lists</strong>: Use bullet points or numbered lists.</li><li><strong>Hyperlinks</strong>: Add clickable links.</li><li><strong>Copy-Paste Support</strong>: Easily paste content from other sources.</li><li><strong>Customizable Buttons</strong>: Modify toolbar buttons to suit your app.</li></ul><h3>How to Use HtmlWYSIWYGTextField in Your App</h3><h3>Step 1: Add Dependency</h3><p>First, add the package to your pubspec.yaml file:</p><pre>dependencies:<br>  flutter:<br>    sdk: flutter<br>  html_wysiwyg_textfield: ^latest_version</pre><p>Run flutter pub get to install the package.</p><h3>Step 2: Import the Package</h3><p>In your Dart file, import the package:</p><pre>import &#39;package:html_wysiwyg_textfield/html_wysiwyg_textfield.dart&#39;;</pre><h3>Step 3: Add the Editor to Your Widget</h3><p>Now, you can add the HtmlWYSIWYGTextField editor inside your widget tree:</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:html_wysiwyg_textfield/html_wysiwyg_textfield.dart&#39;;<br><br><br><br>class HtmlWysiwygScreen extends StatelessWidget {<br>  const HtmlWysiwygScreen({Key? key}) : super(key: key);@override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      body: Column(<br>        children: [<br>          Expanded(<br>            child: HtmlWYSIWYGTextField(<br>              key : _keyData<br>              height: 300,<br>              value: &quot;Your text here...&quot;,<br>              fontList: const [&#39;11&#39;, &#39;12&#39;, &#39;13&#39;, &#39;14&#39;],<br>              onNavigate: (url) {<br>                Navigator.of(context).push(<br>                  MaterialPageRoute(<br>                    builder: (context) =&gt; WebViewScreen(url: url),<br>                  ),<br>                );<br>              },<br>              customToolbar: &quot;&quot;&quot;<br>                [<br>                [&#39;style&#39;, [&#39;bold&#39;, &#39;italic&#39;, &#39;underline&#39;, &#39;clear&#39;]],<br>                [&#39;font&#39;, [&#39;strikethrough&#39;]],<br>                [&#39;fontname&#39;, [&#39;fontname&#39;]],<br>                [&#39;fontsize&#39;, [&#39;fontsize&#39;]],<br>                [&#39;para&#39;, [&#39;ul&#39;, &#39;ol&#39;]],<br>                [&#39;linkButton&#39;, [&#39;customLink&#39;]],<br>                [&#39;copyButton&#39;, [&#39;customCopy&#39;]],<br>                [&#39;pasteButton&#39;, [&#39;customPaste&#39;]],<br>                [&#39;cutButton&#39;, [&#39;customCut&#39;]]<br>                ]<br>              &quot;&quot;&quot;,<br>            ),<br>          ),<br>        ],<br>      ),<br>    );<br>  }<br>}</pre><h3>🔍 Understanding Key Properties</h3><h3>🔹 1. value: &quot;Your text here...&quot;</h3><p>The <strong>value</strong> property allows you to <strong>pre-fill</strong> the editor with text when it loads.</p><p>✅ Useful for editing saved content.<br>✅ Acts as placeholder text before the user types anything.</p><p>Example:</p><pre>HtmlWYSIWYGTextField(<br>  key: _keyData,<br>  value: &quot;Your text here...&quot;,  // Prefilled text<br>)</pre><p>💡 If you leave value empty, the editor will start with a blank text area.</p><h3>🔹 2. fontList: const [&#39;11&#39;, &#39;12&#39;, &#39;13&#39;, &#39;14&#39;]</h3><p>The <strong>fontList</strong> property controls which <strong>font sizes</strong> appear in the editor’s dropdown.</p><p>✅ Restrict font size options for consistency.<br>✅ Customize available font sizes for better UI/UX.</p><p>Example:</p><pre>HtmlWYSIWYGTextField(<br>  key: _keyData,<br>  fontList: const [&#39;11&#39;, &#39;12&#39;, &#39;13&#39;, &#39;14&#39;],  // Only show these font sizes<br>)</pre><p>By default, the HtmlWYSIWYGTextField editor shows many font sizes, but you can limit them using this property.</p><h3>🔹 3. onNavigate: (url) {...}</h3><p>The <strong>onNavigate</strong> function handles link clicks inside the editor. Instead of opening a link in an external browser, you can <strong>open it in a WebView inside your app</strong>.</p><p>✅ Keeps users inside the app.<br>✅ Gives you full control over link navigation.</p><p>Example:</p><pre>HtmlWYSIWYGTextField(<br>  key: _keyData,<br>  onNavigate: (url) {<br>    Navigator.of(context).push(<br>      MaterialPageRoute(<br>        builder: (context) =&gt; WebViewScreen(url: url),<br>      ),<br>    );<br>  },<br>)</pre><h3>🔹 4. Getting the Edited Content</h3><p>Once the user types something, you can get the text using:</p><pre>String? text = await _keyData.currentState?.getText();<br>print(text);</pre><h3>Why Use HtmlWYSIWYGTextField ?</h3><ul><li><strong>Easy to Implement</strong>: Just a few lines of code to get started.</li><li><strong>Feature-Rich</strong>: Supports text formatting, lists, and media.</li><li><strong>Great for Blogs, Notes, and Emails</strong>: Useful for apps requiring formatted text input.</li></ul><h3>Final Thoughts</h3><p>HtmlWYSIWYGTextField is a great choice if you want a simple yet powerful rich text editor in your app. With support for links, formatting, and images, it’s perfect for many use cases. Try it in your next Flutter project and make text editing easier for your users!</p><p>Follow the link below for more understanding.</p><p><a href="https://pub.dev/packages/html_wysiwyg_textfield">https://pub.dev/packages/html_wysiwyg_textfield</a></p><p>Happy coding! 🚀</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35eb254ae593" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Effortless App Deployment: From Code to Launch]]></title>
            <link>https://medium.com/@MarvelApps_/effortless-app-deployment-from-code-to-launch-d01dc50d2cea?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/d01dc50d2cea</guid>
            <category><![CDATA[android]]></category>
            <category><![CDATA[app-store]]></category>
            <category><![CDATA[deployment]]></category>
            <category><![CDATA[ios]]></category>
            <category><![CDATA[play-store]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 06:32:18 GMT</pubDate>
            <atom:updated>2025-02-28T06:32:18.880Z</atom:updated>
            <content:encoded><![CDATA[<p>Deploying an app to the App Store (iOS) and Google Play Store (Android) requires careful planning, proper configuration, and adherence to platform-specific guidelines. This guide covers the prerequisites, development setup, testing types, required accounts, certificate creation, keystore file generation, and step-by-step deployment process for both platforms.</p><h4>Prerequisites</h4><p>Before deploying an app, ensure you have the following:</p><ol><li><strong>Finalized App</strong> — The app should be fully developed, tested, and free from critical bugs.</li><li><strong>Build Configuration</strong> — Ensure the app is configured for release mode with appropriate environment settings.</li><li><strong>Versioning</strong> — Update the app version and build number according to platform-specific requirements.</li><li><strong>App Icons &amp; Screenshots</strong> — Prepare platform-specific app icons, launch images, and promotional screenshots.</li><li><strong>Privacy Policy &amp; Terms of Service</strong> — A compliant privacy policy and terms of service should be hosted online.</li><li><strong>Test on Real Devices</strong> — Ensure testing is done on multiple real devices and form factors.</li></ol><h4>Development Setup</h4><p>To start development, ensure the following:</p><h4><strong>iOS Development:</strong></h4><ul><li><strong>Mac Computer</strong> with the latest macOS.</li><li><strong>Xcode</strong> installed from the Mac App Store.</li><li><strong>Apple Developer Account</strong> for provisioning profiles and signing certificates.</li><li><strong>Simulator &amp; Physical Devices</strong> for testing.</li></ul><h4>Android Development:</h4><ul><li><strong>Android Studio</strong> installed with the latest SDK.</li><li><strong>Java Development Kit (JDK)</strong>.</li><li><strong>Google Play Developer Account</strong> for signing and uploading apps.</li><li><strong>Physical &amp; Virtual Devices</strong> for testing.</li></ul><h4>Testing Types</h4><h4><strong>iOS App Testing:</strong></h4><ul><li><strong>Internal Testing Group</strong>: Use TestFlight to distribute the app to up to 100 team members.</li><li><strong>External Testing Group</strong>: Allows beta testing with up to 10,000 users after Apple’s review.</li></ul><h4>Android App Testing:</h4><ul><li><strong>Internal Testing</strong>: Release the app to a small group for initial testing.</li><li><strong>Closed Testing</strong>: Invite specific testers to try out the app before a wider release.</li><li><strong>Open Testing</strong>: Allows anyone with the link to test the app before public release.</li></ul><h4>Required Accounts</h4><p>To deploy an app, you need the following accounts:</p><h4>iOS Deployment:</h4><ul><li><strong>Apple Developer Account</strong> Enroll at <a href="https://developer.apple.com/">developer.apple.com</a>.($99/year individual account) &amp; ($299/year enterprise account).</li><li><strong>App Store Connect Access</strong> — Required for managing app distribution.</li><li><strong>Xcode</strong> — Required for building and uploading the app.</li><li><strong>Apple TestFlight</strong> — For beta testing before release.</li></ul><h4>Android Deployment:</h4><ul><li><strong>Google Play Developer Account</strong> ($25 one-time fee) — Sign up at play.google.com/console.</li><li><strong>Google Play Console Access</strong> — Required for managing app distribution.</li><li><strong>Firebase (Optional)</strong> — If using push notifications, analytics, or crash reporting.</li></ul><h4>Certificate Creation (iOS)</h4><p>To distribute an iOS app, you need to create a distribution certificate:</p><ol><li><strong>Generate a Certificate Signing Request (CSR):</strong></li></ol><ul><li>Open <strong>Keychain Access</strong> on your Mac.</li><li>Select <strong>Certificate Assistant &gt; Request a Certificate From a Certificate Authority</strong>.</li><li>Enter your email and select <strong>Save to Disk</strong>.</li></ul><p><strong>2. Create a Distribution Certificate in Apple Developer Portal:</strong></p><ul><li>Go to <a href="https://developer.apple.com/">developer.apple.com</a>.</li><li>Navigate to <strong>Certificates, Identifiers &amp; Profiles</strong>.</li><li>Click <strong>Certificates &gt; All</strong> and select <strong>+</strong>.</li><li>Choose <strong>Apple Distribution</strong> and upload the CSR file.</li><li>Download and install the generated certificate in <strong>Keychain Access</strong>.</li></ul><p><strong>3. Create a Provisioning Profile:</strong></p><ul><li>In the Developer Portal, go to <strong>Profiles</strong> and click <strong>+</strong>.</li><li>Select <strong>App Store</strong> for distribution.</li><li>Choose the certificate and app identifier.</li><li>Download and install the profile in Xcode.</li></ul><h4>Keystore File Creation (Android)</h4><p>A keystore file is required to sign and publish an Android app:</p><ol><li><strong>Generate a Keystore File:</strong></li></ol><ul><li>Open the terminal and run:</li></ul><pre>keytool -genkey -v -keystore my-release-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 1000</pre><ul><li>Enter a strong password and complete the required details.</li></ul><p><strong>2. Store the Keystore File Securely:</strong></p><ul><li>Place the .keystore file in a secure location.</li><li>Keep a backup of the keystore password and alias.</li></ul><p><strong>3. Configure Keystore in </strong><strong>gradle.properties:</strong></p><pre>storeFile=my-release-key.keystore <br>storePassword=your-store-password <br>keyAlias=my-key-alias <br>keyPassword=your-key-password</pre><p><strong>4. Sign the App in </strong><strong>build.gradle:</strong></p><pre>android {<br>    signingConfigs {<br>        release {<br>            storeFile file(storeFile)<br>            storePassword storePassword<br>            keyAlias keyAlias<br>            keyPassword keyPassword<br>        }<br>    }<br>    buildTypes {<br>        release {<br>            signingConfig signingConfigs.release<br>        }<br>    }<br>}</pre><h4>iOS Deployment Process</h4><h4>1. Prepare the iOS App for Release</h4><ul><li>Open the project in <strong>Xcode</strong>.</li><li>Set the <strong>Bundle Identifier</strong> and <strong>Version</strong> in Info.plist.</li><li>Choose the appropriate <strong>Signing &amp; Capabilities</strong> (Automatic signing is recommended).</li><li>Archive the app: Product &gt; Archive.</li></ul><h4>2. Upload to App Store Connect</h4><ul><li>After archiving, select <strong>Distribute App</strong> in Xcode.</li><li>Choose <strong>App Store Connect</strong> as the destination.</li><li>Upload the build using <strong>Xcode Organizer</strong>.</li></ul><h4>3. Configure App in App Store Connect</h4><ul><li>Go to <strong>App Store Connect &gt; My Apps</strong>.</li><li>Create a new app and enter metadata (App Name, Description, Keywords, etc.).</li><li>Upload app screenshots for different device sizes.</li><li>Configure pricing and availability settings.</li></ul><h4>4. App Review &amp; Submission</h4><ul><li>Submit the app for <strong>App Review</strong>.</li><li>Apple reviews the app (can take 1–3 days).</li><li>Once approved, release the app manually or schedule automatic release.</li></ul><h4>Android Deployment Process</h4><h4>1. Prepare the Android App for Release</h4><ul><li>Open the project in <strong>Android Studio</strong>.</li><li>Update the <strong>versionCode</strong> and <strong>versionName</strong> in build.gradle.</li><li>Generate a signed <strong>.aab (Android App Bundle)</strong> file.</li><li>Use the <strong>Google Play App Signing</strong> option (recommended for better security).</li></ul><h4>2. Upload to Google Play Console</h4><ul><li>Sign in to <strong>Google Play Console</strong>.</li><li>Create a new app and fill in metadata (App Name, Description, Category, etc.).</li><li>Upload the <strong>.aab file</strong> under the <strong>Production</strong> track.</li></ul><h4>3. App Review &amp; Release</h4><ul><li>Submit the app for review.</li><li>Google may take a few hours to days for approval.</li><li>Once approved, publish the app manually or schedule an automatic release.</li></ul><h4>Conclusion</h4><p>By following this structured process, you can ensure a smooth deployment and compliance with platform guidelines. Keep track of updates and security requirements for seamless app distribution.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d01dc50d2cea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monetizing Magic: Making Your Flutter App Work for You with Ads]]></title>
            <link>https://medium.com/@MarvelApps_/monetizing-magic-making-your-flutter-app-work-for-you-with-ads-d408ea7e3f77?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/d408ea7e3f77</guid>
            <category><![CDATA[admob]]></category>
            <category><![CDATA[mobile-application-dev]]></category>
            <category><![CDATA[flutter]]></category>
            <category><![CDATA[advertisement]]></category>
            <category><![CDATA[dart]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Fri, 28 Feb 2025 06:26:55 GMT</pubDate>
            <atom:updated>2025-02-28T06:26:55.222Z</atom:updated>
            <content:encoded><![CDATA[<p>Monetizing your Flutter app with Google Ads is an excellent way to generate revenue. Google AdMob allows you to display ads in your app seamlessly. In this blog, I will guide you through integrating Google AdMob in your Flutter application with step-by-step instructions.</p><h4>Prerequisites</h4><ul><li>A Flutter project</li><li>A Google AdMob account (<a href="https://admob.google.com/"><em>Click to Sign up</em></a>)</li><li>Google Mobile Ads SDK</li></ul><h4><strong>Step 1: Create an AdMob Account and Generate Ad Unit IDs</strong></h4><ol><li>Sign in with your Google account on <a href="https://admob.google.com/">AdMob</a> .</li><li>Click on <strong>Apps</strong> → <strong>Add App.</strong></li><li>Register your Flutter app.</li><li>Save your <strong>App ID</strong> (E.g., ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx).</li><li>Create required <strong>Ad Unit</strong> (e.g., Banner, Interstitial, Rewarded).</li><li>Save the generated <strong>Ad Unit IDs </strong>to be used later in code.</li></ol><h4>Step 2: Add Dependencies in Flutter</h4><p>Add the following dependency to your project inpubspec.yaml file:</p><pre>dependencies:<br>  google_mobile_ads: ^4.0.0</pre><pre>flutter pub get</pre><h4>Step 3: Initialize Google Mobile Ads SDK</h4><p>Modify the main.dart file to initialize Google Mobile Ads SDK before using ads.</p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:google_mobile_ads/google_mobile_ads.dart&#39;;<br><br>void main() {<br>  WidgetsFlutterBinding.ensureInitialized();<br>  MobileAds.instance.initialize(); // Initialize AdMob<br>  runApp(MyApp());<br>}</pre><h4>Step 4: Implement Banner Ads</h4><h4>1. Load a Banner Ad</h4><p>Modify the HomeScreen or any other screen to load and display a <strong>banner ad </strong>and replace the adUnitId with your banner ad Id<strong>.</strong></p><pre>import &#39;package:flutter/material.dart&#39;;<br>import &#39;package:google_mobile_ads/google_mobile_ads.dart&#39;;class HomeScreen extends StatefulWidget {<br>  @override<br>  _HomeScreenState createState() =&gt; _HomeScreenState();<br>}class _HomeScreenState extends State&lt;HomeScreen&gt; {<br>  BannerAd? _bannerAd;<br>  bool _isBannerAdLoaded = false;  @override<br>  void initState() {<br>    super.initState();<br>    _loadBannerAd();<br>  }void _loadBannerAd() {<br>    _bannerAd = BannerAd(<br>      adUnitId: &#39;ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx&#39;, // Use test ID<br>      size: AdSize.banner,<br>      request: AdRequest(),<br>      listener: BannerAdListener(<br>        onAdLoaded: (ad) {<br>          setState(() {<br>            _isBannerAdLoaded = true;<br>          });<br>        },<br>        onAdFailedToLoad: (ad, error) {<br>          print(&quot;Failed to load a banner ad: ${error.message}&quot;);<br>          ad.dispose();<br>        },<br>      ),<br>    );<br>    _bannerAd?.load();<br>  }  @override<br>  Widget build(BuildContext context) {<br>    return Scaffold(<br>      appBar: AppBar(title: Text(&quot;Google Ads in Flutter&quot;)),<br>      body: Column(<br>        mainAxisAlignment: MainAxisAlignment.end,<br>        children: [<br>          if (_isBannerAdLoaded)<br>            Container(<br>              height: _bannerAd!.size.height.toDouble(),<br>              width: _bannerAd!.size.width.toDouble(),<br>              child: AdWidget(ad: _bannerAd!),<br>            ),<br>        ],<br>      ),<br>    );<br>  }  @override<br>  void dispose() {<br>    _bannerAd?.dispose();<br>    super.dispose();<br>  }<br>}</pre><h4>Step 5: Implement Interstitial Ads</h4><p><strong>1. Load and Show an Interstitial Ad</strong></p><pre>import &#39;package:google_mobile_ads/google_mobile_ads.dart&#39;;class AdManager {<br>  InterstitialAd? _interstitialAd;void loadInterstitialAd() {<br>    InterstitialAd.load(<br>      adUnitId: &#39;ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx&#39;, // Test ID<br>      request: AdRequest(),<br>      adLoadCallback: InterstitialAdLoadCallback(<br>        onAdLoaded: (ad) {<br>          _interstitialAd = ad;<br>        },<br>        onAdFailedToLoad: (error) {<br>          print(&quot;Interstitial Ad failed to load: ${error.message}&quot;);<br>        },<br>      ),<br>    );<br>  }void showInterstitialAd() {<br>    if (_interstitialAd != null) {<br>      _interstitialAd!.show();<br>      _interstitialAd = null;<br>      loadInterstitialAd(); // Preload next ad<br>    }<br>  }<br>}</pre><h4>Step 6: Implement Rewarded Ads</h4><p>Rewarded ads give users incentives for watching an ad, e.g., unlocking premium content.</p><p><strong>1. Load and Show a Rewarded Ad</strong></p><pre>import &#39;package:google_mobile_ads/google_mobile_ads.dart&#39;;class RewardedAdManager {<br>  RewardedAd? _rewardedAd;void loadRewardedAd() {<br>    RewardedAd.load(<br>      adUnitId: &#39;ca-app-pub-3940256099942544/5224354917&#39;, // Test ID<br>      request: AdRequest(),<br>      rewardedAdLoadCallback: RewardedAdLoadCallback(<br>        onAdLoaded: (ad) {<br>          _rewardedAd = ad;<br>        },<br>        onAdFailedToLoad: (error) {<br>          print(&quot;Rewarded Ad failed to load: ${error.message}&quot;);<br>        },<br>      ),<br>    );<br>  }void showRewardedAd() {<br>    if (_rewardedAd != null) {<br>      _rewardedAd!.show(onUserEarnedReward: (ad, reward) {<br>        print(&quot;User earned reward: ${reward.amount} ${reward.type}&quot;);<br>      });<br>      _rewardedAd = null;<br>      loadRewardedAd(); // Preload next ad<br>    }<br>  }<br>}</pre><h4>Step 7: Configure Android &amp; iOS for AdMob</h4><p><strong>Android:</strong></p><p>Open AndroidManifest.xml and add:</p><pre>&lt;manifest&gt;<br>    &lt;application&gt;<br>        &lt;meta-data<br>            android:name=&quot;com.google.android.gms.ads.APPLICATION_ID&quot;<br>            android:value=&quot;ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx&quot;/&gt;<br>    &lt;/application&gt;<br>&lt;/manifest&gt;</pre><p><strong>iOS:</strong></p><p>Open Info.plist and add:</p><pre>&lt;key&gt;GADApplicationIdentifier&lt;/key&gt;<br>&lt;string&gt;ca-app-pub-xxxxxxxxxxxxxxxx~xxxxxxxxxx&lt;/string&gt;<br>&lt;key&gt;SKAdNetworkItems&lt;/key&gt;<br>&lt;array&gt;<br>  &lt;dict&gt;<br>    &lt;key&gt;SKAdNetworkIdentifier&lt;/key&gt;<br>    &lt;string&gt;cstr6suwn9.skadnetwork&lt;/string&gt;<br>  &lt;/dict&gt;<br>&lt;/array&gt;</pre><ol><li>Run:</li></ol><pre>cd ios<br>pod install</pre><h4>Step 8: Test Your Ads</h4><p>Before publishing your app, ensure test ads are enabled:</p><ul><li>Use <strong>test ad unit IDs</strong> provided by Google.</li><li>Use AdRequest(testDevices: [&#39;YOUR_DEVICE_ID&#39;]) for testing.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/0*GbqYNGkjr7xhJK8Q.gif" /></figure><h4>Conclusion</h4><p>You’ve successfully integrated Google AdMob ads in your Flutter application! 🚀 You can now:</p><p>✔ Display <strong>banner ads</strong><br>✔ Show <strong>interstitial ads</strong><br>✔ Implement <strong>rewarded ads</strong></p><blockquote>Congratulations! 🎉 You’ve successfully integrated Google AdMob into your Flutter app. By following best practices, you can maximize revenue while ensuring a smooth user experience.If you found this tutorial helpful, share it! <a href="https://github.com/DeekshaSharmas/POCs.git">Github Link</a></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d408ea7e3f77" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[State Management in React Native: Context API vs Redux]]></title>
            <link>https://medium.com/@MarvelApps_/state-management-in-react-native-context-api-vs-redux-02506853f232?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/02506853f232</guid>
            <category><![CDATA[context]]></category>
            <category><![CDATA[state-management]]></category>
            <category><![CDATA[context-api-vs-redux]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[redux]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 07:47:43 GMT</pubDate>
            <atom:updated>2025-01-24T07:47:43.438Z</atom:updated>
            <content:encoded><![CDATA[<p>In React Native, <strong>state</strong> refers to a mutable object that is used within components or app to keep track of information that can change over time (or in simple words, to manage the dynamic data).</p><h3>Common State Management Approaches</h3><ol><li><strong>Local State Management</strong>: For smaller applications or components, we can manage state using React’s built-in useState hook or the setState method.</li><li><strong>Global State Management</strong>: For larger applications, consider using Context API or libraries like Redux . These tools help manage state across various components, making it easier to share data and maintain consistency.</li><li><strong>Using Libraries</strong>: Explore popular state management libraries such as MobX, Recoil, or Zustand. Each has its own strengths and can be chosen based on the specific needs of your application.</li></ol><p>In this blog, we will explore how to effectively utilize <strong>Redux</strong> and the <strong>Context API</strong> for state management in React Native applications. We will discuss when to use which approach, as well as ,their similarities and differences.</p><p>As applications grow in size and complexity, managing state through <strong>prop drilling</strong> — passing data through multiple layers of components — can result in significant performance bottlenecks. This approach becomes cumbersome and inefficient, particularly when many components need access to the same state.</p><p>To overcome these challenges, we commonly adopt state management solutions like <strong>Redux</strong> and the <strong>Context API</strong>, which provide more efficient ways to share state across components.</p><h3>Context API</h3><p>The Context API consists of two primary components: <strong>Context Provider</strong> and <strong>Context Consumer</strong>.</p><p>The <strong>Provider</strong> is incharge of creating and managing the context, which holds the data that needs to be shared across components. Meanwhile, the <strong>Consumer</strong> is used to access and retrieve that shared data within any component that needs it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*3cSdJfRcApHJatCV.png" /></figure><p>Context API</p><p>To start using the Context API in your applications, you’ll need to follow a few simple steps:</p><ol><li><strong>Create a Context Object</strong></li></ol><p>The first step is to create a context object. This object will serve as a container for the shared data you want to distribute across your components.</p><pre>import React, { createContext } from &#39;react&#39;;<br><br>// Creating a context with a default value of null<br>export const AppContext = createContext(null);</pre><p>2. <strong>Wrap Components with a Provider</strong></p><p>Once you’ve created a context object, the next step is to wrap your components with a <strong>Provider</strong>.</p><p>The <strong>Provider</strong> component is responsible for making the shared data accessible to all child components. Its accepts a value prop, which holds the data that you want to share.</p><pre>import React, { useState } from &#39;react&#39;;<br>import { View, Text, Button } from &#39;react-native&#39;;<br>import { AppContext } from &#39;./AppContext&#39;;<br>import HomeScreen from &#39;./HomeScreen&#39;;<br><br>const App = () =&gt; {<br>  // Shared data state: authentication status<br>  const [isAuthenticated, setIsAuthenticated] = useState(false);<br>  return (<br>    // Wrap the entire app with the Provider and pass the shared data as &quot;value&quot;<br>    &lt;AppContext.Provider value={{ isAuthenticated, setIsAuthenticated }}&gt;<br>      &lt;View style={{ flex: 1, justifyContent: &#39;center&#39;, alignItems: &#39;center&#39; }}&gt;<br>        &lt;HomeScreen /&gt;<br>      &lt;/View&gt;<br>    &lt;/AppContext.Provider&gt;<br>  );<br>};<br>export default App;</pre><p>3.<strong> Consume the Context</strong></p><p>Now that we’ve set up the <strong>Provider</strong> to share the context, the next step is to <strong>consume</strong> the context in any child component that needs access to the shared data.</p><p>To do this, we use the <strong>useContext</strong> hook provided by React. This hook allows us to directly access the context data without having to pass props through multiple levels of components.</p><pre>import React, { useContext } from &#39;react&#39;;<br>import { View, Text, Button } from &#39;react-native&#39;;<br>import { AppContext } from &#39;./AppContext&#39;;<br><br>const HomeScreen = () =&gt; {<br>  // Access shared context data using useContext<br>  const { isAuthenticated, setIsAuthenticated } = useContext(AppContext);<br>  return (<br>    &lt;View style={{ flex: 1, justifyContent: &#39;center&#39;, alignItems: &#39;center&#39; }}&gt;<br>      &lt;Text&gt;<br>        {isAuthenticated ? &#39;You are logged in!&#39; : &#39;You are not logged in!&#39;}<br>      &lt;/Text&gt;<br>      &lt;Button<br>        title={isAuthenticated ? &#39;Log Out&#39; : &#39;Log In&#39;}<br>        onPress={() =&gt; setIsAuthenticated(!isAuthenticated)}<br>      /&gt;<br>    &lt;/View&gt;<br>  );<br>};<br>export default HomeScreen</pre><h3>Redux</h3><p>Redux is a powerful state management library that helps manage application state in a predictable way. It is useful for larger applications where state management can become complex.</p><p>Redux consists of three core principles: <strong>a single source of truth</strong>,<strong> state is read-only,</strong> and <strong>changes are made with pure functions</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*W8Sp4PNt95J8FgDH.gif" /></figure><p>Understanding Redux: A Visual Representation of Data Flow in a Redux Application <a href="https://redux.js.org/assets/images/ReduxDataFlowDiagram-49fa8c3968371d9ef6f2a1486bd40a26.gif">(source)</a></p><p>Key Components of Redux</p><ol><li><strong>Store</strong>: The store holds the entire state of your application. It is created using the createStore function from Redux.</li><li><strong>Actions</strong>: Actions are plain JavaScript objects that describe <strong>what happened</strong> in the application. They must have a type property and can optionally include additional data.</li><li><strong>Reducers</strong>: Reducers are pure functions that take the current state and an action as arguments and return a new state. They specify <strong>how the application’s state changes</strong> in response to actions.</li></ol><h3>Setting Up Redux in Your Application</h3><p>To start using Redux in your React Native application, follow these steps:</p><ol><li><strong>Install Redux and React-Redux</strong>: First, you need to install Redux and React-Redux, which provides bindings for React.</li></ol><pre>npm install redux react-redux</pre><p>2. <strong>Define Action</strong></p><pre>// actionTypes.js<br>export const INCREMENT = &quot;INCREMENT&quot;;<br>export const DECREMENT = &quot;DECREMENT&quot;;<br><br>// actionCreators.js<br>import { INCREMENT, DECREMENT } from &#39;./actionTypes&#39;;<br>export const increment = () =&gt; ({<br>  type: INCREMENT<br>});<br>export const decrement = () =&gt; ({<br>  type: DECREMENT<br>});</pre><p>3.<strong> Define Reducer</strong></p><pre>// counterReducer.js<br>import { INCREMENT, DECREMENT } from &#39;./actionTypes&#39;;<br><br>const initialState = {<br>  count: 0<br>};<br>const counterReducer = (state = initialState, action) =&gt; {<br>  switch (action.type) {<br>    case INCREMENT:<br>      return { ...state, count: state.count + 1 };<br>    case DECREMENT:<br>      return { ...state, count: state.count - 1 };<br>    default:<br>      return state;<br>  }<br>};<br>export default counterReducer;</pre><p>4. <strong>Create the Redux Store</strong></p><pre>// store.js<br>import { createStore } from &#39;redux&#39;;<br>import counterReducer from &#39;./counterReducer&#39;;<br><br>// Create the Redux store using the reducer<br>const store = createStore(counterReducer);<br>export default store;</pre><p>5. <strong>Integrate the Store with React (if applicable)</strong></p><pre>import React from &#39;react&#39;;<br>import { AppRegistry } from &#39;react-native&#39;;<br>import { Provider } from &#39;react-redux&#39;;<br>import store from &#39;./store&#39;;<br>import App from &#39;./App&#39;;<br>import { name as appName } from &#39;./app.json&#39;;<br><br>const Index = () =&gt; (<br>  &lt;Provider store={store}&gt;<br>    &lt;App /&gt;<br>  &lt;/Provider&gt;<br>);<br>AppRegistry.registerComponent(appName, () =&gt; Index);</pre><p>6. <strong>Connect Redux State and Dispatch to React Native Components</strong></p><pre>import React from &#39;react&#39;;<br>import { View, Text, Button } from &#39;react-native&#39;;<br>import { useSelector, useDispatch } from &#39;react-redux&#39;;<br>import { increment, decrement } from &#39;./actionCreators&#39;;<br><br>const App = () =&gt; {<br>  // Accessing the count from the Redux state<br>  const count = useSelector((state) =&gt; state.count);<br>  // Dispatching actions to the store<br>  const dispatch = useDispatch();<br>  return (<br>    &lt;View style={{ flex: 1, justifyContent: &#39;center&#39;, alignItems: &#39;center&#39; }}&gt;<br>      &lt;Text style={{ fontSize: 24, marginBottom: 20 }}&gt;Count: {count}&lt;/Text&gt;<br>      &lt;Button title=&quot;Increment&quot; onPress={() =&gt; dispatch(increment())} /&gt;<br>      &lt;Button title=&quot;Decrement&quot; onPress={() =&gt; dispatch(decrement())} /&gt;<br>    &lt;/View&gt;<br>  );<br>};<br>export default App;</pre><h3>Key Differences Between Redux and Context API</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Tpz54Lc73USjJpI9.png" /></figure><p>Difference between redux and contextApi</p><h3>When to Use React Context API vs Redux?</h3><p>The choice between React Context API and Redux hinges on your application’s complexity and requirements:</p><p><strong>Context API:</strong></p><ul><li>Your application is small to medium-sized.</li><li>You have fewer levels of data sharing.</li><li>You need to manage component-specific state.</li></ul><p><strong>Redux :</strong></p><ul><li>Your application is large and complex.</li><li>You have deeply nested components.</li><li>You require handling asynchronous data flows.</li></ul><h3>Conclusion</h3><p>The <strong>Context API</strong> is ideal for small to medium-sized applications with simple state management needs, while <strong>Redux</strong> is better suited for large, complex apps requiring centralized state management, scalability, and handling asynchronous data flows. The choice depends on the app’s complexity and the level of state management needed.</p><p>Give this blog a clap if it helped you. 👏👏👏👏</p><p>Thanks for reading!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=02506853f232" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrating Native Modules with React Native: Accessing Device Features]]></title>
            <link>https://medium.com/@MarvelApps_/integrating-native-modules-with-react-native-accessing-device-features-398a15f74252?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/398a15f74252</guid>
            <category><![CDATA[bridging]]></category>
            <category><![CDATA[native-modules]]></category>
            <category><![CDATA[hybrid-mobile-application]]></category>
            <category><![CDATA[react-native]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 07:43:54 GMT</pubDate>
            <atom:updated>2025-01-24T07:43:54.190Z</atom:updated>
            <content:encoded><![CDATA[<p>React Native allows developers to build <strong>cross-platform </strong>mobile apps with a single JavaScript codebase. But sometimes, the built-in features of <a href="https://reactnative.dev/">React Native</a> may not be sufficient, especially when you need to access device-specific features like <strong>camera</strong>, <strong>GPS</strong>, <strong>sensors</strong>, or <strong>Bluetooth</strong>.</p><p>This is where <strong>Native Modules</strong> come in. Native modules enable you to bridge <strong>Java</strong> (for Android) or <strong>Swift/Objective-C</strong> (for iOS) code into React Native, giving you direct access to native device features.</p><h3>Why Use Native Modules?</h3><p>Native modules bridge the gap between JavaScript and native code, allowing React Native apps to interact with device-specific features. You might consider native modules in the following cases:</p><ol><li><strong>Access to Unique Features:</strong> Interact with proprietary hardware or third-party SDKs.</li><li><strong>Performance Optimization:</strong> Execute resource-intensive operations directly on the native layer.</li><li><strong>Unsupported APIs:</strong> Enable functionalities unavailable in React Native’s core or third-party libraries.</li></ol><h3>Prerequisites</h3><p>Before diving into native module integration, ensure you have:</p><ul><li>A React Native project set up with Android Studio and Xcode.</li><li>Basic knowledge of JavaScript and React Native.</li><li>Familiarity with native programming in <strong>Java</strong> (for Android) and <strong>Swift/Objective-C</strong> (for iOS).</li></ul><h3>Creating a Custom Native Module (Step-by-Step Guide)</h3><h3>Step 1: Building a Native Module for Android</h3><h3>1. Create the Module</h3><p>Navigate to the android/app/src/main/java/com/yourapp directory and create a Java file, e.g: MyModule.java:</p><pre>package com.yourapp;<br><br>import android.widget.Toast;<br>import com.facebook.react.bridge.ReactApplicationContext;<br>import com.facebook.react.bridge.ReactContextBaseJavaModule;<br>import com.facebook.react.bridge.ReactMethod;<br>public class MyModule extends ReactContextBaseJavaModule {<br>    public MyModule(ReactApplicationContext reactContext) {<br>        super(reactContext);<br>    }<br>    @Override<br>    public String getName() {<br>        return &quot;MyModule&quot;;<br>    }<br>    @ReactMethod<br>    public void showToast(String message) {<br>        Toast.makeText(getReactApplicationContext(), message, Toast.LENGTH_SHORT).show();<br>    }<br>}</pre><h3>2. Register the Module</h3><p>Update MainApplication.java to include your custom module:</p><pre>import com.yourapp.MyModule;<br><br>@Override<br>protected List&lt;ReactPackage&gt; getPackages() {<br>    return Arrays.&lt;ReactPackage&gt;asList(<br>        new MainReactPackage(),<br>        new MyReactPackage() // Add your package here<br>    );<br>}</pre><p>Create a custom package, MyReactPackage.java:</p><pre>import com.facebook.react.ReactPackage;<br>import com.facebook.react.bridge.NativeModule;<br>import com.facebook.react.uimanager.ViewManager;<br>import java.util.Arrays;<br>import java.util.Collections;<br>import java.util.List;<br><br>public class MyReactPackage implements ReactPackage {<br>    @Override<br>    public List&lt;NativeModule&gt; createNativeModules(ReactApplicationContext reactContext) {<br>        return Arrays.&lt;NativeModule&gt;asList(new MyModule(reactContext));<br>    }<br>    @Override<br>    public List&lt;ViewManager&gt; createViewManagers(ReactApplicationContext reactContext) {<br>        return Collections.emptyList();<br>    }<br>}</pre><h3>Step 2: Building a Native Module for iOS</h3><h3>1. Create the Module</h3><p>In Xcode, add a new Swift file, MyModule.swift:</p><pre>import Foundation<br>import React<br><br>@objc(MyModule)<br>class MyModule: NSObject {<br>    @objc<br>    func showToast(_ message: String) {<br>        let alert = UIAlertController(title: nil, message: message, preferredStyle: .alert)<br>        DispatchQueue.main.async {<br>            UIApplication.shared.keyWindow?.rootViewController?.present(alert, animated: true, completion: nil)<br>            DispatchQueue.main.asyncAfter(deadline: .now() + 2) {<br>                alert.dismiss(animated: true, completion: nil)<br>            }<br>        }<br>    }<br>    @objc<br>    static func requiresMainQueueSetup() -&gt; Bool {<br>        return true<br>    }<br>}</pre><h3>2. Register the Module</h3><p>In AppDelegate.m, include your module:</p><pre>#import &lt;React/RCTBridgeModule.h&gt;<br><br>@interface RCT_EXTERN_MODULE(MyModule, NSObject)<br>RCT_EXTERN_METHOD(showToast:(NSString *)message)<br>@end</pre><h3>Step 3: Linking and Using Native Modules in React Native</h3><h3>1. Link Your Native Module</h3><p>If you’re using React Native 0.60 or newer, auto-linking should take care of this. Otherwise, follow the manual linking process as per the documentation.</p><h3>2. Access Native Modules in JavaScript</h3><p>Use NativeModules to call your custom module:</p><pre>import { NativeModules } from &#39;react-native&#39;;<br><br>const { MyModule } = NativeModules;<br>MyModule.showToast(&#39;Hello from Native Module!&#39;);</pre><h3>Testing Your Integration</h3><ol><li>Launch your app using react-native run-android or react-native run-ios.</li><li>Call the showToast method from your React Native app and verify the behavior.</li></ol><h3>Best Practices</h3><ol><li><strong>Error Handling:</strong> Handle errors gracefully to prevent app crashes.</li><li><strong>Platform Independence:</strong> Abstract platform-specific code to avoid duplicating logic.</li><li><strong>Optimize Performance:</strong> Minimize native calls, as they can be slower than JavaScript execution.</li><li><strong>Documentation:</strong> Keep your native modules well-documented for easy maintenance.</li></ol><h3>Conclusion</h3><p>This article explores how to integrate native modules with React Native to access device features like the camera, GPS, and accelerometer. It highlights the benefits of using native modules to extend the functionality of React Native apps, enabling access to platform-specific APIs for more advanced capabilities. The guide includes practical tips for implementing these integrations efficiently. Happy coding!</p><p>Give this blog a clap if it helped you. 👏👏👏👏</p><p>❤❤ Thanks for reading!!! ❤❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=398a15f74252" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Exploring React Native’s Flexbox: Tips for Perfect Alignment]]></title>
            <link>https://medium.com/@MarvelApps_/exploring-react-natives-flexbox-tips-for-perfect-alignment-9c953279a216?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/9c953279a216</guid>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Fri, 24 Jan 2025 07:39:22 GMT</pubDate>
            <atom:updated>2025-01-24T07:39:22.232Z</atom:updated>
            <content:encoded><![CDATA[<p>Let’s learn something about Flexbox</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cuAzrUfiVjWpado2.jpeg" /></figure><p>Hey there, fellow developer! 👋</p><p>So, you’ve dipped your toes into React Native, and now you’re staring at Flexbox like it’s some mysterious wizardry. It’s not a spell, I promise! Flexbox is your best friend when building beautiful, responsive layouts in React Native. Think of it like a magic tool that helps you organize your app’s UI, ensuring everything’s aligned and looking snazzy on any screen size.</p><p>But let’s be real — Flexbox can feel a bit like trying to fold a fitted sheet for the first time (it looks easy, but what the heck is going on with those corners?). Don’t worry, I got your back. Let’s walk through Flexbox like we’re chatting over a cup of coffee.</p><h3>What is Flexbox, Really?</h3><p>Okay, let’s keep this simple. <strong>Flexbox</strong> is basically a layout system that lets you control how components in a container should be arranged, spaced out, and aligned. Sounds fancy, right?</p><p>But trust me, it’s as fun as putting together a Lego set — once you know where all the pieces go.</p><p>In React Native, Flexbox helps us to manage</p><ul><li><strong>The direction of the layout</strong> (is your UI in a row or column?),</li><li><strong>How elements should grow, shrink, or stay still</strong></li><li><strong>How things should be aligned and spaced</strong>.</li></ul><p>It’s like being a <strong>UI magician</strong> with a set of powerful tools. 🧙‍♂️✨</p><h3>The Flexbox Properties You’ll Actually Use</h3><p>Before we get into the tips, let’s quickly go over the Flexbox properties. Don’t worry — this isn’t a boring lecture. I’ll keep it light. 😎</p><ol><li><strong>flex</strong>: This magical number tells items how to grow or shrink. If you give it a value1, it says, &quot;Hey, take up any leftover space in the container, please!&quot; If you set it to0, you’re saying, &quot;Nope, I don’t need extra space, thanks.&quot;</li><li><strong>flexDirection</strong>: This decides whether your items should be lined up in a row or a column. You’ll use it row for horizontal layouts and column vertical ones.</li><li><strong>justifyContent</strong>: This aligns items along the <strong>main axis</strong> (so, depending onflexDirection, whether it could be horizontally or vertically)<br>it’s attributes:<br>center: Center your stuff, because who doesn&#39;t love a little symmetry?space-between: Distribute things evenly<br>flex-start/flex-end: Put things at the start or end of the container (perfect if you&#39;re into minimalism).</li><li><strong>alignItems</strong>: This property is for aligning things on the <strong>cross-axis</strong>. It flexDirection is row, it will align items vertically. If it&#39;scolumn, it aligns them horizontally. Simple, right?</li><li><strong>alignSelf</strong>: You want to make one item rebel against the others? alignSelf is your tool. It overrides the alignItems rule for a specific item.</li><li><strong>flexWrap</strong>: If you have too many items crammed into a container and need them to <em>wrap</em>, use flexWrap. It’s like when your mom tells you to clean your room but instead of shoving everything under the bed, you organize it into neat piles. 🍃</li></ol><h3>Tips for Flexbox Mastery</h3><p>Now that you’ve got the basics down, let’s get to the good stuff: <strong>tips for perfect alignment</strong>. Ready to level up your React Native layout game? 🎮</p><h3>1. Know Your Axes: Main vs. Cross (Not a Band)</h3><p>Imagine you’re playing darts. The <strong>main axis</strong> is your target (that’s where the action happens), and the <strong>cross axis</strong> is like the safety net, just making sure things stay in place.</p><ul><li><strong>Main axis</strong> = where the flex magic happens (horizontal or vertical, depending on your flexDirection).</li><li><strong>Cross axis</strong> = where you ensure things don’t fall off the edge (perpendicular to the main axis).</li></ul><p>If you mess up these axes, it’s like throwing darts with your eyes closed. Not fun. So, keep them in mind when you’re using properties like justifyContent and alignItems.</p><h3>2. justifyContent: The Space Distributor (It’s Like a DJ for Your Layout)</h3><p>If you’re creating a row and want to center everything like a champion, use justifyContent: &#39;center&#39;. It’s like putting all the chairs around the table, ensuring no one’s left standing awkwardly by the wall.</p><pre>&lt;View style={{ flexDirection: &#39;row&#39;, justifyContent: &#39;center&#39; }}&gt;<br>  &lt;Text&gt;Item 1&lt;/Text&gt;<br>  &lt;Text&gt;Item 2&lt;/Text&gt;<br>&lt;/View&gt;</pre><p>Want your items spaced out evenly, like how you would arrange your snacks at a party (not too close, not too far apart)? Try space-between:</p><pre>&lt;View style={{ flexDirection: &#39;row&#39;, justifyContent: &#39;space-between&#39; }}&gt;<br>  &lt;Text&gt;Item 1&lt;/Text&gt;<br>  &lt;Text&gt;Item 2&lt;/Text&gt;<br>&lt;/View&gt;</pre><h3>3. alignItems: Vertical Alignment (For When You Need That Extra ‘Oomph’)</h3><p>Okay, this one is a game-changer. Want to make sure everything is aligned properly? Use alignItems. If you have a row and you want everything to sit pretty in the middle, like a perfectly aligned Pinterest board, use center:</p><pre>&lt;View style={{ flexDirection: &#39;row&#39;, alignItems: &#39;center&#39; }}&gt;<br>  &lt;Text&gt;Item 1&lt;/Text&gt;<br>  &lt;Text&gt;Item 2&lt;/Text&gt;<br>&lt;/View&gt;</pre><p>For aligning items to the top or bottom, you can use flex-start or flex-end (no judgment here—sometimes you just need to get stuff done).</p><h3>4. alignSelf: One Item to Rule Them All</h3><p>Ever had that one friend who refuses to conform to the group for the Trip? 😅 Same here. alignSelf Let you do this with individual items. Want one item to be a total rebel and stand out? Just use alignSelf.</p><pre>&lt;View style={{ flexDirection: &#39;row&#39;, alignItems: &#39;flex-start&#39; }}&gt;<br>  &lt;Text&gt;Item 1&lt;/Text&gt;<br>  &lt;Text style={{ alignSelf: &#39;center&#39; }}&gt;Item 2&lt;/Text&gt;<br>  &lt;Text&gt;Item 3&lt;/Text&gt;<br>&lt;/View&gt;</pre><p>Boom! Item 2 is now the center of attention. 😎</p><h3>5. flexWrap: Don’t Cram Everything into One Row!</h3><p>What happens when you’ve got too many items and they start to overflow? Well, you could just pretend it’s not happening, but <em>we’re developers</em>, not magicians. Use flexWrap to let your items flow onto the next line.</p><pre>&lt;View style={{ flexDirection: &#39;row&#39;, flexWrap: &#39;wrap&#39; }}&gt;<br>  &lt;Text style={{ width: 100 }}&gt;Item 1&lt;/Text&gt;<br>  &lt;Text style={{ width: 100 }}&gt;Item 2&lt;/Text&gt;<br>  &lt;Text style={{ width: 100 }}&gt;Item 3&lt;/Text&gt;<br>  &lt;Text style={{ width: 100 }}&gt;Item 4&lt;/Text&gt;<br>&lt;/View&gt;</pre><p>Just like that, your items are all neat and tidy without spilling over into the next dimension. 🧙‍♀️✨</p><h3>6. flex: Give Items Space to Grow</h3><p>Flex makes your items <em>flexible</em>. It tells them how much space they should take up relative to other items in the container.</p><p>Want everything to take equal space? Easy. Just add a flex: 1 to all items:</p><pre>&lt;View style={{ flexDirection: &#39;row&#39; }}&gt;<br>  &lt;Text style={{ flex: 1 }}&gt;Item 1&lt;/Text&gt;<br>  &lt;Text style={{ flex: 1 }}&gt;Item 2&lt;/Text&gt;<br>  &lt;Text style={{ flex: 1 }}&gt;Item 3&lt;/Text&gt;<br>&lt;/View&gt;</pre><h3>Wrapping It Up (Literally, with Flex Wrap)</h3><p>Flexbox is your secret weapon for creating stunning, responsive UIs in React Native. Whether you’re trying to centre some buttons, space out items, or make sure everything fits nicely on any screen, Flexbox has got you covered. So, go ahead — become the Flexbox master you were always meant to be. You got this! 💪</p><p>And remember, Flexbox is like your developer toolbox. There’s no one-size-fits-all solution. Play around, experiment, and have fun with it. Happy coding, and may your layouts always be perfectly aligned! 😎🎉</p><p>Feel free to let me know how it goes! Or if you mess up, I’ll totally understand. It happens to the best of us.</p><p><em>Hope this article is useful for you!🙂🙂 Give this blog a clap if it helped you.</em> 👏👏👏👏</p><p><em>If you enjoyed this article, share it with your friends and colleagues!😇</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9c953279a216" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Supabase: Database Solution]]></title>
            <link>https://medium.com/@MarvelApps_/supabase-database-solution-e1c9a87e647d?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/e1c9a87e647d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[backend-development]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[supabase]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Fri, 10 Jan 2025 06:07:04 GMT</pubDate>
            <atom:updated>2025-01-10T06:07:04.110Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Supabase</strong> is a relational database that uses PostgreSQL for storing data in a structured format, i.e., in tables, with rows and columns.</p><p>It supports JSON and <a href="https://supabase.com/docs/guides/ai">vector dataTypes</a> and and allows writing triggers and functions in pure SQL. Supabase offers role-based, row-level security and, most importantly, enables querying and normalizing data using joins.</p><h3>Did You Know ?</h3><p>Supabase can also serve as a Backend-as-a-Service (BaaS) for many web and mobile application development frameworks like React.js, React Native, Flutter, Angular.js, Vue.js, etc.</p><p>Supabase is built on a relational database model with various<strong> relationship types</strong>, including:</p><ul><li>Many-to-Many</li><li>Many-to-One</li><li>One-to-One</li><li>One-to-Many</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XTsNz6b_uXO9lsWe" /><figcaption>Relational Database (Relationship types: many-many, many-one ,one-one ,one-many)</figcaption></figure><h3>Why Choose Supabase?</h3><p><strong>Relational and Realtime Database: </strong>Supabase enables us to store and handle structured data efficiently with real-time updates. This combination makes it perfect for apps that need immediate data synchronization.</p><p><strong>Faster Access Speed:</strong> Supabase integrates with Content Delivery Networks (CDNs) to cache static assets. It also handles indexing for tables (primary, secondary, clustering indexing etc. based on data storing ways or its type), which speeds up data retrieval.</p><p><strong>Full Stack Solution: </strong>Supabase provides authentication, storage, and serverless functionalities, allowing us to create complete applications without the need of multiple services.</p><p><strong>SQL and REST APIs: </strong>Supabase supports SQL queries and generates RESTful APIs according to database schema, making it simple to integrate with other services and front-end frameworks.</p><p><strong>Security: </strong>Supabase features such as role-based access control and row-level security help to assure application security and data protection.</p><p><strong>Open Source: </strong>Supabase is open source, meaning developers can analyze, change, and contribute to the codebase.</p><h3>Supabase Setup :</h3><p><strong>Step 1 : Create Account</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*DScklfN0MsHMXMaZ" /></figure><p>We can Sign Up or Login with the help of Github account or Google Email.</p><p><strong>Step 2: After Login Screen</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eC71SqNdpunr-rlv" /></figure><p>If You already created an organization, then your Project will be Visible like above, Screen. Here, I Created a project with name ExpoPractice in Satyam’s2023 organization.</p><h3>OR</h3><p>If <strong>you are new</strong>, then after login you will navigate to the above screen and to create a Project, first we need to create an organization by clicking the button of “New Organization”.</p><p><strong>Step 3 : Creating Project and Organization</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*M-flTJLAQ-A9zy-h" /><figcaption>Creating Project Screen</figcaption></figure><p>To Create a project we need to fill the above details and after filling the details click the “Create New Project” at bottom right corner.</p><p><strong>Step 4 : APIs URL and Key</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*mnJkgwvg26MPT00c" /></figure><p>After clicking the Create New Project button you will be navigating to the above screen, and from there you will get the API URL from “Project Configuration” tab and Key from “Project API Keys” tab.</p><blockquote><strong>You can refer to this </strong><a href="https://drive.google.com/file/d/1QexOo0LNFlAyMa2BSX6XbCiIVIAbnTry/view?resourcekey="><strong>Video</strong></a>. <strong>for the steps to set up the database.</strong></blockquote><p>After that , Our Project Setup is ready!!</p><p>To Access the API in our javascript application we need to implement the following library :</p><pre>npm install @supabase/supabase-js</pre><p>After installing the library, import the following functions:</p><pre>import { createClient } from &#39;@supabase/supabase-js&#39;</pre><pre>const supabase = createClient(&#39;Supabase_API_URL&#39;, &#39;Supabase_API_ANON_KEY&#39;)</pre><p>There are generally two types of key in Supabase <strong>anon</strong> and <strong>Service Role key</strong>.</p><p><strong>Anon Key:</strong> In Supabase, it allows users to view data you define as publicly accessible through Row Level Security (RLS). We can think of it as a guest pass. It grants limited access to public areas of the building, like the lobby.</p><p><strong>Secret Key : </strong>In Supabase, it’s a powerful key used by your application’s backend to manage your database (add, edit, delete data) as long as RLS allows it. This is like a master key for building staff. It grants access to most areas (depending on your setup) for maintenance or other tasks.</p><p>Now we can use the Supabase in our Project:</p><h3>Fetch Data</h3><p>It always return two types of object <strong>error </strong>and <strong>data </strong>.</p><p>Query:</p><pre>const {error,data}= supabase.from(&#39;tableName&#39;).select();<br>//It returns all the data from the table.</pre><pre>const {error,data}= supabase.from(&#39;tableName&#39;).select(&#39;columnName&#39;);<br>//It returns data only from the specified column.</pre><h3>Update Data:</h3><p>Query:</p><pre>const {error,data}=await supabase.from(&#39;tableName&#39;).update({ field: &quot;value&quot;. })<br>.eq(&#39;id&#39;, id_value)<br>//It updates the table row where the ID matches the given id_value.</pre><h3>Upsert Data :</h3><p>Query:</p><pre>const {error,data}= supabase.from(&#39;tableName&#39;).<br>                    upsert({id:value,column_name:value})<br>//It updates the data if it already exists, or inserts the data if it does not exist.</pre><h3>Delete Data:</h3><p>Query:</p><pre>const {error,data}=supabase<br>  .from(&#39;tableName&#39;)<br>  .delete().eq(&#39;id&#39;,id_value);<br>//It deletes the column for the specified ID.</pre><p><strong>Now , We Create simple To Do list using Supabase .</strong></p><p>Intialize your supabase :</p><p><strong>Supabase.ts file</strong></p><pre>import { AppState } from &#39;react-native&#39;<br>import &#39;react-native-url-polyfill/auto&#39;<br>import AsyncStorage from &#39;@react-native-async-storage/async-storage&#39;<br>import { createClient } from &#39;@supabase/supabase-js&#39;<br><br>const supabaseUrl = &#39;your_url&#39;;<br>const supabaseAnonKey = &#39;your_key&#39;;<br>export const supabase = createClient(supabaseUrl, supabaseAnonKey, {<br>  auth: {<br>    storage: AsyncStorage,<br>    autoRefreshToken: true,<br>    persistSession: true,<br>    detectSessionInUrl: false,<br>  },<br>})<br>AppState.addEventListener(&#39;change&#39;, (state) =&gt; {<br>  if (state === &#39;active&#39;) {<br>    supabase.auth.startAutoRefresh()<br>  } else {<br>    supabase.auth.stopAutoRefresh()<br>  }<br>})</pre><p><strong>TextField.tsx common component file</strong></p><pre>import { TextInput, View, Text, StyleSheet, ViewStyle } from &quot;react-native&quot;;<br><br>interface TextInputProps {<br>  placeholder: string;<br>  onChangeText: (text: string) =&gt; void;<br>  value?: string;<br>}<br>const TextField = ({ placeholder, onChangeText, value }: TextInputProps) =&gt; {<br>  return (<br>    &lt;View style={{ marginTop: 16 }}&gt;<br>      &lt;Text&gt;{placeholder}&lt;/Text&gt;<br>      &lt;TextInput<br>        onChangeText={(text: string) =&gt; {<br>          onChangeText(text);<br>        }}<br>        style={styles.textContainer}<br>        defaultValue={value}<br>      /&gt;<br>    &lt;/View&gt;<br>  );<br>};<br>export default TextField;<br>const styles = StyleSheet.create&lt;{ textContainer: ViewStyle }&gt;({<br>  textContainer: {<br>    borderRadius: 10,<br>    borderColor: &quot;#2E8A466B&quot;,<br>    borderWidth: 2,<br>    height: 56,<br>    width: &quot;100%&quot;,<br>    marginTop: 16,<br>    paddingHorizontal: 10,<br>  },<br>});</pre><p><strong>Constant.ts (Constant String File)</strong></p><pre>export enum CONST_STRING{<br>     GO_TO_SIGN_LOG=&quot;Go to SignUp or Login Screen&quot;,<br>     ENTER_EMAIL=&quot;Enter Email&quot;,<br>     ENTER_PASS=&quot;Enter Password&quot;,<br>     SIGNUP=&#39;Sign Up&#39;,<br>     SIGNIN=&#39;Sign In&#39;,<br>     ALREADY_ACC=&quot;Already have a Account ? &quot;,<br>     ENTER_TASK=&quot;Enter To Do Task&quot;,<br>     UPDATE=&quot;Update&quot;,<br>     ID=&quot;Id:&quot;,<br>     Value=&quot;Values:&quot;,<br>     DELETE=&quot;DELETE&quot;,<br>     ADD=&quot;Add +&quot;,<br>     ENTER_NAME=&quot;Enter Name&quot;,<br>     ENTER_SCORE=&quot;Enter Score&quot;,<br>     ADD_SCORE=&quot;ADD SCORE&quot;,<br>     ENTER_LOCATION=&quot;Enter Location&quot;,<br>     ADD_LOCATION=&quot;Add Location&quot;<br>  }</pre><p><strong>Interface.ts (Interface File)</strong></p><pre>import { MutableRefObject } from &quot;react&quot;;<br>import { TextStyle, ViewStyle } from &quot;react-native&quot;;<br><br>export interface IUserDetails {<br>  [key: string | number]: MutableRefObject&lt;string&gt;;<br>  email: MutableRefObject&lt;string&gt;;<br>  password: MutableRefObject&lt;string&gt;;<br>}<br>export interface IToDoStyle {<br>  addBtn: ViewStyle;<br>  itemContainer: ViewStyle;<br>  delUpdContainer: ViewStyle;<br>  delBtn: ViewStyle;<br>  updBtn: ViewStyle;<br>  headingStyle: TextStyle;<br>}<br>export interface Itable {<br>  id: string;<br>  Values: string;<br>  Created_By: string;<br>  last_updated: string;<br>  created_at: string;<br>}<br>export interface IScore {<br>  id: number;<br>  name: string;<br>  score: number;<br>  user_id: string;<br>}<br>export interface IStoreStyle{<br>    addLocationBtn:ViewStyle;<br>    container:ViewStyle; <br>}</pre><p><strong>Imports of App.tsx file</strong></p><pre>import React, { useEffect, useRef, useState } from &quot;react&quot;;<br>import {<br>  ActivityIndicator,<br>  FlatList,<br>  Pressable,<br>  SafeAreaView,<br>  StyleSheet,<br>  Text,<br>  View,<br>} from &quot;react-native&quot;;<br>import { supabase } from &quot;../../supabse&quot;;<br>import TextField from &quot;../../component/TextInput&quot;;<br>import { IToDoStyle, Itable } from &quot;../../models/Interface&quot;;<br>import { CONST_STRING } from &quot;../../libs/Constant&quot;;</pre><pre>import React, { useEffect, useRef, useState } from &quot;react&quot;;<br>import {<br>  ActivityIndicator,<br>  FlatList,<br>  Pressable,<br>  SafeAreaView,<br>  StyleSheet,<br>  Text,<br>} from &quot;react-native&quot;;<br>import { supabase } from &quot;../../supabse&quot;;<br>import TextField from &quot;../../component/TextInput&quot;;<br>import { View } from &quot;react-native&quot;;<br>import { IToDoStyle, Itable } from &quot;../../models/Interface&quot;;<br>import { CONST_STRING } from &quot;../../libs/constant&quot;;<br><br>const ToDoList = () =&gt; {<br>  const [toDoList, setTodoList] = useState&lt;Itable[]&gt;([]);<br>  const [updateItem, setUpdateItem] = useState&lt;number&gt;(-1);<br>  const [loaderStatus, setLoaderStatus] = useState&lt;boolean&gt;(false);<br>  const details = useRef&lt;string&gt;(&quot;&quot;);<br>// The fetchToDoList function is used to retrieve all the ToDo items from our database.<br>  const fetchTodoList = async () =&gt; {<br>    try {<br>      setLoaderStatus(true);<br>      const supavalue = await supabase.from(&quot;toDo&quot;).select();<br>      supavalue?.data &amp;&amp; setTodoList(supavalue?.data);<br>    } catch (e) {<br>      console.error(e);<br>    } finally {<br>      setLoaderStatus(false);<br>    }<br>  };<br>// It is used to filter the data for the given ID from our ToDo list.<br> const giveContent = (id: string) =&gt; {<br>    const filteredValue = toDoList.filter((item: Itable) =&gt; item.id == id);<br>    details.current = filteredValue[0].Values;<br>  };<br>  const updateCleanUp = () =&gt; {<br>    details.current = &quot;&quot;;<br>    setUpdateItem(-1);<br>    fetchTodoList();<br>  };<br>//It is used to update an existing ToDo item based on its ID.<br>  const updateTaskItem = async (id: string) =&gt; {<br>    try {<br>      const { data, error } = await supabase<br>        .from(&quot;toDo&quot;)<br>        .update([<br>          {<br>            Values: details.current,<br>            last_updated: new Date(),<br>          },<br>        ])<br>        .eq(&quot;id&quot;, id);<br>      updateCleanUp();<br>    } catch (e) {<br>      console.error(e);<br>    }<br>  };<br>  const updateValue = async (id: string) =&gt; {<br>    giveContent(id);<br>    setUpdateItem(Number(id));<br>  };<br><br>// It adds a new task to our ToDo list.<br> const addTask = async () =&gt; {<br>    if (updateItem != -1) {<br>      updateTaskItem(updateItem as unknown as string);<br>    } else {<br>      const { data, error } = await supabase.from(&quot;toDo&quot;).insert([<br>        {<br>          Values: details.current,<br>          created_at: new Date(),<br>        },<br>      ]);<br>      updateCleanUp();<br>    }<br>  };<br>// It deletes the selected task.<br> const deleteTask = async (id: string) =&gt; {<br>    const { data, error } = await supabase.from(&quot;toDo&quot;).delete().eq(&quot;id&quot;, id);<br>    fetchTodoList();<br>  };<br>  const btnText = updateItem != -1 ? CONST_STRING.UPDATE : CONST_STRING.ADD;<br>  useEffect(() =&gt; {<br>    fetchTodoList();<br>  }, []);<br>  const renderItem = ({ item }: { item: Itable; index: number }) =&gt; {<br>    return (<br>      &lt;View style={styles.itemContainer}&gt;<br>        &lt;Text&gt;<br>          &lt;Text style={styles.headingStyle}&gt;{CONST_STRING.ID} &lt;/Text&gt;<br>          {item.id}<br>        &lt;/Text&gt;<br>        &lt;Text&gt;<br>          &lt;Text style={styles.headingStyle}&gt;{CONST_STRING.Value} &lt;/Text&gt;<br>          {item.Values}<br>        &lt;/Text&gt;<br>        &lt;View style={styles.delUpdContainer}&gt;<br>          &lt;Pressable style={styles.delBtn} onPress={() =&gt; deleteTask(item?.id)}&gt;<br>            &lt;Text&gt;{CONST_STRING.DELETE}&lt;/Text&gt;<br>          &lt;/Pressable&gt;<br>          &lt;Pressable<br>            style={styles.updBtn}<br>            onPress={() =&gt; updateValue(item?.id)}<br>          &gt;<br>            &lt;Text&gt;{CONST_STRING.UPDATE}&lt;/Text&gt;<br>          &lt;/Pressable&gt;<br>        &lt;/View&gt;<br>      &lt;/View&gt;<br>    );<br>  };<br>  return (<br>    &lt;SafeAreaView style={styles.mainContainer}&gt;<br>        &lt;View style={styles.inputContainer}&gt;<br>          &lt;TextInput<br>            placeholder={CONST_STRING.ENTER_TASK}<br>            onChangeText={(value: string) =&gt; (details.current = value)}<br>            value={details.current}<br>          /&gt;<br>          &lt;Pressable style={styles.addBtn} onPress={addTask}&gt;<br>            &lt;Text&gt; {btnText}&lt;/Text&gt;<br>          &lt;/Pressable&gt;<br>        &lt;/View&gt;<br>        {!loaderStatus ? (<br>          &lt;FlatList<br>            showsVerticalScrollIndicator={false}<br>            data={toDoList}<br>            renderItem={renderItem}<br>            style={{ marginTop: 40 }}<br>          /&gt;<br>        ) : (<br>          &lt;ActivityIndicator size={&quot;large&quot;} color={&quot;green&quot;} /&gt;<br>        )}<br>    &lt;/SafeAreaView&gt;<br>  );<br>};<br>export default ToDoList;</pre><pre>export interface IToDoStyle { <br>  mainContainer:ViewStyle; <br>  inputContainer:ViewStyle;       <br>  addBtn: ViewStyle;<br>  itemContainer: ViewStyle;<br>  delUpdContainer: ViewStyle;<br>  delBtn: ViewStyle;<br>  updBtn: ViewStyle;<br>  headingStyle: TextStyle;<br>}<br><br><br>const styles = StyleSheet.create&lt;IToDoStyle&gt;({<br>  mainContainer:{<br>    flex:1,<br>    paddingHorizontal:20<br>  },<br>  inputContainer:{<br>    paddingHorizontal:40<br>  },<br>  addBtn: {<br>    justifyContent: &quot;center&quot;,<br>    alignItems: &quot;center&quot;,<br>    backgroundColor: &quot;#2E8A8A72&quot;,<br>    padding: 10,<br>    marginTop: 16,<br>    borderRadius: 10,<br>  },<br>  itemContainer: {<br>    backgroundColor: &quot;#2E8ACB5B&quot;,<br>    padding: 20,<br>    marginBottom: 16,<br>    borderRadius: 20,<br>  },<br>  delUpdContainer: {<br>    flexDirection: &quot;row&quot;,<br>    justifyContent: &quot;space-around&quot;,<br>    marginTop: 10,<br>  },<br>  delBtn: {<br>    backgroundColor: &quot;red&quot;,<br>    padding: 10,<br>    borderRadius: 10,<br>  },<br>  updBtn: {<br>    backgroundColor: &quot;#00EA002D&quot;,<br>    padding: 10,<br>    borderRadius: 10,<br>  },<br>  headingStyle: {<br>    fontSize: 17,<br>    fontStyle: &quot;italic&quot;,<br>  },<br>});</pre><p>Thanks For Reading !!!!</p><p>If you like it , don’t forget to give a clap .</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e1c9a87e647d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[React Native’s New Architecture: A Leap Beyond the Old Paradigm]]></title>
            <link>https://medium.com/@MarvelApps_/react-natives-new-architecture-a-leap-beyond-the-old-paradigm-20b166759527?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/20b166759527</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[react-native]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[react-native-architecture]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Wed, 08 Jan 2025 07:30:22 GMT</pubDate>
            <atom:updated>2025-01-08T07:30:22.210Z</atom:updated>
            <content:encoded><![CDATA[<p>React Native has been a popular choice for developers aiming to create cross-platform mobile apps, thanks to its “Learn once, write anywhere” philosophy. However, as apps grow in complexity, the need for better performance and more efficient communication between JavaScript and native code becomes clear. React Native’s New Architecture, introduced in version 0.68, is a significant leap forward, addressing the shortcomings of its predecessor.</p><p>In this article, we’ll explain the new architecture in simple terms and show how it solves some of the long-standing challenges of the old one. Let’s dive in!</p><h3>The Old Architecture</h3><p><em>React Native apps are typically composed of two main parts:</em></p><ol><li><strong>JavaScript Code</strong> : Manages business logic, UI components, and user interactions.</li><li><strong>Native Code: </strong>Handles platform-specific functionality, like native UI components and device APIs.</li></ol><p><em>Execution in the old architecture happened over three threads:</em></p><ul><li><strong>JavaScript Thread</strong>: Runs the JavaScript code using a JavaScript engine (like JavaScriptCore on iOS or Hermes on Android).</li><li><strong>Native/UI Thread</strong>: Manages the user interface, rendering views, handling gestures, etc.</li><li><strong>Shadow Thread</strong>: Handles the layout and positioning of native elements, calculating size and position.</li></ul><p><strong>Issues With the Bridge</strong></p><p><em>The communication between JavaScript and native code is managed by </em><strong><em>The Bridge</em></strong><em>. While this allows communication, it introduces several limitations, especially around performance. The most notable issues are:</em></p><ol><li><strong>Asynchronous Delays</strong>: Communication between JavaScript and native code is asynchronous, meaning JavaScript sends a message, waits for a response, and continues once it gets the answer. This delay can impact performance, especially for real-time tasks like animations.</li><li><strong>Single-threaded JavaScript</strong>: JavaScript code runs on a single thread. This causes bottlenecks for tasks that require heavy computation, such as data processing, which can slow down the app.</li><li><strong>Serialization Overhead</strong>: Data passed between JavaScript and native code must be serialized (converted to JSON) and deserialized (converted back), which adds overhead, especially when transferring large or complex data.</li><li><strong>Threading and Synchronization Issues</strong>: With multiple threads involved (JavaScript, UI, and Shadow), there were synchronization issues, often leading to inconsistent behavior and choppy UI rendering.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/0*ksLJhwInYNCwjq8I.png" /><figcaption>Old Architecture</figcaption></figure><p><strong>The New Architecture: Breaking the Bridge</strong></p><p><em>React Native’s new architecture, introduced in version 0.68, eliminates the bridge and replaces it with the </em><strong><em>JavaScript Interface (JSI)</em></strong><em>. This change dramatically improves performance, reduces overhead, and simplifies communication between JavaScript and native code. Here’s how the new architecture works:</em></p><p><strong>Key Components of the New Architecture:</strong></p><ol><li><strong>Codegen (Native Code Generator)</strong>:</li></ol><ul><li>Generates native code from JavaScript and ensures static type checking for smoother communication.</li><li>Eliminates the need for the old bridge, allowing direct communication between JavaScript and native code.</li></ul><p><strong>2. JSI (JavaScript Interface)</strong>:</p><ul><li>Generates native code from JavaScript and ensures static type checking for smoother communication.</li><li>Eliminates the need for the old bridge, allowing direct communication between JavaScript and native code.</li></ul><p>3. <strong>Hermes Engine</strong>:</p><ul><li>A lightweight, optimized JavaScript engine that reduces app size, memory usage, and startup time.</li><li>Pre-compiles JavaScript code into bytecode for faster execution.</li></ul><p><strong>4. TurboModules</strong>:</p><ul><li>Replaces old Native Modules with a more efficient system using JSI.</li><li>Supports lazy loading, meaning that native modules are loaded only when needed, reducing startup time.</li></ul><p><strong>5. Fabric (New Rendering Engine)</strong>:</p><ul><li>A new UI manager that enhances rendering performance.</li><li>Uses JSI for direct communication with native code, eliminating the bridge.</li></ul><p><strong>6. Yoga (Cross-platform Layout Engine)</strong>:</p><ul><li>Continues to be a key part of the new architecture for handling cross-platform layouts.</li></ul><p><strong>The Two Phases of the New Architecture:</strong></p><p><strong>Phase 1: App Build Time</strong></p><ul><li>Codegen generates native code and static type checks during the build process.</li><li>JavaScript code is compiled into bytecode and packaged with the app.</li></ul><p><strong>Phase 2: App Run Time<br></strong>At runtime, TurboModules and Fabric take over:</p><ul><li>TurboModules load native modules only when required.</li><li>Fabric handles UI rendering and native interactions.</li></ul><p><strong>Key Benefits of the New Architecture:</strong></p><ul><li><strong>Improved Performance</strong>: JSI allows more efficient communication between JavaScript and native code, eliminating the delays caused by the old bridge.</li><li><strong>Faster Startup</strong>: With TurboModules, only necessary modules are loaded, speeding up the app’s startup time.</li><li><strong>Reduced Overhead</strong>: JSI removes the need for serialization and deserialization, improving performance, especially with large or complex data.</li><li><strong>Cross-platform Flexibility</strong>: JSI’s C++ foundation improves compatibility across platforms (iOS, Android, macOS, and Windows).</li></ul><p><strong>Comparison: Old vs. New Architecture</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*iYK1jACnnzB-uUqQ.png" /></figure><p><strong>Real-World Impact</strong></p><p><em>Imagine a weather app that frequently fetches data. In the old architecture, data-heavy tasks could lead to UI lag. With the new architecture, TurboModules and JSI ensure smoother animations and faster updates, providing a native-like experience.</em></p><h3>Migration Path: How to Adopt the New Architecture</h3><ol><li><strong>Enable the New Architecture</strong>: Update your Gradle and Pod configurations.</li><li><strong>Upgrade Native Modules</strong>: Check compatibility with TurboModules.</li><li><strong>Test Extensively</strong>: Ensure there are no performance regressions or edge cases.</li></ol><h3>Challenges to Watch For</h3><ul><li><strong>Library Support</strong>: Some third-party libraries may not yet support the new architecture.</li><li><strong>Learning Curve</strong>: Developers will need to familiarize themselves with new concepts like JSI and TurboModules.</li></ul><h3>Future-Proofing with the New Architecture</h3><p>This new architecture is not just about performance; it’s about positioning React Native for future growth. It aligns React Native with modern concurrent features from React and sets the stage for scalable, enterprise-level apps.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*wq0HRr2VJqZt_uSP.png" /><figcaption>New Architecture</figcaption></figure><h3>Final Thoughts</h3><p>React Native’s new architecture marks a significant advancement in performance, scalability, and flexibility. By addressing critical pain points of the previous architecture, it simplifies the process of building high-performance mobile applications. Whether you’re creating a small app or tackling an enterprise-level project, adopting this new architecture can greatly enhance both the user experience and the development workflow.</p><p>Ready to build faster, more efficient apps with React Native? Explore the new architecture today and unlock its full potential!</p><p>Give this blog a clap if it helped you. 👏👏👏👏</p><p>❤❤ Thanks for reading!!! ❤❤</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=20b166759527" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SSL Pinning with Flutter]]></title>
            <link>https://medium.com/@MarvelApps_/ssl-pinning-with-flutter-e0aa8f3eeaf7?source=rss-38384c210b06------2</link>
            <guid isPermaLink="false">https://medium.com/p/e0aa8f3eeaf7</guid>
            <category><![CDATA[ssl-pinning]]></category>
            <category><![CDATA[mobile-app-security]]></category>
            <category><![CDATA[marvel-app]]></category>
            <category><![CDATA[dart]]></category>
            <category><![CDATA[flutter]]></category>
            <dc:creator><![CDATA[Marvel Apps]]></dc:creator>
            <pubDate>Wed, 20 Nov 2024 12:55:36 GMT</pubDate>
            <atom:updated>2024-11-20T12:55:36.120Z</atom:updated>
            <content:encoded><![CDATA[<p>In today’s digital aspect, security is important, especially when it comes to mobile applications. One essential security technique to protect data in transfer is SSL pinning. This blog will explore what SSL Certificate and SSL pinning are, why SSL pinning is important, and how it can be implemented effectively.</p><h3>What is an SSL Certificate?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/0*LhAUbYmkwAhcqVGA.png" /></figure><p>An SSL(Secure Socket Layer) Certificate is an cryptographic digital certificate that ensures encrypted and secure communication between web server and client by authenticating the identity of a website or server.</p><p>SSL certificates are issued by certificate authority (CA). A CA is an outside organization, a trusted third party, that generates and gives out SSL certificates.</p><h3>What are the elements of SSL Certificate?</h3><ol><li>Domain Name</li><li>Organization Name</li><li>Issuing authority name</li><li>Authority’s digital signature</li><li>Associated subdomains</li><li>Date of issue</li><li>Expiration date</li><li>Public key</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*eqgYC4Y1vrNf2ryd.png" /></figure><h3>What is SSL Pinning and its Purpose?</h3><p>SSL Pinning is a security technique used to ensure that an application communicates with a legitimate server by validating the server’s SSL certificate.It’s purpose is to ensure that the app communicates with the intended server by verifying the server’s identity.</p><p>This means that when the application attempts to establish a secure connection with the server, it will verify the server’s certificate against the pinned certificate or public key. If the certificate presented by the server does not match the pinned one, the connection is refused, and the communication does not proceed.</p><h3>Why SSL Pinning is Important?</h3><ol><li><strong>Preventing MITM Attacks</strong>: SSL pinning prevents attackers from using fake certificates to intercept and manipulate the data being transmitted between the app and the server.</li><li><strong>Ensuring Data Integrity</strong>: By ensuring that the application only communicates with the intended server, SSL pinning helps maintain the integrity of the data being exchanged.</li><li><strong>Enhancing User Trust</strong>: Users are more likely to trust applications that employ strong security measures, including SSL pinning, as it protects their sensitive information.</li></ol><h3>How SSL Pinning Works?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*tBF0iLK4caReN6dR" /></figure><ol><li>The client application sends a connection request to the server, server listens to the request. ​</li><li>Server gives response including public key and certificate.</li><li>The client checks the certificate against a predefined pinned certificate.</li><li>Verify the Validity of the certificate by confirming the expiration date, the issuer, if the certificate has been revoked, and that the domain in the certificate matches the server domain.</li><li>If the certificate is valid, an encrypted session is created; else, the session connection is terminated.</li><li>Client sends an encrypted session key to the server.</li><li>The server decrypts the session key using the private key and sends the encrypted data back to the client machine.</li><li>Client receives and decrypts the encrypted data using the session key.</li></ol><h3>Types of SSL Pinning</h3><p>There are several types of SSL pinning, and understanding how each works can help you choose the right one for your app . Let’s break them down in simple terms:</p><ol><li><strong>Certificate Pinning: </strong>Certificate pinning involves associating the app with a specific SSL certificate used by the server. When a device tries to connect to the server, it checks if the server’s certificate matches the pinned certificate. If it doesn’t match, the connection is blocked.</li><li><strong>Public Key Pinning: </strong>Public key pinning is similar to certificate pinning but instead of pinning the whole SSL certificate, it pins the public key used in the certificate. This method focuses on the key itself, which is more stable over time compared to certificates that may need to be renewed periodically.</li><li><strong>Dynamic Pinning: </strong>Dynamic pinning involves a more flexible approach, where the app initially performs a regular SSL handshake but also validates that the certificate or public key is from a known source. This method is often paired with a backup mechanism (such as a secondary trusted certificate or key) in case the main certificate/key changes unexpectedly.</li><li><strong>Pinning with Hashes: </strong>Another variation is pinning based on hash values of the SSL certificate or public key. Instead of storing the certificate or key directly, you store the hash value, and the app will compare the hash of the received certificate with the stored one.</li></ol><h3>What are the Disadvantages of SSL Pinning?</h3><ol><li><strong>Maintenance Overhead : </strong>If the server’s certificate changes, the app needs to be updated with the new certificate, which can be cumbersome and prone to errors</li><li><strong>Reduced Flexibility</strong> : SSL pinning can make it more challenging to switch servers or update SSL certificates, as each change requires an update to the app.</li><li><strong>Revocation Issues : </strong>If a web server SSL certificate is revoked, then the app will not be able to communicate with the web server until and unless a new SSL certificate created and updated to app.</li></ol><h3>Best Practices</h3><ul><li><strong>Ensure correct pin management : </strong>Pin management is crucial to ensure that the SSL pinning mechanism continues to function correctly.</li><li><strong>Regular updates and testing : </strong>Regularly update your pinned certificates or public keys to reflect any changes, such as certificate renewals.</li><li><strong>Plan for Certificate Expiration : </strong>Keep track of the expiration dates of your pinned certificates or keys. Plan ahead to update your pins well before the certificates expire.</li><li><strong>Secure the Pinning Information : </strong>Ensure that the pinning information (i.e., the pinned certificates or public keys) is stored securely within the application.</li><li><strong>Be Careful with Error Handling : </strong>When a pinning check fails, the application should handle the error gracefully. This might mean providing a clear error message to the user, rather than simply crashing or refusing to connect.</li></ul><h3>Implementation</h3><h3>Step 1: Import Certificate from Website</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*LNjvHKJyomg1leY9.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/0*ly-zbT4pgOhinNJT.gif" /></figure><h3>Step 2 : Add certificate.pem into pubspec.yaml</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*kS_EOnMANbQNGXAW" /></figure><h3>Step 3 :Add following code in main.dart</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*F0Tp85BnXlqdfjpV.png" /></figure><h3>Step 4: Create Api Service Class</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*irVc026Qw0qgAymA.png" /></figure><p>After this just run the application and you will be able to see final result like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/0*SCZAfTD5DBKAl79h" /></figure><p>If I got something wrong? Let me know in the comments. I would love to improve.</p><p>Don’t forget to clap 👏 If this article helps you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e0aa8f3eeaf7" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>