Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-google-places-compat

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-google-places-compat

An update of react-native-google-places library, brings compatibility with newer React Native version (0.71.x). It addresses dependency and compatibility issues, ensuring seamless integration with Google Places API for React Native projects.

  • 0.2.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

react-native-google-places-compat

An update of react-native-google-places library, brings compatibility with newer React Native version (0.71.x). It addresses dependency and compatibility issues, ensuring seamless integration with Google Places API for React Native projects.

Installation

npm install react-native-google-places-compat

Usage

Initialize the Google Places Client

Start by initializing the Google Places client with your Places SDK API key. Refer to the Places SDK documentation for initial setup instructions. It's important to restrict your key usage as detailed here. Replace "your-ios-api-key" and "your-android-api-key" with your actual API keys.

  RNGooglePlacesCompat.initializePlaceClient(
    Platform.OS === 'ios'
      ? "your-ios-api-key"
      : "your-android-api-key"
  );

Interacting with the Google Places API

Once initialized, you can use the following methods to interact with the Google Places API:

  RNGooglePlacesCompat.openAutocompleteModal()
  RNGooglePlacesCompat.getAutocompletePredictions()
  RNGooglePlacesCompat.getCurrentPlace()
  RNGooglePlacesCompat.lookUpPlaceByID()

Managing API Costs with Session Tokens

If you use getAutocompletePredictions utilize session tokens to optimize API costs. Start a new session before making autocomplete predictions and end it when you're finished to avoid unnecessary charges. Only fetching place details will incur a cost. Learn more about session tokens here, and for details on usage and billing, read here.

  RNGooglePlacesCompat.beginAutocompleteSession();
  // RNGooglePlacesCompat.getAutocompletePredictions();
  // ... more prediction calls
  // End the session by calling
  RNGooglePlacesCompat.endAutocompleteSession();

You can keep track of the session via - RNGooglePlacesCompat.isAutoCompleteSessionStarted()

Refer examples in the example directory for more details.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Made with create-react-native-library

Keywords

FAQs

Package last updated on 07 Mar 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc