npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@expo-harmony/expo-tracking-transparency

v57.0.2-harmony.1

Published

HarmonyOS port of expo-tracking-transparency

Readme

@expo-harmony/expo-tracking-transparency

GitHub 仓库 | 官方文档

为 HarmonyOS 上的 React Native 应用提供 Expo Tracking Transparency 的原生实现,与官方 expo-tracking-transparency 配套使用。

安装

本包适配 Expo SDK 57。

引入本包前,需要确保应用使用的 HarmonyOS SDK 至少为 API 13(HarmonyOS 5.0.1)。

npm install @expo-harmony/expo-tracking-transparency expo-tracking-transparency@~57.0.2

API 对照表

Hooks

TrackingTransparency.useTrackingPermissions(options?)

options 可选,类型为 PermissionHookOptions。get 默认为 true,表示挂载时查询权限;request 默认为 false,设为 true 时挂载后请求权限。返回 [PermissionResponse | null, requestPermission, getPermission],后两个方法分别请求和查询权限。

Methods

TrackingTransparency.getTrackingPermissionsAsync()

无参数,返回 Promise<PermissionResponse>,查询跨应用跟踪权限状态,不显示授权对话框。响应的 expires 始终为 'never'。

HarmonyOS SDK API 20 及以上可直接查询完整权限状态。API 13–19 未授权时,根据此前请求权限的结果区分 denied 与 undetermined;如果用户在系统设置中修改了权限,状态可能无法准确区分。

TrackingTransparency.requestTrackingPermissionsAsync()

无参数,返回 Promise<PermissionResponse>,请求跨应用跟踪权限。已授权或系统明确禁止再次请求时,直接返回当前状态。其他情况下由系统处理请求。用户拒绝或系统不再允许请求后,canAskAgain 为 false。并发调用共用一次请求结果。

TrackingTransparency.isAvailable()

无参数,返回 boolean。HarmonyOS 检查设备是否支持系统 OAID 服务。此查询不会请求权限。设备缺少该服务时,权限查询和请求返回 denied 且 canAskAgain 为 false,异步读取返回 null。

TrackingTransparency.getAdvertisingId()

接口签名返回 string | null,无参数。

  • HarmonyOS 只提供异步 OAID 读取;调用此方法会以 ERR_UNAVAILABLE 抛出,请改用 getAdvertisingIdAsync()。

getAdvertisingIdAsync()

从 @expo-harmony/expo-tracking-transparency 导入。无参数,返回 Promise<string | null>。获得权限时读取 OAID;未授权、标识符为空或全零时返回 null。读取期间权限被撤回时也返回 null。读取失败且权限仍有效时,Promise 以 ERR_TRACKING_TRANSPARENCY_ADVERTISING_ID 拒绝。

Types

PermissionResponse

权限查询和请求方法的返回类型,包含 status、granted、canAskAgain 和 expires。status 为 PermissionStatus;granted 表示是否已授权;canAskAgain 表示是否还能再次请求;HarmonyOS 上 expires 始终为 'never'。

PermissionExpiration

权限过期时间类型。HarmonyOS 上该权限长期有效,取值为 'never'。

PermissionHookOptions

传给 useTrackingPermissions 的选项:get?: boolean 控制挂载时是否查询权限,默认 true;request?: boolean 控制挂载时是否请求权限,默认 false。

Enums

PermissionStatus

| 成员 | 值 | 含义 | | --- | --- | --- | | GRANTED | 'granted' | 已授权 | | DENIED | 'denied' | 已拒绝 | | UNDETERMINED | 'undetermined' | 尚未决定 |

Error codes

ERR_TRACKING_TRANSPARENCY_BACKGROUND

尚可请求授权时,应用未处于前台或没有界面会以此错误码拒绝。

ERR_TRACKING_TRANSPARENCY_PERMISSION

宿主应用未声明有效的 ohos.permission.APP_TRACKING_CONSENT,或系统无法处理该权限请求时,查询或请求会以此错误码拒绝。

ERR_TRACKING_TRANSPARENCY_ADVERTISING_ID

读取 OAID 失败且跨应用跟踪权限仍有效时,getAdvertisingIdAsync() 以此错误码拒绝。

ERR_UNAVAILABLE

HarmonyOS 不支持同步的 getAdvertisingId(),调用时会以此错误码抛出。

Permissions

ohos.permission.APP_TRACKING_CONSENT

此权限是普通用户授权权限。使用跟踪功能的宿主应用需在入口模块的 module.json5 声明权限,填写授权用途 reason 和 usedScene.abilities,并将使用时机设为 inuse。未声明或声明无效时,支持 OAID 的设备上的权限查询和请求会以 ERR_TRACKING_TRANSPARENCY_PERMISSION 拒绝。未授权时,getAdvertisingIdAsync() 返回 null。系统设置中的「要求应用请求关联」开关会影响授权对话框的显示,关闭时系统可能直接授予权限。 华为 OAID 接入文档

Author

expo-harmony © Baoshuo, Released under the MIT License. Authored and maintained by Baoshuo with help from contributors.

Personal Website · Blog · GitHub @renbaoshuo · Twitter @renbaoshuo