Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

internet-identity-notifications

БесплатноБез исполняемых скриптовНе проверен

Notify a signed-in Internet Identity user from your canister while the app is closed, with web push that II owns end to end, so there is no push service, no…

jiayaoqijiaот jiayaoqijia★ 81 звезда на GitHub

Об этом скилле

Internet Identity Notifications

Prerequisite

Load the internet-identity skill first. Two things from it are load-bearing here: the sender list is served from the app's primary origin, the same origin ii-app-metadata is read from, and that metadata is what names the app on its own notifications.

A suite shares one sender list and one 10-canister cap across every app derived from that origin.

Notifications

Your canister can notify a signed-in user while the app is closed. II owns the push subscriptions, 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.

  1. The frontend asks for consent, through II.
  2. The origin names the sending canister at /.well-known/ii-notification-senders.
  3. The canister sends, through the identity-notifications library.

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() is wrong and type-checks as an object.
  • granted: false is 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.
  • getNotificationConsentStatus is 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. 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".

A suite shares one sender list and one cap of 10 across every app derived from that origin.

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, and init called again from post_upgrade. Motoko needs neither: the mixin brings the endpoints and keeps its own state, and there is nothing to do on upgrade. 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,
Полный SKILL.md на GitHub

Установить internet-identity-notifications в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

LICENSESOURCE.mdTRUST.auto.yaml

FAQ

Что делает скилл internet-identity-notifications?

Notify a signed-in Internet Identity user from your canister while the app is closed, with web push that II owns end to end, so there is no push service, no VAPID keys and no device tokens in the app. Covers 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 reach a user who is not looking at it, when adding web push or a notifications toggle, or when consent was granted and nothing arrives. Assumes sign-in already works and the app's primary origin is settled: load internet-identity 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.

Как установить скилл internet-identity-notifications?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл internet-identity-notifications запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить internet-identity-notifications с