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

tauri-plugin-fcm

v0.1.9

Published

Tauri 2 plugin for Firebase Cloud Messaging (FCM) — iOS APNs→FCM token exchange + Android FCM

Readme

tauri-plugin-fcm

Crates.io npm License

Firebase Cloud Messaging for Tauri 2 mobile apps.

The plugin returns FCM registration tokens on both iOS and Android. On iOS it handles the APNs to FCM exchange so your app uses one token type across both platforms.

| Platform | Supported | | --- | --- | | Android | Yes | | iOS | Yes | | macOS | No | | Windows | No | | Linux | No |

Install

Add the Rust crate to src-tauri/Cargo.toml:

[dependencies]
tauri-plugin-fcm = "0.1.0"

Install the JavaScript guest bindings:

pnpm add tauri-plugin-fcm
# or
bun add tauri-plugin-fcm
# or
npm add tauri-plugin-fcm
# or
yarn add tauri-plugin-fcm

Register the plugin in your Tauri app:

fn main() {
    let builder = tauri::Builder::default();
    #[cfg(mobile)]
    let builder = builder.plugin(tauri_plugin_fcm::init());

    builder
        .run(tauri::generate_context!())
        .expect("error while running tauri application");
}

Add the capability permission:

{
  "permissions": [
    "fcm:default"
  ]
}

API

import {
  checkPermissions,
  createChannel,
  deleteToken,
  getToken,
  onPushError,
  onTokenRefresh,
  register,
  requestPermissions,
  sendNotification,
} from "tauri-plugin-fcm";

Functions

  • checkPermissions(): Promise<PermissionState>
  • requestPermissions(): Promise<PermissionState>
  • register(): Promise<void>
  • getToken(): Promise<{ token: string }>
  • deleteToken(): Promise<void>
  • createChannel(options: CreateChannelOptions): Promise<void>
  • sendNotification(options: SendNotificationOptions): Promise<void>
  • onTokenRefresh(handler): Promise<PluginListener>
  • onPushError(handler): Promise<PluginListener>

PermissionState comes from @tauri-apps/api/core and can be:

  • granted
  • denied
  • prompt
  • prompt-with-rationale (Android only)

Types

CreateChannelOptions

interface CreateChannelOptions {
  /** Unique identifier for the channel */
  id: string;
  /** Display name for the channel */
  name: string;
  /** Importance level for the channel (0-5) */
  importance: number;
}

SendNotificationOptions

interface SendNotificationOptions {
  /** Notification title */
  title: string;
  /** Notification body text */
  body?: string;
  /** Icon identifier or URL */
  icon?: string;
  /** Notification ID */
  id?: number;
  /** Channel ID (Android) */
  channelId?: string;
}

Usage

Basic Setup

import {
  checkPermissions,
  getToken,
  onPushError,
  onTokenRefresh,
  register,
  requestPermissions,
} from "tauri-plugin-fcm";

let permission = await checkPermissions();

if (permission === "prompt" || permission === "prompt-with-rationale") {
  permission = await requestPermissions();
}

if (permission === "granted") {
  await register();
  const { token } = await getToken();
  console.log("FCM token:", token);
}

const tokenListener = await onTokenRefresh((event) => {
  console.log("New FCM token:", event.token);
});

const errorListener = await onPushError((event) => {
  console.error("Push error:", event.error);
});

// Later:
await tokenListener.unregister();
await errorListener.unregister();

Sending Notifications

import { createChannel, sendNotification } from "tauri-plugin-fcm";

// Create a notification channel (Android only, no-op on iOS)
await createChannel({
  id: "default",
  name: "Default Notifications",
  importance: 4,
});

// Send a notification
await sendNotification({
  title: "Hello",
  body: "This is a test notification",
  channelId: "default",
});

Platform setup

iOS

  1. Add GoogleService-Info.plist to your generated iOS project under src-tauri/gen/apple/<app-name>_iOS/ and make sure it is included in the iOS app target.
  2. Enable the aps-environment entitlement.
  3. Enable Push Notifications and Background Modes with Remote notifications.
  4. If you disable FirebaseAppDelegateProxyEnabled, make sure APNs callbacks still reach Firebase.

Android

  1. Add google-services.json to src-tauri/gen/android/app.
  2. Apply the Google Services Gradle plugin in the Android app.
  3. Keep POST_NOTIFICATIONS available for Android 13 and later.

Notes

  • This is a mobile-only plugin. If you share Tauri setup code across desktop and mobile targets, gate registration with #[cfg(mobile)].
  • On Android, register() is effectively a no-op because FCM registration is automatic.
  • On iOS simulators, register() rejects with "Push notifications not available on simulator". A push-error event also fires once at startup (from load()) for listeners attached early.
  • On iOS, if APNs registration fails (missing entitlement, cert mismatch, no network), the error is buffered and surfaced by the next getToken() call. The push-error event also fires for listeners.
  • createChannel() is Android-only and is a no-op on iOS.
  • On Android API 26+, calling sendNotification() before createChannel() will silently drop the notification.

License

Licensed under either of: