@mfbhatt/azure-push-notifications
TypeScript icon, indicating that this package has built-in type declarations

1.0.12 • Public • Published

push-notifications

The Push Notifications API provides access to native push notifications for Capacitor.

Install

npm install @mfbhatt/push-notifications
npx cap sync

Example

import {
  AzurePushNotifications,
  AzurePushNotificationSchema,
  PushNotificationActionPerformed,
  PushNotificationToken,
} from '@mfbhatt/azure-push-notifications';

Usage

AzurePushNotifications.requestPermissions().then((result) => {
      AzurePushNotifications.register({
        notificationHubName: '<AZURE NOTIFICATION HUB NAME>',
        connectionString:
          '<AZURE NOTIFICATION CONNECTION STRING>',
        deviceTag: '<DEVICE TAG>',
      }).then(() => {
        AzurePushNotifications.addListener(
          'registration',
          (token: PushNotificationToken) => {
            alert('Push registration success, token: ' + token.value);
          }
        );
      });
    });

Listners

AzurePushNotifications.addListener(
          'registrationError',
          (error: any) => {
            alert('Error on registration: ' + JSON.stringify(error));
          }
        );

        AzurePushNotifications.addListener(
          'pushNotificationReceived',
          (notification: AzurePushNotificationSchema) => {
            alert('Push received: ' + JSON.stringify(notification));
          }
        );
        AzurePushNotifications.addListener(
          'pushNotificationActionPerformed',
          (notification: PushNotificationActionPerformed) => {
            alert('Push action performed: ' + JSON.stringify(notification));
          }
        );

/@mfbhatt/azure-push-notifications/

    Package Sidebar

    Install

    npm i @mfbhatt/azure-push-notifications

    Weekly Downloads

    6

    Version

    1.0.12

    License

    MIT

    Unpacked Size

    68 kB

    Total Files

    26

    Last publish

    Collaborators

    • mfbhatt
    • prashant.nigs
    • divakarlasrinivas