<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Suraj Prasad</title>
    <description>The latest articles on DEV Community by Suraj Prasad (@surajprasad13).</description>
    <link>https://dev.to/surajprasad13</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F393392%2F19195ec9-ee60-4b56-84a3-048dbed72bb4.jpeg</url>
      <title>DEV Community: Suraj Prasad</title>
      <link>https://dev.to/surajprasad13</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/surajprasad13"/>
    <language>en</language>
    <item>
      <title>Creating Dynamic Links and Deep Linking URLs in Node.js for React Native</title>
      <dc:creator>Suraj Prasad</dc:creator>
      <pubDate>Mon, 05 Aug 2024 15:57:41 +0000</pubDate>
      <link>https://dev.to/surajprasad13/creating-dynamic-links-and-deep-linking-urls-in-nodejs-for-react-native-175d</link>
      <guid>https://dev.to/surajprasad13/creating-dynamic-links-and-deep-linking-urls-in-nodejs-for-react-native-175d</guid>
      <description>&lt;p&gt;In the mobile app ecosystem, providing a seamless user experience is critical. One way to enhance this is by implementing deep links and dynamic links within your app. Dynamic links allow you to share content and ensure users have a smooth transition whether they have your app installed or not. In this blog, we'll explore how to create dynamic links and deep linking URLs using Node.js for a React Native application.&lt;br&gt;
What Are Dynamic Links and Deep Links?&lt;br&gt;
Deep Links: These are URLs that take users to a specific part of your app. When users click on a deep link, the app opens to the specific content the link is meant to display. If the app is not installed, the link typically opens the web version of the app or a fallback page.&lt;br&gt;
Dynamic Links: These are deep links with added flexibility. They can change their behavior based on different conditions, such as whether the app is installed, the platform (iOS or Android), or even the context in which the link is opened (e.g., marketing campaigns).&lt;/p&gt;

&lt;p&gt;Why Use Dynamic Links?&lt;br&gt;
Cross-Platform Compatibility: Dynamic links work on multiple platforms, including iOS, Android, and web.&lt;br&gt;
Deferred Deep Linking: If the app isn't installed, dynamic links can direct users to the app store and then to the specific content once the app is installed.&lt;br&gt;
Enhanced User Experience: They provide a more personalized experience by directing users to the right content within your app.&lt;/p&gt;

&lt;p&gt;Prerequisites&lt;br&gt;
Before we dive in, make sure you have the following:&lt;br&gt;
Node.js installed on your machine.&lt;br&gt;
A React Native project setup.&lt;br&gt;
Firebase account (optional, but recommended for generating dynamic links).&lt;/p&gt;
&lt;h2&gt;
  
  
  Step 1: Setting Up a Node.js Server
&lt;/h2&gt;

&lt;p&gt;We'll start by setting up a Node.js server that will generate dynamic links. You can use Express.js to create a simple server.&lt;br&gt;
First, create a new Node.js project:&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir dynamic-links-server
cd dynamic-links-server
npm init -y
npm install express shortid
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 2: Generating Dynamic Links
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const express = require("express");
const shortId = require("shortid")

const { appendSeoDetail } = require("./utils");
const app = express()

const PORT = process.env.PORT || 3000

app.use(express.json())
app.use("/.well-known", express.static('.well-known'))

const urls = {};

app.post("/create-url", (req, res) =&amp;gt; {
  try {
    const { title, description, image, newsId } = req.body
    const previewUrl = `https://3a09-2402-4cc0-2501-1f4-71ad-7a58-7a4c-895c.ngrok-free.app/?newsId=${newsId}&amp;amp;title=${encodeURIComponent(title)}&amp;amp;description=${encodeURIComponent(description)}&amp;amp;image=${encodeURIComponent(image)}`
    const id = shortId.generate();
    urls[id] = previewUrl;
    res.send({ url: `https://3a09-2402-4cc0-2501-1f4-71ad-7a58-7a4c-895c.ngrok-free.app/${id}` })
  } catch (error) {
    res.send({ error: "Something went wrong" })
  }
})

