This contains a sample application to showcase the functionality of the NavSDK library for React Native.
-
First, make sure you go through the setup from the main README.
-
Run this command
npm install react-native
from the root of SampleApp folder. This will generate thenode_modules
from this sample app.- In case you get a
Permission denied (publickey).
error here, make sure that you have authenticated with Github in your terminal.
- In case you get a
-
Run this in SampleApp's root directory:
npm install --save https://github.com/googlemaps/react-native-navigation-sdk
-
Open the SampleApp/android folder in Android Studio and add your api key in local.properties by adding a line like this:
MAPS_API_KEY=YOUR_API_KEY
- make sure that this key is pointing to a Google Cloud project which had Nav SDK enabled.- To enable Nav SDK in your project follow these guides:
-
Using your preferred terminal, go to SampleApp/ios folder and run the command below.
pod install
-
In your Google cloud console, add the Google API key to the project. Add this newly created API key to the Info.plist file inside
SampleApp/ios/SampleApp/
.<key>API_KEY</key> <string>Your API KEY</string>
-
To run the sample app, go to the root folder of the sample app and run the command below according to platform using your preferred terminal.
- Running in Android:
npx react-native run-android
- Running in iOS:
npx react-native run-ios
- Running in Android:
-
After the app initializes, accept the terms of services. You should see a map loaded in background if you have used the right API key.
-
On your Emulator, go to App Info for the installed app, then Permissions > Location and allow location for the app.
-
Restart the app, now the Navigation view should be displayed instead of the map.