{"id":29943393,"url":"https://github.com/sourcefuse/loopback4-notifications","last_synced_at":"2025-08-03T02:17:05.417Z","repository":{"id":37101296,"uuid":"253509280","full_name":"sourcefuse/loopback4-notifications","owner":"sourcefuse","description":"An extension for setting up various notification mechanisms in loopback4 application, vis-a-vis, Push notification, SMS notification, Email notification","archived":false,"fork":false,"pushed_at":"2025-07-22T10:15:48.000Z","size":5277,"stargazers_count":35,"open_issues_count":7,"forks_count":15,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-07-27T18:20:00.463Z","etag":null,"topics":["arcbysf","aws-ses","aws-sns","email-notification","loopback-next","loopback4","loopback4-extension","pubnub","push-notifications","sms-notifications"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/sourcefuse.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":".github/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":".github/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2020-04-06T13:41:35.000Z","updated_at":"2024-12-13T14:22:40.000Z","dependencies_parsed_at":"2023-12-13T10:24:09.197Z","dependency_job_id":"9ef843f8-ccc2-49fc-9b00-e8f34db27f04","html_url":"https://github.com/sourcefuse/loopback4-notifications","commit_stats":{"total_commits":86,"total_committers":21,"mean_commits":4.095238095238095,"dds":0.8255813953488372,"last_synced_commit":"0f67bc14da0dc4b0aae78842fc9115b81b70ecab"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"purl":"pkg:github/sourcefuse/loopback4-notifications","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-notifications","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-notifications/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-notifications/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-notifications/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sourcefuse","download_url":"https://codeload.github.com/sourcefuse/loopback4-notifications/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sourcefuse%2Floopback4-notifications/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268484362,"owners_count":24257660,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-03T02:00:12.545Z","response_time":2577,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["arcbysf","aws-ses","aws-sns","email-notification","loopback-next","loopback4","loopback4-extension","pubnub","push-notifications","sms-notifications"],"created_at":"2025-08-03T02:15:14.801Z","updated_at":"2025-08-03T02:17:05.386Z","avatar_url":"https://github.com/sourcefuse.png","language":"TypeScript","readme":"\u003ca href=\"https://sourcefuse.github.io/arc-docs/arc-api-docs\" target=\"_blank\"\u003e\u003cimg src=\"https://github.com/sourcefuse/loopback4-microservice-catalog/blob/master/docs/assets/logo-dark-bg.png?raw=true\" alt=\"ARC By SourceFuse logo\" title=\"ARC By SourceFuse\" align=\"right\" width=\"150\" /\u003e\u003c/a\u003e\n\n# [loopback4-notifications](https://github.com/sourcefuse/loopback4-notifications)\n\n\u003cp align=\"left\"\u003e\n\u003ca href=\"https://www.npmjs.com/package/loopback4-notifications\"\u003e\n\u003cimg src=\"https://img.shields.io/npm/v/loopback4-notifications.svg\" alt=\"npm version\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://sonarcloud.io/summary/new_code?id=sourcefuse_loopback4-notifications\" target=\"_blank\"\u003e\n\u003cimg alt=\"Sonar Quality Gate\" src=\"https://img.shields.io/sonar/quality_gate/sourcefuse_loopback4-notifications?server=https%3A%2F%2Fsonarcloud.io\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://app.snyk.io/org/ashishkaushik/reporting?context[page]=issues-detail\u0026project_target=%255B%2522sourcefuse%252Floopback4-notifications%2522%255D\u0026project_origin=%255B%2522github%2522%255D\u0026issue_status=%255B%2522Open%2522%255D\u0026issue_by=Severity\u0026table_issues_detail_cols=SCORE%257CCVE%257CCWE%257CPROJECT%257CEXPLOIT%2520MATURITY%257CAUTO%2520FIXABLE%257CINTRODUCED%257CSNYK%2520PRODUCT\u0026v=1\"\u003e\n\u003cimg alt=\"Synk Status\" src=\"https://img.shields.io/badge/SYNK_SECURITY-MONITORED-GREEN\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/sourcefuse/loopback4-notifications/graphs/contributors\" target=\"_blank\"\u003e\n\u003cimg alt=\"GitHub contributors\" src=\"https://img.shields.io/github/contributors/sourcefuse/loopback4-notifications\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://www.npmjs.com/package/loopback4-notifications\" target=\"_blank\"\u003e\n\u003cimg alt=\"downloads\" src=\"https://img.shields.io/npm/dw/loopback4-notifications.svg\"\u003e\n\u003c/a\u003e\n\u003ca href=\"https://github.com/sourcefuse/loopback4-notifications/blob/master/LICENSE\"\u003e\n\u003cimg src=\"https://img.shields.io/github/license/sourcefuse/loopback4-notifications.svg\" alt=\"License\" /\u003e\n\u003c/a\u003e\n\u003ca href=\"https://loopback.io/\" target=\"_blank\"\u003e\n\u003cimg alt=\"Powered By LoopBack 4\" src=\"https://img.shields.io/badge/Powered%20by-LoopBack 4-brightgreen\" /\u003e\n\u003c/a\u003e\n\u003c/p\u003e\n\n## Overview\n\nThis is a loopback-next extension for adding different notification mechanisms vis-à-vis, Push, SMS, Email to any loopback 4 based REST API application or microservice.\n\nIt provides a generic provider-based framework to add your own implementation or implement any external service provider to achieve the same. There are 3 different providers available to be injected namely, PushProvider, SMSProvider and EmailProvider. It also provides support for 7 very popular external services for sending notifications.\n\n1. [AWS Simple Email Service](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html) - It's one of the EmailProvider for sending email messages.\n2. [AWS Simple Notification Service](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html) - It's one of the SMSProvider for sending SMS notifications.\n3. [Pubnub](https://www.pubnub.com/docs/nodejs-javascript/pubnub-javascript-sdk) - It's one of the PushProvider for sending realtime push notifications to mobile applications as well as web applications.\n4. [Socket.IO](https://socket.io/docs/) - It's one of the PushProvider for sending realtime push notifications to mobile applications as well as web applications.\n5. [FCM](https://firebase.google.com/docs/cloud-messaging) - It's one of the PushProvider for sending realtime push notifications to mobile applications as well as web applications.\n6. [Nodemailer](https://nodemailer.com/about/) - It's one of the EmailProvider for sending email messages.\n7. [Apple Push Notification service](https://developer.apple.com/library/archive/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/APNSOverview.html#//apple_ref/doc/uid/TP40008194-CH8-SW1) - It's one of the push notification providers that integrates notification service created by Apple Inc. that enables third party application developers to send notification data to applications installed on Apple devices.\n8. [Twilio SMS Service](https://www.twilio.com/docs/sms) - Twilio is a modern communication API Used by developers for establishing communications. Twilio can be used for sending SMS or [Whatapp notifications](https://www.twilio.com/docs/whatsapp).\n   You can use one of these services or add your own implementation or integration using the same interfaces and attach it as a provider for that specific type.\n\nYou can use one of these services or add your own implementation or integration using the same interfaces and attach it as a provider for that specific type.\n\n## Installation\n\n```sh\nnpm install loopback4-notifications\n```\n\n## Usage\n\nIn order to use this component into your LoopBack application, please follow below steps.\n\nAdd component to application.\n\n```ts\n// application.ts\nimport {NotificationsComponent} from 'loopback4-notifications';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    // ...\n  }\n}\n```\n\nAfter the above, you need to configure one of the notification provider at least. Based upon the requirement, please choose and configure the respective provider for sending notifications. See below.\n\n### Email Notifications using Amazon Simple Email Service\n\nThis extension provides in-built support of AWS Simple Email Service integration for sending emails from the application. In order to use it, run `npm install aws-sdk`, and then bind the SesProvider as below in `application.ts`.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {SesProvider} from 'loopback4-notifications/ses';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.EmailProvider).toProvider(SesProvider);\n    // ...\n  }\n}\n```\n\nThere are some additional configurations needed in order to allow SES to connect to AWS. You need to add them as below. Make sure these are added before the provider binding.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {SesProvider, SESBindings} from 'loopback4-notifications/ses';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(SESBindings.Config).to({\n      accessKeyId: process.env.SES_ACCESS_KEY_ID,\n      secretAccessKey: process.env.SES_SECRET_ACCESS_KEY,\n      region: process.env.SES_REGION,\n    });\n    this.bind(NotificationBindings.EmailProvider).toProvider(SesProvider);\n    // ...\n  }\n}\n```\n\nAll the configurations as specified by AWS docs [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SES.html#constructor-property) are supported in above `SESBindings.Config` key.\n\nIn addition to this, some general configurations can also be done, like below.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {SesProvider, SESBindings} from 'loopback4-notifications/ses';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.Config).to({\n      sendToMultipleReceivers: false,\n      senderEmail: 'support@myapp.com',\n    });\n    this.bind(SESBindings.Config).to({\n      accessKeyId: process.env.SES_ACCESS_KEY_ID,\n      secretAccessKey: process.env.SES_SECRET_ACCESS_KEY,\n      region: process.env.SES_REGION,\n    });\n    this.bind(NotificationBindings.EmailProvider).toProvider(SesProvider);\n    // ...\n  }\n}\n```\n\nPossible configuration options for the above are mentioned below.\n\n| Option                  | Type    | Description                                                                                                                                                            |\n| ----------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| sendToMultipleReceivers | boolean | If set to true, single email will be sent to all receivers mentioned in payload. If set to false, multiple emails will be sent for each receiver mentioned in payload. |\n| senderEmail             | string  | This will be used as from email header in sent email.                                                                                                                  |\n\nIf you wish to use any other service provider of your choice, you can create a provider for the same, similar to SesProvider we have. Add that provider in place of SesProvider. Refer to the implementation [here](https://github.com/sourcefuse/loopback4-notifications/blob/master/src/providers/email/ses/).\n\n```ts\nthis.bind(NotificationBindings.EmailProvider).toProvider(MyOwnProvider);\n```\n\n### Email Notifications Using Nodemailer\n\nThis extension provides in-built support of Nodemailer integration for sending emails from the application. In order to use it, run `npm install nodemailer`, and then bind the NodemailerProvider as below in `application.ts`.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {NodemailerProvider} from 'loopback4-notifications/nodemailer';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.EmailProvider).toProvider(\n      NodemailerProvider,\n    );\n    // ...\n  }\n}\n```\n\nThere are some additional configurations needed in order to allow NodeMailer to works. You need to add them as below. Make sure these are added before the provider binding.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {\n  NodemailerProvider,\n  NodemailerBindings,\n} from 'loopback4-notifications/nodemailer';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(NodemailerBindings.Config).to({\n      pool: true,\n      maxConnections: 100,\n      url: '',\n      host: 'smtp.example.com',\n      port: 80,\n      secure: false,\n      auth: {\n        user: 'username',\n        pass: 'password',\n      },\n      tls: {\n        rejectUnauthorized: true,\n      },\n    });\n    this.bind(NotificationBindings.EmailProvider).toProvider(\n      NodemailerProvider,\n    );\n    // ...\n  }\n}\n```\n\nAll the configurations as specified by Nodemailer docs for SMTP transport [here](https://nodemailer.com/smtp/) are supported in above NodemailerBindings.Config key.\n\nIn addition to this, some general configurations can also be done, like below.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {\n  NodemailerProvider,\n  NodemailerBindings,\n} from 'loopback4-notifications/nodemailer';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.Config).to({\n      sendToMultipleReceivers: false,\n      senderEmail: 'support@myapp.com',\n    });\n    this.bind(NodemailerBindings.Config).to({\n      pool: true,\n      maxConnections: 100,\n      url: '',\n      host: 'smtp.example.com',\n      port: 80,\n      secure: false,\n      auth: {\n        user: 'username',\n        pass: 'password',\n      },\n      tls: {\n        rejectUnauthorized: true,\n      },\n    });\n    this.bind(NotificationBindings.EmailProvider).toProvider(\n      NodemailerProvider,\n    );\n    // ...\n  }\n}\n```\n\nPossible configuration options for the above are mentioned below.\n\n| Option                  | Type    | Description                                                                                                                                                            |\n| ----------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| sendToMultipleReceivers | boolean | If set to true, single email will be sent to all receivers mentioned in payload. If set to false, multiple emails will be sent for each receiver mentioned in payload. |\n| senderEmail             | string  | This will be used as from email header in sent email.                                                                                                                  |\n\nIf you wish to use any other service provider of your choice, you can create a provider for the same, similar to NodemailerProvider we have. Add that provider in place of NodemailerProvider. Refer to the implementation [here](https://github.com/sourcefuse/loopback4-notifications/blob/master/src/providers/email/nodemailer/).\n\n```ts\nthis.bind(NotificationBindings.EmailProvider).toProvider(MyOwnProvider);\n```\n\n### SMS Notifications using AWS SNS\n\nThis extension provides in-built support of AWS Simple Notification Service integration for sending SMS from the application. In order to use it, run `npm install aws-sdk`, and then bind the SnsProvider as below in `application.ts`.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {SnsProvider} from 'loopback4-notification/sns';\n// ...\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.SMSProvider).toProvider(SnsProvider);\n    // ...\n  }\n}\n```\n\nThere are some additional configurations needed in order to allow SNS to connect to AWS. You need to add them as below. Make sure these are added before the provider binding.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {SNSBindings, SnsProvider} from 'loopback4-notification/sns';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(SNSBindings.Config).to({\n      accessKeyId: process.env.SNS_ACCESS_KEY_ID,\n      secretAccessKey: process.env.SNS_SECRET_ACCESS_KEY,\n      region: process.env.SNS_REGION,\n    });\n    this.bind(NotificationBindings.SMSProvider).toProvider(SnsProvider);\n    // ...\n  }\n}\n```\n\nAll the configurations as specified by AWS docs [here](https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/SNS.html#constructor-property) are supported in above SNSBindings.Config key.\n\nIf you wish to use any other service provider of your choice, you can create a provider for the same, similar to SnsProvider we have. Add that provider in place of SnsProvider.Refer to the implementation [here](https://github.com/sourcefuse/loopback4-notifications/blob/master/src/providers/sms/sns/).\n\n```ts\nthis.bind(NotificationBindings.SMSProvider).toProvider(MyOwnProvider);\n```\n\n### SMS / Whatsapp Notifications using Twilio\n\nThis extension provides in-built support of Twilio integration for sending SMS / whatsapp notifications from the application. In order to use it, run `npm install twilio`, and then bind the TwilioProvider as below in application.ts.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {\n  TwilioProvider\n} from 'loopback4-notification/twilio';\n....\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    ....\n\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.SMSProvider).toProvider(TwilioProvider);\n    ....\n  }\n}\n```\n\nThere are some additional configurations needed in order to connect to Twilio. You need to add them as below. Make sure these are added before the provider binding.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {\n  TwilioBindings,\n  TwilioProvider\n} from 'loopback4-notification/twilio';\n....\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    ....\n\n    this.component(NotificationsComponent);\n    this.bind(TwilioBindings.Config).to({\n      accountSid: process.env.TWILIO_ACCOUNT_SID,\n      authToken: process.env.TWILIO_AUTH_TOKEN,\n      waFrom: process.env.TWILIO_WA_FROM,\n      smsFrom: process.env.TWILIO_SMS_FROM,\n      waStatusCallback:process.env.TWILIO_WA_STATUS_CALLBACK,\n      smsStatusCallback:process.env.TWILIO_SMS_STATUS_CALLBACK,\n    });\n    this.bind(NotificationBindings.SMSProvider).toProvider(TwilioProvider);\n    ....\n  }\n}\n```\n\nAll the configurations as specified by Twilio docs and console are supported in above TwilioBindings Config key. smsFrom could be messaging service id, twilio number or short code. waFrom could be whats app number or number associated to channel.\n\n### Push Notifications with Pubnub\n\nThis extension provides in-built support of Pubnub integration for sending realtime push notifications from the application. In order to use it, run `npm install pubnub`, and then bind the PushProvider as below in `application.ts`.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {PubNubProvider} from 'loopback4-notifications/pubnub';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.PushProvider).toProvider(PubNubProvider);\n    // ...\n  }\n}\n```\n\nThere are some additional configurations needed in order to allow Pubnub connection. You need to add them as below. Make sure these are added before the provider binding.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {PubnubBindings, PubNubProvider} from 'loopback4-notifications/pubnub';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(PubNubProvider.Config).to({\n      subscribeKey: process.env.PUBNUB_SUBSCRIBE_KEY,\n      publishKey: process.env.PUBNUB_PUBLISH_KEY,\n      secretKey: process.env.PUBNUB_SECRET_KEY,\n      ssl: true,\n      logVerbosity: true,\n      uuid: 'my-app',\n      cipherKey: process.env.PUBNUB_CIPHER_KEY,\n      apns2Env: 'production',\n      apns2BundleId: 'com.app.myapp',\n    });\n    this.bind(NotificationBindings.PushProvider).toProvider(PubNubProvider);\n    // ...\n  }\n}\n```\n\nAll the configurations as specified by Pubnub docs [here](https://www.pubnub.com/docs/web-javascript/api-reference-configuration) are supported in above PubNubProvider.Config key.\n\nAdditionally, PubNubProvider also supports Pubnub Access Manager integration. Refer [docs](https://www.pubnub.com/docs/platform/security/access-control#overview) here for details.\n\nFor PAM support, PubNubProvider exposes two more methods - grantAccess and revokeAccess. These can be used to grant auth tokens and revoke them from Pubnub.\n\nIf you wish to use any other service provider of your choice, you can create a provider for the same, similar to PubNubProvider we have. Add that provider in place of PubNubProvider. Refer to the implementation [here](https://github.com/sourcefuse/loopback4-notifications/blob/master/src/providers/push/pubnub/).\n\n```ts\nthis.bind(NotificationBindings.PushProvider).toProvider(MyOwnProvider);\n```\n\n### Push Notifications With Socket.io\n\nThis extension provides in-built support of Socket.io integration for sending realtime notifications from the application. In order to use it, run `npm install socket.io-client`, and bind the PushProvider as below in `application.ts`.\n\nThis provider sends the message to the channel passed via config (or while publishing) and accepts a fix interface to interact with.\nThe interface could be imported into the project by the name SocketMessage.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {SocketIOProvider} from 'loopback4-notifications/socketio';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.PushProvider).toProvider(SocketIOProvider);\n    // ...\n  }\n}\n```\n\nThere are some additional configurations needed in order to allow Socket connection. You need to add them as below. Make sure these are added before the provider binding.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {\n  SocketBindings,\n  SocketIOProvider,\n} from 'loopback4-notifications/socketio';\n\nexport class NotificationServiceApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n\n    this.component(NotificationsComponent);\n    this.bind(SocketBindings.Config).to({\n      url: process.env.SOCKETIO_SERVER_URL,\n    });\n    this.bind(NotificationBindings.PushProvider).toProvider(SocketIOProvider);\n    // ...\n  }\n}\n```\n\nIf you wish to use any other service provider of your choice, you can create a provider for the same, similar to SocketIOProvider we have. Add that provider in place of SocketIOProvider. Refer to the implementation [here](https://github.com/sourcefuse/loopback4-notifications/blob/master/src/providers/push/socketio/).\n\n```ts\nthis.bind(NotificationBindings.PushProvider).toProvider(MyOwnProvider);\n```\n\n### Push Notifications With FCM\n\nThis extension provides in-built support of Firebase Cloud Messaging integration for sending realtime push notifications from the application. In order to use it, run `npm i firebase-admin`, and then bind the PushProvider as below in `application.ts`.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {FcmProvider} from 'loopback4-notifications/fcm';\nexport class MyApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.PushProvider).toProvider(FcmProvider);\n    // ...\n  }\n}\n```\n\nThere are some additional configurations needed in order to use Firebase Cloud Messaging. You need to add them as below. Make sure these are added before the provider binding.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {FcmProvider, FcmBindings} from 'loopback4-notifications/fcm';\nexport class MyApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n    this.component(NotificationsComponent);\n    this.bind(FcmBindings.Config).to({\n      apiKey: 'API_KEY',\n      authDomain: 'PROJECT_ID.firebaseapp.com',\n      // The value of `databaseURL` depends on the location of the database\n      databaseURL: 'https://DATABASE_NAME.firebaseio.com',\n      projectId: 'PROJECT_ID',\n      storageBucket: 'PROJECT_ID.appspot.com',\n      messagingSenderId: 'SENDER_ID',\n      appId: 'APP_ID',\n      // For Firebase JavaScript SDK v7.20.0 and later, `measurementId` is an optional field\n      measurementId: 'G-MEASUREMENT_ID',\n    });\n    this.bind(NotificationBindings.PushProvider).toProvider(FcmProvider);\n    // ...\n  }\n}\n```\n\nIf you wish to use any other service provider of your choice, you can create a provider for the same, similar to FcmProvider we have. Add that provider in place of FcmProvider. Refer to the implementation [here](https://github.com/sourcefuse/loopback4-notifications/blob/master/src/providers/push/fcm/).\n\n```ts\nthis.bind(NotificationBindings.PushProvider).toProvider(MyOwnProvider);\n```\n\n### Push Notifications With APNs\n\nThis extension provides in-built support of Apple Push Notification service for sending notification to applications installed on Apple devices. In order to use it bind the PushProvider as below in `application.ts`.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {ApnsProvider} from 'loopback4-notifications/apns';\nexport class MyApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n    this.component(NotificationsComponent);\n    this.bind(NotificationBindings.PushProvider).toProvider(ApnsProvider);\n    // ...\n  }\n}\n```\n\nThere are some additional configurations needed in order to use Apple Push Notification service. You need to add them as below. Make sure these are added before the provider binding.\n\n```ts\nimport {\n  NotificationsComponent,\n  NotificationBindings,\n} from 'loopback4-notifications';\nimport {ApnsProvider, ApnsBinding} from 'loopback4-notifications/apns';\nexport class MyApplication extends BootMixin(\n  ServiceMixin(RepositoryMixin(RestApplication)),\n) {\n  constructor(options: ApplicationConfig = {}) {\n    // ...\n    this.component(NotificationsComponent);\n    this.bind(ApnsBinding.Config).to({\n      providerOptions: {\n        /* APNs Connection options, see below. */\n      };\n      options: {\n        badge: 1, // optional\n        topic: \"string\"\n      };\n    });\n    this.bind(NotificationBindings.PushProvider).toProvider(ApnsProvider);\n    // ...\n  }\n}\n```\n\nFor more information about `providerOptions` check: [provider documentation](https://github.com/parse-community/node-apn/blob/master/doc/provider.markdown#apnprovideroptions)\n\nIf you wish to use any other service provider of your choice, you can create a provider for the same, similar to ApnsProvider we have. Add that provider in place of ApnsProvider. Refer to the implementation [here](https://github.com/sourcefuse/loopback4-notifications/blob/master/src/providers/push/apns/).\n\n```ts\nthis.bind(NotificationBindings.PushProvider).toProvider(MyOwnProvider);\n```\n\n### Controller Usage\n\nOnce the providers are set, the implementation of notification is very easy. Just add an entity implementing the Message interface provided by the component. For specific type, you can also implement specific interfaces like, SMSMessage, PushMessage, EmailMessage. See example below.\n\n```ts\nimport {Entity, model, property} from '@loopback/repository';\nimport {\n  Message,\n  Receiver,\n  MessageType,\n  MessageOptions,\n} from 'loopback4-notifications';\n\n@model({\n  name: 'notifications',\n})\nexport class Notification extends Entity implements Message {\n  @property({\n    type: 'string',\n    id: true,\n  })\n  id?: string;\n\n  @property({\n    type: 'string',\n    jsonSchema: {\n      nullable: true,\n    },\n  })\n  subject?: string;\n\n  @property({\n    type: 'string',\n    required: true,\n  })\n  body: string;\n\n  @property({\n    type: 'object',\n    required: true,\n  })\n  receiver: Receiver;\n\n  @property({\n    type: 'number',\n    required: true,\n  })\n  type: MessageType;\n\n  @property({\n    type: 'date',\n    name: 'sent',\n  })\n  sentDate: Date;\n\n  @property({\n    type: 'object',\n  })\n  options?: MessageOptions;\n\n  constructor(data?: Partial\u003cNotification\u003e) {\n    super(data);\n  }\n}\n```\n\nAfter this, you can publish notification from controller API methods as below. You don't need to invoke different methods for different notification. Same publish method will take care of it based on message type sent in request body.\n\n```ts\nexport class NotificationController {\n  constructor(\n    // ...\n    @inject(NotificationBindings.NotificationProvider)\n    private readonly notifProvider: INotification,\n  ) {}\n\n  @post('/notifications', {\n    responses: {\n      [STATUS_CODE.OK]: {\n        description: 'Notification model instance',\n        content: {\n          [CONTENT_TYPE.JSON]: {schema: getModelSchemaRef(Notification)},\n        },\n      },\n    },\n  })\n  async create(\n    @requestBody({\n      content: {\n        [CONTENT_TYPE.JSON]: {\n          schema: getModelSchemaRef(Notification, {exclude: ['id']}),\n        },\n      },\n    })\n    notification: Omit\u003cNotification, 'id'\u003e,\n  ): Promise\u003cNotification\u003e {\n    await this.notifProvider.publish(notification);\n  }\n}\n```\n\nAs you can see above, one controller method can now cater to all the different type of notifications.\n\n## Feedback\n\nIf you've noticed a bug or have a question or have a feature request, [search the issue tracker](https://github.com/sourcefuse/loopback4-notifications/issues) to see if someone else in the community has already created a ticket.\nIf not, go ahead and [make one](https://github.com/sourcefuse/loopback4-notifications/issues/new/choose)!\nAll feature requests are welcome. Implementation time may vary. Feel free to contribute the same, if you can.\nIf you think this extension is useful, please [star](https://help.github.com/en/articles/about-stars) it. Appreciation really helps in keeping this project alive.\n\n## Contributing\n\nPlease read [CONTRIBUTING.md](https://github.com/sourcefuse/loopback4-notifications/blob/master/.github/CONTRIBUTING.md) for details on the process for submitting pull requests to us.\n\n## Code of conduct\n\nCode of conduct guidelines [here](https://github.com/sourcefuse/loopback4-notifications/blob/master/.github/CODE_OF_CONDUCT.md).\n\n## License\n\n[MIT](https://github.com/sourcefuse/loopback4-notifications/blob/master/LICENSE)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcefuse%2Floopback4-notifications","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsourcefuse%2Floopback4-notifications","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsourcefuse%2Floopback4-notifications/lists"}