user-notifications
БесплатноБез исполняемых скриптовНе проверенNotify your app's users from your canister, on their devices and even while the app is closed. Internet Identity delivers each notification (as web push), so…
от jiayaoqijia★ 81 звезда на GitHubОб этом скилле
User Notifications
Prerequisite
Load the user-sign-in skill first. The sender list below is served from the app's primary origin, which that skill elects.
How it works
Your canister can notify your app's users, on their devices and while the app is closed. The canister addresses a user; Internet Identity holds that user's devices and delivers to them, so there is no push service, no VAPID keys, and no device tokens in the app.
Three pieces, all required. Missing any one of them produces silence rather than an error at the point you left out.
- The frontend asks the user's consent, through II.
- The origin names the sending canister at
/.well-known/ii-notification-senders. - The canister sends, through the
identity-notificationslibrary.
1. Consent, in the frontend
Needs @icp-sdk/auth 11.1.0 or later. Earlier 11.x has none of these methods.
const { granted } = await authClient.requestNotificationConsent();
const { granted } = await authClient.getNotificationConsentStatus();
await authClient.revokeNotificationConsent();
| Call | Opens II | Needs a session | Answers |
|---|---|---|---|
requestNotificationConsent() |
Yes | No; signs the user in if needed | { granted }, what II recorded |
getNotificationConsentStatus() |
No | Yes | { granted }, uncertified query |
revokeNotificationConsent() |
No | Yes | nothing; idempotent |
- All three answer a record, not a bare boolean.
const granted = await ...requestNotificationConsent()type-checks and is always truthy. granted: falseis the user's refusal, not a failure. Render it; do not throw.- Asking a second time when consent is already held returns
{ granted: true }without showing a screen, because the answer is read back from the canister rather than reported from the ceremony. getNotificationConsentStatusis a query, so the answer is uncertified. Paint a toggle from it; do not gate anything on it.- Ask from a click. The ceremony renders, so it cannot run under
prompt: 'none'. - Consent is recorded against the identity, and the browser the user answered on is the one registered for delivery. Someone who wants your notifications on a second machine answers again there. The status call reports the consent alone and does not speak for the device in the user's hand.
Asking with the sign-in
The sign-in button is already a click, so that is the cheapest place to ask. Run both from it and the user signs in and answers in one visit to II rather than two:
const [identity, { granted }] = await Promise.all([
authClient.signIn(),
authClient.requestNotificationConsent(),
]);
Asking at any later moment needs a control of its own.
A toggle, later
To show the user whether your app may notify them, and let them turn it off:
const { granted } = await authClient.getNotificationConsentStatus();
await authClient.revokeNotificationConsent();
Revoking is scoped to your app. It drops your origin's consent and whatever you still had queued for that user, and leaves their device subscriptions and every other app's consent alone. So dropping someone from your own recipient table revokes nothing, and revoking is not an unsubscribe.
Errors worth branching on:
| Error | Means | Remedy |
|---|---|---|
InteractionRequiredError |
Client built with prompt: 'none' |
Ask again from a click |
NotificationsUnsupportedError |
That II deployment does not notify at all | Hide the control; nothing to retry |
SessionGoneError |
No live session (status and revoke only) | Sign in again |
2. The senders document
Serve from the primary origin, the same origin as /.well-known/ii-app-metadata:
{ "senders": ["ryjl3-tyaaa-aaaaa-aaaba-cai"] }
- At most 10 canisters, shared by every app derived from that origin. A longer list is rejected whole, never truncated.
- II caches what it reads, so a canister added is not accepted instantly and one removed keeps working for a while afterwards.
- Without this document naming the sending canister, every send is refused. This is the most common cause of "nothing arrives and nothing errors".
3. Sending
Library: identity-notifications, same send in both languages, different wiring. Rust is on crates.io, Motoko on Mops (requires moc 2.0.0 or later).
Rust needs endpoints!() plus three stable MemoryIds handed to init (see "Upgrades"). Motoko needs neither: the mixin brings the endpoints and keeps its own state. Do not tell a Motoko user to pass memory ids; there are none.
identity-notifications = "0.1"
use identity_notifications as notifications;
use identity_notifications::{Memories, Notification};
notifications::endpoints!(); // the endpoints II calls back on
#[init] fn init() { init_notifications(); }
#[post_upgrade] fn post_upgrade() { init_notifications(); }
fn init_notifications() {
MEMORIES.with_borrow(|manager|
Установить user-notifications в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл user-notifications?
Notify your app's users from your canister, on their devices and even while the app is closed. Internet Identity delivers each notification (as web push), so there is no push service, no VAPID keys and no device tokens in the app: the canister addresses a user and II reaches their browsers. Covers asking the user's consent in the frontend (requestNotificationConsent, getNotificationConsentStatus, revokeNotificationConsent, needing @icp-sdk/auth 11.1.0), the /.well-known/ii-notification-senders document, and sending with the identity-notifications library from Motoko or Rust. Use when an app must tell a user something while they are not looking at it, when adding notifications, web push or a notifications toggle, or when the user consented and nothing arrives. Assumes sign-in already works and the app's primary origin is settled: load user-sign-in first. Do NOT use for in-app notification UI or email, or for reaching anyone who is not a signed-in user of this app.
Как установить скилл user-notifications?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл user-notifications запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
docx
Use this skill whenever the user wants to create, read, edit, or manipulate Word documents (.docx files) or Word templates (.dotx files). Triggers include…
от AnthropicUse this skill whenever the user wants to do anything with PDF files. This includes reading or extracting text/tables from PDFs, combining or merging multiple…
от Anthropicxlsx
Use this skill any time a spreadsheet file is the primary input or output. This means any task where the user wants to: open, read, edit, or fix an existing…
от Anthropicpptx
Use this skill any time a .pptx or .potx file is involved in any way — as input, output, or both. This includes: creating slide decks, pitch decks, or…
от Anthropic