Registry / aws / amplify-category-notifications

amplify-category-notifications

JSON →
library2.23.2jsnpmunverified

The `@aws-amplify/amplify-category-notifications` package is a core plugin for the AWS Amplify Command Line Interface (CLI), enabling developers to manage notification channels, primarily through Amazon Pinpoint. It allows for the addition, removal, updating, and status checking of notification channels directly from the command line, and provides a shortcut to the Pinpoint console for detailed configuration. This package is part of the larger Amplify CLI monorepo, with its latest stable version being `2.26.42`. It receives frequent updates, typically alongside the rapid release cadence of the Amplify CLI itself, ensuring compatibility with the latest AWS services and addressing security concerns. Its key differentiator is its deep integration into the Amplify development workflow, abstracting complex AWS Pinpoint configurations into simple CLI commands. This package is primarily for internal use by the Amplify CLI and for advanced users extending the CLI functionality.

npm install amplify-category-notifications
INSTALL
IMPORT
SIG · AMPLIFY-CATEGORY-N
A
amplify-category-notifications
awsjavascriptv2.23.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

add
import { add } from '@aws-amplify/amplify-category-notifications';
This function is primarily for internal Amplify CLI use or advanced plugin development, not typical application code.
update
import { update } from '@aws-amplify/amplify-category-notifications';
This function is primarily for internal Amplify CLI use or advanced plugin development, not typical application code.
NotificationChannel
import { NotificationChannel } from '@aws-amplify/amplify-category-notifications';
This is a TypeScript type/interface, useful for defining configuration objects when working with the plugin's internal structures.

This quickstart demonstrates how to programmatically interact with the Amplify CLI to add and configure a push notification channel using the underlying `amplify-category-notifications` plugin. It simulates the `amplify add notifications` command, which is the primary way developers utilize this package.

