{"_id":"@aistudioapk/notifications","_rev":"2-5793e1b5823c901d6c15f5b70b13e9b9","name":"@aistudioapk/notifications","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@aistudioapk/notifications","version":"1.0.0","keywords":["notifications","android","capacitor","aistudio"],"license":"MIT","_id":"@aistudioapk/notifications@1.0.0","maintainers":[{"name":"loopintoai","email":"loopintoai@gmail.com"}],"homepage":"https://github.com/loopintoai/aistudioapk#readme","bugs":{"url":"https://github.com/loopintoai/aistudioapk/issues"},"dist":{"shasum":"4b489e4972f5c71f76c7e230046bb945c87ed028","tarball":"https://registry.npmjs.org/@aistudioapk/notifications/-/notifications-1.0.0.tgz","fileCount":3,"integrity":"sha512-HPk2p1MlQOuzZi9ziRfSw/o2qeuYcXctv2K60Cjyjop+x7AZ/5h9iBsN4EitHFd9rR5D2706WZaFst2SeUlf6w==","signatures":[{"sig":"MEYCIQDlv9EXgDA/4k6ayQr48O6y3+BMShmlqG4tXn3xd7VD7AIhAIHGKdFKwXejhvEKBUN2d1ICg/4YAiBJIkWm+wWKPMww","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12816},"main":"index.js","type":"module","types":"index.d.ts","module":"index.js","exports":{".":{"types":"./index.d.ts","import":"./index.js"}},"gitHead":"c88f83401c688f34abf223ac0f8ce213a5be736d","_npmUser":{"name":"loopintoai","email":"loopintoai@gmail.com"},"repository":{"url":"git+https://github.com/loopintoai/aistudioapk.git","type":"git"},"_npmVersion":"11.12.1","description":"Local notifications for AIStudioAPK — renders web toasts in the browser, native Android notifications in APK builds","directories":{},"_nodeVersion":"24.15.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/notifications_1.0.0_1780942609702_0.9749164458750526","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@aistudioapk/notifications","version":"1.0.1","description":"Local notifications for AIStudioAPK — renders web toasts in the browser, native Android notifications in APK builds","type":"module","main":"index.js","module":"index.js","types":"index.d.ts","exports":{".":{"import":"./index.js","types":"./index.d.ts"}},"keywords":["notifications","android","capacitor","aistudio"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/loopintoai/aistudioapk.git"},"gitHead":"b16f2128481757f066fd60e35ede33a97f2ce9fe","_id":"@aistudioapk/notifications@1.0.1","bugs":{"url":"https://github.com/loopintoai/aistudioapk/issues"},"homepage":"https://github.com/loopintoai/aistudioapk#readme","_nodeVersion":"24.15.0","_npmVersion":"11.12.1","dist":{"integrity":"sha512-VQmEcVMIHH8kdgeLt7QUhkucdyQ9/zqY2MF3HLj9N3YqTV2LCqD0KIZjwYj/eaQmzbQ8mEfZS5TVPVv+TCUZ9w==","shasum":"0f0b7c1860fa4d1b96947b0693fe1be1a156078c","tarball":"https://registry.npmjs.org/@aistudioapk/notifications/-/notifications-1.0.1.tgz","fileCount":4,"unpackedSize":17872,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQCAV5TtIZlAX9hnICeUFkwpXHfRQa/2bSRxbafATzNppAIgDrcYhmstQHodka262KyN14eIVk2ybFW69tePuyp+Lxw="}]},"_npmUser":{"name":"loopintoai","email":"loopintoai@gmail.com"},"directories":{},"maintainers":[{"name":"loopintoai","email":"loopintoai@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/notifications_1.0.1_1780942895123_0.8492269570906632"},"_hasShrinkwrap":false}},"time":{"created":"2026-06-08T18:16:49.506Z","modified":"2026-06-08T18:21:35.376Z","1.0.0":"2026-06-08T18:16:49.894Z","1.0.1":"2026-06-08T18:21:35.234Z"},"bugs":{"url":"https://github.com/loopintoai/aistudioapk/issues"},"license":"MIT","homepage":"https://github.com/loopintoai/aistudioapk#readme","keywords":["notifications","android","capacitor","aistudio"],"repository":{"type":"git","url":"git+https://github.com/loopintoai/aistudioapk.git"},"description":"Local notifications for AIStudioAPK — renders web toasts in the browser, native Android notifications in APK builds","maintainers":[{"name":"loopintoai","email":"loopintoai@gmail.com"}],"readme":"# @aistudioapk/notifications\n\n> Local notifications for apps built with [AIStudioAPK](https://aistudioapk.com) — renders web toasts in the browser for testing, native Android notifications in your APK automatically.\n\n[![npm version](https://img.shields.io/npm/v/@aistudioapk/notifications.svg)](https://www.npmjs.com/package/@aistudioapk/notifications)\n[![license](https://img.shields.io/npm/l/@aistudioapk/notifications.svg)](LICENSE)\n\n---\n\n## How it works\n\nWrite your notification logic once using this library. In the browser it shows styled toast popups so you can test everything normally. When you build your APK with AIStudioAPK, the platform detects the library and automatically injects a native Android bridge — no code changes needed.\n\n| Environment | Behaviour |\n|-------------|-----------|\n| Browser | Styled toast popup in the corner of the page |\n| APK (AIStudioAPK build) | Native Android notification |\n\n> If the library is not found in your project, the build skips injection entirely — no extra permissions, no bloat added to your APK.\n\n---\n\n## Installation\n\n```bash\nnpm install @aistudioapk/notifications\n```\n\n---\n\n## Quick start\n\n```js\nimport { notify } from '@aistudioapk/notifications'\n\n// Show a notification immediately\nawait notify.show({\n  title: 'Download complete',\n  body: 'Your file is ready.',\n  data: { screen: '/results' }\n})\n\n// Schedule one for later\nawait notify.schedule({\n  title: 'Daily reminder',\n  body: 'Check your dashboard',\n  triggerAt: Date.now() + 24 * 60 * 60 * 1000,\n  repeat: 'daily'\n})\n\n// Handle taps — register once on app startup\nnotify.onTap((data) => {\n  console.log('Notification tapped:', data)\n})\n```\n\n---\n\n## API\n\n### `notify.show(options)` → `Promise<void>`\n\nShow a notification immediately.\n\n| Option | Type | Required | Description |\n|--------|------|----------|-------------|\n| `title` | `string` | ✅ | Notification heading |\n| `body` | `string` | ✅ | Notification message |\n| `id` | `string \\| number` | — | Stable ID. Auto-generated if omitted. |\n| `data` | `object` | — | Payload forwarded to `onTap` callback |\n| `icon` | `string` | — | Emoji shown in browser toast |\n| `sound` | `boolean` | — | Play sound. Default: `true` |\n| `vibrate` | `boolean` | — | Vibrate device. Default: `true` |\n| `priority` | `'low' \\| 'normal' \\| 'high'` | — | Android priority. Default: `'normal'` |\n| `ongoing` | `boolean` | — | Persistent notification. Default: `false` |\n\n---\n\n### `notify.schedule(options)` → `Promise<void>`\n\nSchedule a notification to fire at a future time. Survives app restarts on Android.\n\n| Option | Type | Required | Description |\n|--------|------|----------|-------------|\n| `triggerAt` | `Date \\| number` | ✅ | When to fire — `Date` or ms timestamp |\n| `repeat` | `'hourly' \\| 'daily' \\| 'weekly' \\| number` | — | Repeat interval. Pass ms for custom intervals. |\n| `...` | | | All `show()` options are supported |\n\n---\n\n### `notify.cancel(id)` → `Promise<void>`\n\nCancel a displayed notification or pending alarm by ID.\n\n---\n\n### `notify.cancelAll()` → `Promise<void>`\n\nCancel all notifications and pending alarms.\n\n---\n\n### `notify.onTap(callback)` → `void`\n\nRegister a callback invoked when the user taps a notification. Call once on app startup.\n\n```js\nnotify.onTap((data) => {\n  // data = the object you passed in show() or schedule()\n  if (data.screen) router.push(data.screen)\n})\n```\n\n---\n\n### `notify.requestPermission()` → `Promise<'granted' | 'denied' | 'not-determined'>`\n\nRequest Android `POST_NOTIFICATIONS` permission. Always returns `'granted'` in the browser.\n\n---\n\n### `notify.configure(config)` → `void`\n\nSet global defaults. Call once before using other methods.\n\n```js\nnotify.configure({\n  webPosition: 'top-right',   // where browser toasts appear\n  defaultSound: true,\n  defaultVibrate: true,\n  defaultChannelId: 'general'\n})\n```\n\n| Option | Type | Default |\n|--------|------|---------|\n| `webPosition` | `'bottom-right' \\| 'bottom-left' \\| 'top-right' \\| 'top-left' \\| 'top-center' \\| 'bottom-center'` | `'bottom-right'` |\n| `defaultSound` | `boolean` | `true` |\n| `defaultVibrate` | `boolean` | `true` |\n| `defaultChannelId` | `string` | `'general'` |\n\n---\n\n## Examples\n\n**Process completion**\n```js\nasync function runExport() {\n  await generateReport()\n  await notify.show({\n    title: 'Export ready',\n    body: 'Your report has been generated.',\n    data: { screen: '/reports/latest' }\n  })\n}\n\nnotify.onTap(({ screen }) => {\n  if (screen) router.push(screen)\n})\n```\n\n**Daily reminder with cancel**\n```js\nnotify.schedule({\n  id: 'daily-reminder',\n  title: 'Good morning!',\n  body: 'Your daily summary is ready.',\n  triggerAt: new Date().setHours(9, 0, 0, 0),\n  repeat: 'daily'\n})\n\n// Cancel it later\nnotify.cancel('daily-reminder')\n```\n\n---\n\n## Requirements\n\n- Built with [AIStudioAPK](https://aistudioapk.com) for native Android support\n- Works in any React / Vue / Svelte / vanilla JS project\n\n---\n\n## License\n\nMIT © [AIStudioAPK](https://aistudioapk.com)\n","readmeFilename":"README.md"}