@armanatz/expo-hms-location

中文文档
1.0.3发布于 2025/01/07MITTypeScriptCommonJS零依赖近 30 天下载 2382

Expo config plugin to configure @hmscore/react-native-hms-location on prebuild

原始使用文档
文档目录6 节
  1. Compatibility
  2. Prerequisites
  3. Installation
  4. Configuration
  5. Post Configuration
  6. Changes Made By This Plugin

@armanatz/expo-hms-location

This Expo config plugin auto-configures @hmscore/react-native-hms-location so that is can be used inside an Expo application that uses Continuous Native Generation.

Compatibility

This plugin is currently only for Android and there are no plans to add iOS support at the moment. I am open to PRs however so feel free to create one if you need iOS support.

This plugin was written and tested against Expo SDK 51. It should work with later versions of Expo unless they change something internally. If it doesn't work for versions past 51, leave an issue and I will look into it.

It goes without saying but this plugin cannot be used in an "Expo Go" app as it requires custom native code.

Prerequisites

Ensure that you have a Huawei AppGallery Connect account and have created an Android project in there before using this plugin.

This is needed because you will require the agconnect-services.json file associated to your project.

Installation

First install the base React Native HMS Location package:

npm install --save @hmscore/react-native-hms-location

Then install this plugin:

npx expo install @armanatz/expo-hms-location

Configuration

Add @armanatz/expo-hms-location to your app's Expo config file (app.json, or app.config.js).

The plugin exposes the following options:

OptionTypeDescription
agConnectServicesFilestringPath to your agconnect-services.json file.
isBackgroundLocationEnabledboolean(Optional) Enable location service in the background
enableBouncyCastleFixboolean(Optional) If you get errors related to org.bouncycastle (like when using expo-updates), then set this to true

!! IMPORTANT !!: The option agConnectServicesFile has to be provided, otherwise the prebuild will fail.


Example configuration:

"expo": {
  ...
  "plugins": [
      [
        "@armanatz/expo-hms-location",
        {
          "agConnectServicesFile": "./path/to/agconnect-services.json",
          "isBackgroundLocationEnabled": true,
          "enableBouncyCastleFix": true
        }
      ]
  ]
}

Post Configuration

After adding the plugin to your Expo config file, ensure you rebuild your app by running prebuild so that the plugin can apply its changes accordingly.

If all goes well, your app should now be able to use the @hmscore/react-native-hms-location package inside your Expo application.

Changes Made By This Plugin

  1. Copies your agconnect-services.json file to the android/app directory
  2. Extracts the App ID of your application from the agconnect-services.json
  3. Sets extracted App ID in AndroidManifest.xml
  4. Adds relevant location permissions in AndroidManifest.xml as per Huawei's docs
  5. Adds the Huawei Developer Maven repo to the project's build.gradle file
  6. Pins the Android Gradle Build Tools version to 8.6.0 (This is needed because the Huawei SDKs cause build errors without it)
  7. Adds the Huawei AGCP SDK to the project's build.gradle file
  8. Applies the Huawei AGConnect plugin inside the app's build.gradle file
  9. Adds the Huawei Location Kit SDK to the app's build.gradle file
  10. If enableBouncyCastleFix is set to true, will resolve org.bouncycastle dependency

版本与发布记录

@armanatz/expo-hms-location 共发布 4 个版本,首次发布于 2024/09/18;过去 12 个月发布了 0 个版本。

版本发布日期距今
1.0.3latest2025/01/071.8 年前
1.0.22024/10/242 年前
1.0.12024/09/182 年前
1.0.02024/09/182 年前

关于 @armanatz/expo-hms-location 的常见问题

@armanatz/expo-hms-location 是什么?

Expo config plugin to configure @hmscore/react-native-hms-location on prebuild

如何安装 @armanatz/expo-hms-location?

在项目目录运行 npm install @armanatz/expo-hms-location,或使用 pnpm add / yarn add / bun add。

@armanatz/expo-hms-location 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@armanatz/expo-hms-location 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@armanatz/expo-hms-location 可以商用吗?

@armanatz/expo-hms-location 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@armanatz/expo-hms-location 的下载量有多少?

根据 npm 官方下载统计,@armanatz/expo-hms-location 在 2026/10/07 – 2026/11/05 这 30 天内被下载 2,382 次,日均约 79 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@armanatz/expo-hms-location 还在维护吗?

最新版本 1.0.3 发布于 2025/01/07(1.8 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2024/09/18。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。