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

react-native-ailink

v0.0.1

Published

AILink broadcast scale React Native module (iOS + Android)

Readme

react-native-ailink

AILink 广播秤(Broadcast Scale)React Native 原生模块,支持 iOSAndroid(RN 0.83.x 可用)。

功能

  • 扫描 AILink 广播秤
  • 解析广播秤数据(体重/阻抗/温度/DID/原始数据)
  • 由 JS 传入算法参数(性别/年龄/身高/算法类型),Native 计算体脂等结果并通过事件回传

安装(本地)

在你的 RN 项目里:

yarn add file:../react-native-ailink

然后执行 pod install(iOS)或重新编译 Android。

iOS 配置(宿主 App)

  1. 在工程中提供 AILinkBleSDK.framework(与 AILinkBleSDKDemo 中使用的同一份)。
  2. Podfilepost_install 中为所有 target 增加该 framework 的搜索路径,例如(按你仓库实际路径调整):
post_install do |installer|
  # ... react_native_post_install 等 ...
  installer.pods_project.targets.each do |target|
    target.build_configurations.each do |config|
      config.build_settings['FRAMEWORK_SEARCH_PATHS'] ||= ['$(inherited)']
      path = '"$(SRCROOT)/../../AILink_ios/AILinkBleSDKDemo"'
      unless config.build_settings['FRAMEWORK_SEARCH_PATHS'].include?(path)
        config.build_settings['FRAMEWORK_SEARCH_PATHS'] << path
      end
    end
  end
end
  1. 在 Xcode 中为 Info.plist 增加蓝牙使用说明(如 NSBluetoothAlwaysUsageDescription),并确保有蓝牙权限。

Android 权限(宿主 App)

宿主 App 需要在运行时申请蓝牙相关权限(Android 12+)以及(Android 11 及以下)定位权限。

推荐使用 react-native-permissions,或你自己用 PermissionsAndroid 申请:

  • android.permission.BLUETOOTH_SCAN
  • android.permission.BLUETOOTH_CONNECT
  • android.permission.ACCESS_FINE_LOCATION(<= Android 11 扫描常需要)

JS 使用示例

import { AilinkBroadcastScale, emitter } from 'react-native-ailink';

const sub = emitter.addListener('broadcastScaleWeight', (e) => {
  console.log('weight', e);
});

emitter.addListener('broadcastScaleBodyFat', (e) => {
  console.log('bodyFat', e);
});

await AilinkBroadcastScale.setAlgorithmParams({
  algorithmType: 0, // 例如 AlgorithmUtil.AlgorithmType.TYPE_AICARE(见 Android 侧常量)
  sex: 1,
  age: 25,
  heightCm: 170,
});
AilinkBroadcastScale.setComputeOptions({ enabled: true, onlyWhenStable: true });

await AilinkBroadcastScale.startScan({ timeoutMs: 0, autoSelectFirst: true });
// ...
await AilinkBroadcastScale.stopScan();
sub.remove();

发布到 npm

  1. 确认包名

    • 当前包名为 react-native-ailink。若该名在 npm 已被占用,可改为 scoped 包,例如 @你的组织/react-native-ailink(在 package.json 里改 name)。
  2. 登录 npm(未登录时)

    npm login

    按提示输入 npm 账号、密码和邮箱。

  3. 选版本号

    • package.json 中改 version(如 0.0.2)。
    • 遵守语义化版本:主版本.次版本.修订号。
  4. 试打包(不发布)

    cd react-native-ailink
    npm pack

    会生成 react-native-ailink-0.0.1.tgz,可解压检查是否包含 index.jsios/android/src 等所需文件。

  5. 发布

    npm publish

    若使用 scoped 包且首次发布为公开包,需加 --access public

    npm publish --access public
  6. 安装方式
    发布成功后,用户可安装:

    yarn add react-native-ailink
    # 或
    npm i react-native-ailink

说明:.npmignore 已排除 android/buildandroid/.gradlepackage.jsonfiles 字段已限定发布内容,避免把构建产物发到 npm。