Open google Navigation directly in React Native. (android)

Image for post
Image for post
Image for post
Image for post
Google Maps
yarn add react-native-send-intent

openMaps

This will help you with opening the google app with a latitude and longitude, and it receives just query, you can learn about the query from the official page

SendIntentAndroid.openMaps("Piccadilly Circus Station, London, United Kingdom");
SendIntentAndroid.openMaps("40.730610, -73.935242");

openMapsWithRoute

This helper function will help you open the navigation directly instead of opening the app; therefore, you start your journey as fast as you execute the function.

SendIntentAndroid.openMapsWithRoute('40.730610, -73.935242', 'd'),
SendIntentAndroid.openMapsWithRoute('Piccadilly Circus Station, London, United Kingdom', 'd'),

How to open your app again after reaching the destination?

Well, you can start up a foreground service (Simple Foreground Service), and try to get the location in the headless task, and set up a geofence, so when the destination distance from the locations falls into the minimum given, it should Start your app back with.

SendIntentAndroid.SendIntentAndroid.openApp("com.Your.app.BundlerName").then(wasOpened => {});

Written by

A Resident of the Javascript Rockstar world. I like to write about problems and their solution that I face in my life. I code because is I am good at it.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store