import { exec } from 'child_process'; import { promisify } from 'util'; const execAsync = promisify(exec); async function setupAmplifyNotifications() { try { console.log('Initializing Amplify project (if not already initialized)...'); // Ensure Amplify project is initialized. This is a prerequisite. await execAsync('amplify init --yes'); console.log('Adding notifications category via Amplify CLI...'); // This simulates running `amplify add notifications` interactively. // In a real script, you'd handle prompts or use headless mode. const { stdout, stderr } = await execAsync( `amplify add notifications --channel APNS --json-file-path './path/to/your-apns-key.json' --no-override`, { env: { ...process.env, // Example: Provide environment variables for non-interactive prompts if available // AMH_APP_ID: process.env.AMH_APP_ID ?? '', // AMH_REGION: process.env.AMH_REGION ?? '' } } ); console.log('Amplify CLI Output (add notifications):', stdout); if (stderr) console.error('Amplify CLI Error (add notifications):', stderr); console.log('Pushing Amplify backend changes...'); await execAsync('amplify push --yes'); console.log('Amplify notifications setup complete. Review `amplify status` for details.'); } catch (error) { console.error('Failed to set up Amplify notifications:', error); process.exit(1); } } // For an actual application, you'd then use @aws-amplify/pushnotification in your client-side code. // import Amplify from 'aws-amplify'; // import PushNotification from '@aws-amplify/pushnotification'; // import awsconfig from './aws-exports'; // Amplify.configure(awsconfig); // PushNotification.onNotification(notification => { // console.log('Notification received:', notification); // }); setupAmplifyNotifications();
amplify --version
Debug
Known issues
gotchaThis package, `@aws-amplify/amplify-category-notifications`, is a plugin for the AWS Amplify CLI and is primarily intended for internal use by the CLI or for advanced users extending CLI functionality. Direct programmatic import into typical application code is not the standard use case. For application-level push notifications, use `@aws-amplify/notifications` or `@aws-amplify/pushnotification` from the main `aws-amplify` library.
fix
For application logic, use client-side Amplify libraries (e.g., `aws-amplify` or `@aws-amplify/pushnotification`). Interact with notification backend setup via the Amplify CLI commands (e.g., `amplify add notifications`).
affects: >=1.0.0
breakingA significant refactoring related to AWS SDK v3 migration was attempted and then reverted in Amplify CLI `v14.2.0` (which includes `amplify-category-notifications@2.26.38`). This indicates that future major versions of Amplify CLI will likely introduce breaking changes as the AWS SDK v3 migration is completed. Users should anticipate breaking changes related to AWS SDK interfaces and potentially the structure of how AWS service calls are made internally.
fix
Monitor Amplify CLI release notes closely for explicit breaking changes related to AWS SDK v3 migration. Update CLI and related packages incrementally, and thoroughly test existing deployments.
affects: >=14.2.0
gotchaWhen configuring push notifications, especially for iOS (APNS), the Amplify CLI requires paths to `.p12` certificate files or service account keys (for FCM). Incorrect paths or malformed certificate/key files are a common source of setup failures.
fix
Ensure all certificate and key file paths provided during `amplify add notifications` are absolute or correctly relative to the project root. Double-check that certificate/key files are valid and correctly generated from your Apple Developer or Firebase console.
affects: >=1.0.0
breakingSecurity fixes were released in `v2.26.42` for handling errant certificate marks and unsanitized input in PEM file content. Older versions may be vulnerable to issues related to certificate parsing.
fix
Upgrade to `@aws-amplify/amplify-category-notifications@2.26.42` or later to ensure these security vulnerabilities are patched. Regularly update your Amplify CLI.
affects: <2.26.42
gotchaAdding the notifications category via `amplify add notifications` automatically adds the Auth category and configures Amazon Cognito User Pools, which is required for authenticated access to Amazon Pinpoint endpoints. Modifications to Cognito after initial setup can impact notification functionality.
fix
Be aware that notification setup is tightly coupled with the Auth category. Avoid manual modifications to Cognito resources that were provisioned by Amplify for notifications without fully understanding the dependencies. For unauthenticated users, ensure analytics events are authorized during setup.
affects: >=1.0.0
Errors
Common errors & fixes
Error: Amplify CLI is not installed or configured correctly.
The Amplify CLI is not globally installed or is not in the system's PATH, preventing the `amplify` command from being found.
fix
Install the Amplify CLI globally: `npm install -g @aws-amplify/cli` or `yarn global add @aws-amplify/cli`. Ensure your system's PATH includes the global npm/yarn bin directory.
The push notification channel to enable. (Use arrow keys)
This is a prompt from `amplify add notifications` indicating that an interactive selection for the notification channel (APNS, FCM) is required, but it's not being provided in a non-interactive context.
fix
Run `amplify add notifications` interactively, or provide options using flags for non-interactive execution, e.g., `amplify add notifications --channel APNS` and include necessary certificate/key paths using `--json-file-path` or `--p12-file-path` flags.
AccessDeniedException: User: arn:aws:iam::ACCOUNT_ID:user/IAM_USER is not authorized to perform: mobiletargeting:UpdateApnsChannel
The AWS IAM user or role configured for Amplify CLI lacks the necessary permissions to manage Amazon Pinpoint notification channels.
fix
Ensure the IAM user/role used by the Amplify CLI (configured via `amplify configure`) has appropriate `mobiletargeting` permissions, including `UpdateApnsChannel`, `UpdateGcmChannel`, `GetChannel` actions for Amazon Pinpoint. Review and update the IAM policy attached to your Amplify CLI user/role.
TypeError: Cannot read properties of undefined (reading 'onNotification')
This error typically occurs in client-side application code when attempting to use `@aws-amplify/pushnotification` without proper configuration or initialization, or if `Amplify.configure()` has not been called.
fix
Ensure `aws-amplify` and `@aws-amplify/pushnotification` are installed, imported, and `Amplify.configure(awsconfig)` is called early in your application's lifecycle, using the `aws-exports.js` file generated by the Amplify CLI. Also, confirm the push notifications category is correctly added to your backend via `amplify add notifications` and `amplify push`.
Upgrade
Version history
2.23.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
42 hits · last 30 days
node
34
Resources