app.get('/:id', (req, res) =&amp;gt; {
  const id = req.params.id;
  const url = urls[id];

  if (url) {
    res.redirect(url);
  } else {
    res.sendStatus(404);
  }
});

app.get('*', (req, res,) =&amp;gt; {
  const { title, description, image } = req.query
  // Define values
  const source = appendSeoDetail({ title, description, image })
  // Return the webpage
  return res.send(source);
});

app.listen(PORT, () =&amp;gt; {
  console.log("App is running on ", PORT)
})
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 3: Creating index html for the social share preview
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
 &amp;lt;head&amp;gt;
  &amp;lt;!-- HTML Meta Tags --&amp;gt;
  &amp;lt;title&amp;gt;{{title}}&amp;lt;/title&amp;gt;
  &amp;lt;meta name="description" content="{{description}}" /&amp;gt;

  &amp;lt;!-- Facebook Meta Tags --&amp;gt;
  &amp;lt;meta property="og:url" content="https://3a09-2402-4cc0-2501-1f4-71ad-7a58-7a4c-895c.ngrok-free.app/" /&amp;gt;
  &amp;lt;meta property="og:type" content="website" /&amp;gt;
  &amp;lt;meta property="og:title" content="{{title}}" /&amp;gt;
  &amp;lt;meta property="og:description" content="{{description}}" /&amp;gt;
  &amp;lt;meta property="og:image" content="{{image}}" /&amp;gt;

  &amp;lt;!-- Twitter Meta Tags --&amp;gt;
  &amp;lt;meta name="twitter:card" content="summary_large_image" /&amp;gt;
  &amp;lt;meta property="twitter:domain" content="3a09-2402-4cc0-2501-1f4-71ad-7a58-7a4c-895c.ngrok-free.app" /&amp;gt;
  &amp;lt;meta property="twitter:url" content="https://3a09-2402-4cc0-2501-1f4-71ad-7a58-7a4c-895c.ngrok-free.app/" /&amp;gt;
  &amp;lt;meta name="twitter:title" content="{{title}}" /&amp;gt;
  &amp;lt;meta name="twitter:description" content="{{description}}" /&amp;gt;
  &amp;lt;meta name="twitter:image" content="{{image}}" /&amp;gt;

  &amp;lt;!-- Meta Tags Generated via https://www.opengraph.xyz --&amp;gt;

  &amp;lt;link
   rel="stylesheet"
   href="https://cdn.jsdelivr.net/npm/bootstrap@4.0.0/dist/css/bootstrap.min.css"
   integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm"
   crossorigin="anonymous"
  /&amp;gt;

  &amp;lt;script
   src="https://cdnjs.cloudflare.com/ajax/libs/Detect.js/2.2.2/detect.min.js"
   rossorigin="anonymous"
   referrerpolicy="no-referrer"
  &amp;gt;&amp;lt;/script&amp;gt;
 &amp;lt;/head&amp;gt;

 &amp;lt;body&amp;gt;
  &amp;lt;div class="container pt-3"&amp;gt;
   &amp;lt;div class="text-center row justify-content-center"&amp;gt;
    &amp;lt;div class="col-10"&amp;gt;
     &amp;lt;a href="#"&amp;gt;
      &amp;lt;img src="https://www.pouch.news/cropped-pulse%201.png" class="img-fluid" alt="" /&amp;gt;
     &amp;lt;/a&amp;gt;
    &amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
   &amp;lt;div class="centered row mt-3 justify-content-center align-items-center"&amp;gt;
    &amp;lt;div class="col-md-3 col-10 text-center"&amp;gt;
     &amp;lt;p id="message"&amp;gt;&amp;lt;/p&amp;gt;
     &amp;lt;p id="redirectMessage text-center d-none d-md-block"&amp;gt;Redirecting you to Example app.&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
  &amp;lt;/div&amp;gt;
 &amp;lt;/body&amp;gt;

 &amp;lt;script&amp;gt;
  // Function to check if it's an Android device
  function isAndroid() {
   return navigator.userAgent.match(/Android/i)
  }

  // Function to check if it's an iOS device
  function isiOS() {
   return navigator.userAgent.match(/iPhone|iPad|iPod/i)
  }

  // Function to check if it's a desktop
  function isDesktop() {
   return window.innerWidth &amp;gt; 768 // Adjust the width threshold as needed
  }

  // Function to redirect to a website
  function redirectToWebsite() {
   window.location.href = "https://www.example.com/" // Replace with your desired URL
  }

  // Function to redirect to the Google Play Store
  function redirectToPlayStore() {
   window.location.href =
    "intent://details?id=com.example#Intent;scheme=market;package=com.example;end"
  }

  // Function to redirect to the App Store
  function redirectToAppStore() {
   window.location.href = "itms-apps://itunes.apple.com/app/appid2323" // Replace with your app's App Store URL
  }

  // Check the device type and display the appropriate message
  if (isDesktop()) {
   redirectToWebsite()
  } else if (isAndroid()) {
   document.getElementById("message").textContent =
    "We are redirecting you to the examplemobile app for Android."
   setTimeout(redirectToPlayStore, 3000) // Redirect after 3 seconds
  } else if (isiOS()) {
   document.getElementById("message").textContent = "We are redirecting you to the examplemobile app for iOS."
   setTimeout(redirectToAppStore, 3000) // Redirect after 3 seconds
  }
 &amp;lt;/script&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 4: Creating utils for the appending dynamic seo title
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const path = require("path")
const fs = require("fs");

