@a.abunada/expo-location 中文文档教程

发布于 4年前 浏览 23 项目主页 更新于 3年前

expo-location

允许从设备读取地理位置信息。 您的应用可以轮询当前位置或订阅位置更新事件。

API documentation

Installation in managed Expo projects

对于托管 托管 Expo 项目,请按照 最新稳定版本的 API 文档

Installation in bare React Native projects

对于裸 React Native 项目,您必须确保已安装并配置了 react -native-unimodules package 在继续之前。

Add the package to your npm dependencies

expo install expo-location

Configure for iOS

NSLocationAlwaysAndWhenInUseUsageDescriptionNSLocationAlwaysUsageDescriptionNSLocationWhenInUseUsageDescription 键添加到您的 Info.plist

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>

运行 npx pod-install< /code> 安装 npm 包后。

Configure for Android

此模块需要获得大致和准确设备位置的权限。 它还需要前台服务权限才能在使用该应用程序时订阅位置更新。 这些权限是自动添加的。

<!-- Added permissions -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Contributing

非常欢迎投稿! 请参阅贡献指南中描述的指南。

expo-location

Allows reading geolocation information from the device. Your app can poll for the current location or subscribe to location update events.

API documentation

Installation in managed Expo projects

For managed managed Expo projects, please follow the installation instructions in the API documentation for the latest stable release.

Installation in bare React Native projects

For bare React Native projects, you must ensure that you have installed and configured the react-native-unimodules package before continuing.

Add the package to your npm dependencies

expo install expo-location

Configure for iOS

Add NSLocationAlwaysAndWhenInUseUsageDescription, NSLocationAlwaysUsageDescription and NSLocationWhenInUseUsageDescription keys to your Info.plist:

<key>NSLocationAlwaysAndWhenInUseUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>
<key>NSLocationAlwaysUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>Allow $(PRODUCT_NAME) to use your location</string>

Run npx pod-install after installing the npm package.

Configure for Android

This module requires the permissions for approximate and exact device location. It also needs the foreground service permission to subscribe to location updates, while the app is in use. These permissions are automatically added.

<!-- Added permissions -->
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION" />
<uses-permission android:name="android.permission.FOREGROUND_SERVICE" />

Contributing

Contributions are very welcome! Please refer to guidelines described in the contributing guide.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文