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

push-native-expo

v1.0.2

Published

本 SDK 专为 Expo (Managed / Bare Workflow) 项目设计,用于获取原生推送令牌(FCM/APNs)并自动上报到统一推送后端。

Readme

Push Native System - Expo SDK

本 SDK 专为 Expo (Managed / Bare Workflow) 项目设计,用于获取原生推送令牌(FCM/APNs)并自动上报到统一推送后端。

🌟 特点

  • 绕过 Expo 服务: 直接获取原生设备令牌,不依赖 expo-push-server
  • 自动上报: 封装了权限请求、Token 获取及后端 API 调用。
  • TypeScript 支持: 完整的类型定义。

📦 安装

pnpm add push-native-expo

🚀 全栈集成步骤

为了使推送系统正常工作,您需要完成以下全栈配置:

1. 后端证书准备

在您的服务器端(Next.js 项目)中,必须配置 Firebase Admin 私钥。

  • 获取方式:Firebase 控制台 -> 项目设置 -> 服务帐号 -> 生成新的私钥。
  • 放置位置:将下载的 JSON 重命名为 firebase-service-account.json 放入后端根目录。

2. 配置 Expo 权限 (app.json)

确保在 app.json 中配置了对应的推送权限:

{
  "expo": {
    "plugins": [
      [
        "expo-notifications",
        {
          "icon": "./assets/notification-icon.png",
          "color": "#ffffff"
        }
      ]
    ]
  }
}

2. 初始化并注册设备

在 App 入口处或登录成功后调用:

import { PushSdk } from 'push-native-expo';

const pushSdk = new PushSdk({
  baseUrl: 'https://your-push-api.com', // 仅填写域名,无需 /api 路径
  userId: 'user-123' // 可选,用于绑定推送用户
});

// 设置通知行为(前台显示等)
PushSdk.setNotificationHandler();

// 初始化并自动上报设备信息
pushSdk.initAndRegister().then(res => {
  if (res.code === 0) {
    console.log('Push device registered successfully');
  } else {
    console.error('Push registration failed:', res.message);
  }
});

⚠️ 注意事项

  • 必须使用物理设备: 推送功能无法在模拟器上运行。
  • 原生配置:
    • Android: 需在 Firebase 控制台下载 google-services.json 并在 app.json 中配置。
    • iOS: 需在 Apple Developer 中心配置推送证书(P8 文件)。