function appendSeoDetail({ title, description, image }) {
  const _title = title ?? 'POUCH - Packaging News App';
  const _subtitle = description ?? 'Pouch is a news aggregator application for the Packaging industry that summarises news articles and stories sourced from various third-party links including industry journals, expert blogs, and innovative company releases';
  const _image = image ?? 'https://www.pouch.news/cropped-pulse%201.png';

  // Load HTML template
  const templatePath = path.join(__dirname, '../index.html');

  // Replace handles with content
  var source = fs.readFileSync(templatePath, { encoding: 'utf-8' })
    .replaceAll('{{title}}', _title)
    .replaceAll('{{description}}', _subtitle)
    .replaceAll('{{image}}', _image);

  return source
}

module.exports = { appendSeoDetail }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 5: Make a .well-know folder and insert files for
&lt;/h2&gt;

&lt;p&gt;assetlinks.json and apple-app-site-association&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
  "applinks": {
    "details": [
      {
        "appIDs": [
          "EXDFF##.com.example"
        ],
        "paths": [
          "*"
        ]
      }
    ]
  },
  "webcredentials": {
    "apps": [
      "EXDFF##.com.example"
    ]
  }
}
[
  {
    "relation": [
      "delegate_permission/common.handle_all_urls"
    ],
    "target": {
      "namespace": "android_app",
      "package_name": "com.example",
      "sha256_cert_fingerprints": [
        "9B:83:32:66:75:91:03:3B:9C"
       ]
    }
  }
]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Step 7: Integrating Deep Links in React Native
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const linking = {
  prefixes: ["example://", "https://3a09-2402-4cc0-2501-1f4-71ad-7a58-7a4c-895c.ngrok-free.app"],
  config,
  async getInitialURL() {
   const url = await Linking.getInitialURL()

   console.log(url, "Dynamic url")

   if (typeof url === "string") {
    return url
   }
js 
  },
 }

&amp;lt;NavigationContainer ref={navigationRef} linking={linking}&amp;gt;

