A Node.js service that handles push notifications using RabbitMQ as a message broker. Currently supports iOS push notifications via Apple Push Notification service (APNs).
This service provides two distinct ways to send notifications:
- Direct RabbitMQ Integration: Connect directly to the RabbitMQ message broker to send notifications (see Message Format below)
- HTTP API: Use the REST API endpoints to send notifications and manage device tokens. (see API Documentation).
Note: Device token management (registration, updates, deletion) is only available through the HTTP API.
- Docker and Docker Compose
- Apple Developer Account credentials for iOS push notifications
-
Clone the repository
-
Create a
.envfile in the root directory with the following configuration:
RABBITMQ_QUEUE_NAME = "test_queue"
APN_TEAM_ID = "YOUR_TEAM_ID"
APN_KEY_ID = "YOUR_KEY_ID"
APN_KEY_PATH = "./IOS/AuthKey_YOUR_KEY_ID.p8"
APN_TOPIC = "your.app.bundle.id"
APN_TEST_DEVICE_TOKEN = "YOUR_DEVICE_TOKEN"
CREATE_MANAGEMENT_PORTAL = true
- Place your APNs authentication key (
.p8file) in theIOSdirectory
- Start RabbitMQ and notfication service using Docker Compose:
docker-compose up -dThe service:
- Connects to RabbitMQ on startup
- Listens for notification messages on the configured queue
- Processes messages and sends push notifications to iOS devices
Send JSON messages to RabbitMQ in the following format:
{
"title": "Notification Title",
"body": "Notification Body",
"tokens": ["device_token_1", "device_token_2"]
}The project structure:
src/index.ts- Main application entry pointRabbitMQ/RabbitMQ.ts- RabbitMQ connection handlingNotification.ts- Notification processing and sending logic
Run tests using Jest:
npm testAccess the RabbitMQ management interface at:
- URL: http://localhost:15672
- Username: guest
- Password: guest
ISC