&amp;lt;/NavigationContainer&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;div class="crayons-card c-embed text-styles text-styles--secondary"&gt;
      &lt;div class="c-embed__cover"&gt;
        &lt;a href="https://reactnavigation.org/docs/deep-linking/" class="c-link s:max-w-50 align-middle" rel="noopener noreferrer"&gt;
          &lt;img alt="" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Freactnavigation.org%2Fassets%2Fimages%2Fxcode-linking-9a32c91fae982fab28dc33e7f951e8b3.png" height="auto" class="m-0"&gt;
        &lt;/a&gt;
      &lt;/div&gt;
    &lt;div class="c-embed__body"&gt;
      &lt;h2 class="fs-xl lh-tight"&gt;
        &lt;a href="https://reactnavigation.org/docs/deep-linking/" rel="noopener noreferrer" class="c-link"&gt;
          Deep linking | React Navigation
        &lt;/a&gt;
      &lt;/h2&gt;
        &lt;p class="truncate-at-3"&gt;
          This guide will describe how to configure your app to handle deep links on various platforms. To handle incoming links, you need to handle 2 scenarios:
        &lt;/p&gt;
      &lt;div class="color-secondary fs-s flex items-center"&gt;
          &lt;img alt="favicon" class="c-embed__favicon m-0 mr-2 radius-0" src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Freactnavigation.org%2Fimg%2Ffavicon.ico"&gt;
        reactnavigation.org
      &lt;/div&gt;
    &lt;/div&gt;
&lt;/div&gt;


&lt;p&gt;Conclusion&lt;br&gt;
By setting up dynamic links and deep linking in your React Native app with a Node.js backend, you can significantly enhance the user experience by providing seamless navigation and personalized content. Dynamic links offer a powerful way to ensure that users get to the right content, whether they have your app installed or not.&lt;br&gt;
This setup is not just limited to Firebase. You can use other services like Branch.io or create a custom solution depending on your needs. The principles, however, remain the same: enabling users to move directly to the content they care about.&lt;br&gt;
Happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>How to start mobile app development with React Native Part 1</title>
      <dc:creator>Suraj Prasad</dc:creator>
      <pubDate>Tue, 09 Feb 2021 17:02:31 +0000</pubDate>
      <link>https://dev.to/surajprasad13/how-to-start-mobile-app-development-with-react-native-part-1-364e</link>
      <guid>https://dev.to/surajprasad13/how-to-start-mobile-app-development-with-react-native-part-1-364e</guid>
      <description>&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;If you are new in mobile app development and want to  make carrier in this field then react native is the best for you &lt;/p&gt;

&lt;h1&gt;
  
  
  Lets take a new path
&lt;/h1&gt;

&lt;p&gt;For learning something new starts with zero. First you have to learn Javascript from basic to intermediate level.Here is the best resource you should follow from scratch.&lt;/p&gt;

&lt;h4&gt;
  
  
  W3schools
&lt;/h4&gt;

&lt;p&gt;w3school is the king maker in web development field. You should go through each and every section of javascript at least twice.&lt;/p&gt;

&lt;h4&gt;
  
  
  freecodecamp
&lt;/h4&gt;

&lt;p&gt;in this you should go through javascript section and solve maximum problem as you can &lt;/p&gt;

&lt;h4&gt;
  
  
  React
&lt;/h4&gt;

&lt;p&gt;Learn react from react official documentation page and also w3schools react section you have to grasp deeper knowledge about props, state and lifecycle method&lt;/p&gt;

&lt;h4&gt;
  
  
  Udemy
&lt;/h4&gt;

&lt;p&gt;If you want learn through an instructor then i suggest udemy is the best platform for this section.&lt;br&gt;
i learned react with stephen  grider he is the best teacher in my point of view for react and javascript.&lt;/p&gt;

&lt;h2&gt;
  
  
  Start Journey
&lt;/h2&gt;

&lt;p&gt;If you want to learn new technology the best method is to create projects as you can. This is the part where you have to stay motivated and also keep away from negative thoughts of your mind&lt;br&gt;
Sometimes you feel you can't but trust me you can !&lt;br&gt;
You probably heard sometimes practice makes perfect.&lt;/p&gt;

</description>
      <category>mobile</category>
      <category>reactnative</category>
      <category>hybridapp</category>
      <category>appdevelopment</category>
    </item>
  </channel>
</rss>
