⚡️ Capacitor plugin to register push notifications via Azure Notification Hub.

Overview


Azure Notification Hubs

@jonz94/capacitor-azure-notification-hubs

Capacitor plugin to register push notifications via Azure Notification Hub.

Install

npm install @jonz94/capacitor-azure-notification-hubs @capacitor/push-notifications
npx cap sync

iOS

On iOS you must enable the Push Notifications capability. See Setting Capabilities for instructions on how to enable the capability.

After enabling the Push Notifications capability, add the following to your app's AppDelegate.swift:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
  NotificationCenter.default.post(name: .capacitorDidRegisterForRemoteNotifications, object: deviceToken)
}

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error) {
  NotificationCenter.default.post(name: .capacitorDidFailToRegisterForRemoteNotifications, object: error)
}

Android

The Push Notification API uses Firebase Cloud Messaging SDK for handling notifications. See Set up a Firebase Cloud Messaging client app on Android and follow the instructions for creating a Firebase project and registering your application. There is no need to add the Firebase SDK to your app or edit your app manifest - the Push Notifications provides that for you. All that is required is your Firebase project's google-services.json file added to the module (app-level) directory of your app.

Variables

This plugin will use the following project variables (defined in your app's variables.gradle file):

  • $firebaseMessagingVersion version of com.google.firebase:firebase-messagin (default: 23.0.5)
  • $azureNotificationHubsVersion version of com.microsoft.azure:notification-hubs-android-sdk-fcm (default: 1.1.4)
  • $androidVolleyVersion version of com.android.volley:volley (default: 1.2.1)
  • $kotlinVersion version of org.jetbrains.kotlin:kotlin-stdlib-jdk7 (default: 1.7.10)
  • $coreKtx version of androidx.core:core-ktx (default: 1.8.0)

Configuration

No configuration required for this plugin.

Usage

import { Device } from '@capacitor/device';
import { PushNotifications } from '@capacitor/push-notifications';
import { AzureNotificationHubs } from '@jonz94/capacitor-azure-notification-hubs';

const addListeners = async () => {
  await AzureNotificationHubs.addListener('registration', token => {
    console.info('Registration token: ', token.value);
  });

  await AzureNotificationHubs.addListener('registrationError', err => {
    console.error('Registration error: ', err.error);
  });
}

const registerNotifications = async () => {
  let permissionStatus = await PushNotifications.checkPermissions();

  if (permissionStatus.receive === 'prompt') {
    permissionStatus = await PushNotifications.requestPermissions();
  }

  if (permissionStatus.receive !== 'granted') {
    throw new Error('User denied permissions!');
  }

  const { uuid } = await Device.getId();

  const myDeviceTag = `${uuid}-${Date.now()}`

  await AzureNotificationHubs.register({
    notificationHubName: 'azure-notification-hub-name',
    connectionString: 'my-connection-string',
    deviceTag: myDeviceTag,
  });
}

API

register(...)

register(info: RegisterInfo) => Promise<void>

Register the app to receive push notifications.

This method will trigger the 'registration' event with the push token or 'registrationError' if there was a problem. It does not prompt the user for notification permissions, use PushNotifications.requestPermissions() from @capacitor/push-notifications first.

Param Type
info RegisterInfo

Since: 1.0.0


addListener('registration', ...)

addListener(eventName: 'registration', listenerFunc: (token: Token) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the push notification registration finishes without problems.

Provides the push notification token.

Param Type
eventName 'registration'
listenerFunc (token: Token) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


addListener('registrationError', ...)

addListener(eventName: 'registrationError', listenerFunc: (error: RegistrationError) => void) => Promise<PluginListenerHandle> & PluginListenerHandle

Called when the push notification registration finished with problems.

Provides an error with the registration problem.

Param Type
eventName 'registrationError'
listenerFunc (error: RegistrationError) => void

Returns: Promise<PluginListenerHandle> & PluginListenerHandle

Since: 1.0.0


removeAllListeners()

removeAllListeners() => Promise<void>

Remove all native listeners for this plugin.

Since: 1.0.0


Interfaces

RegisterInfo

Prop Type Description Since
notificationHubName string The notification hub name. 1.0.0
connectionString string The connection string. 1.0.0
deviceTag string The device tag. 1.0.0

PluginListenerHandle

Prop Type
remove () => Promise<void>

Token

Prop Type Description Since
value string On iOS it contains the APNS token. On Android it contains the FCM token. 1.0.0

RegistrationError

Prop Type Description Since
error string Error message describing the registration failure. 1.0.0

Changelog

See CHANGELOG.md.

License

See LICENSE.

You might also like...
'Minimalistic Push' is a minimalistic push-up application now built with Flutter.
'Minimalistic Push' is a minimalistic push-up application now built with Flutter.

Minimalistic Push Minimalistic Push is one of the simplest push-up trackers out there. You can track your push-ups in the training mode and see an ove

Apple Push Notifications (APNs) Server-Side library.
Apple Push Notifications (APNs) Server-Side library.

Perfect-Notifications 简体中文 APNs remote Notifications for Perfect. This package adds push notification support to your server. Send notifications to iO

A SwiftUI iOS App and Vapor Server to send push notifications fueled by Siri Shortcuts.
A SwiftUI iOS App and Vapor Server to send push notifications fueled by Siri Shortcuts.

Puffery An iOS App written in SwiftUI to send push notifications fueled by Siri Shortcuts. You can follow other's channels and directly receive update

Push notifications allow developers to reach users, even when users aren't actively using an app!
Push notifications allow developers to reach users, even when users aren't actively using an app!

Push notifications allow developers to reach users, even when users aren't actively using an app! With the latest update of iOS Apple provide very useful extensions which are user-friendly. In this tutorial, I am going to share the configuration, set up of Notification with the media attachments like.

Apple Push Notifications (APNs) Server-Side library.
Apple Push Notifications (APNs) Server-Side library.

Perfect-Notifications 简体中文 APNs remote Notifications for Perfect. This package adds push notification support to your server. Send notifications to iO

Pushkin is a free open source tool for sending push notifications
Pushkin is a free open source tool for sending push notifications

Unmaintained This repository is no longer maintained. Pushkin Introduction Pushkin is a free open source tool for sending push notifications. It was d

A simple, reliable and scalable delivery API for transactional push notifications for websites and applications
A simple, reliable and scalable delivery API for transactional push notifications for websites and applications

Catapush is a simple, reliable and scalable delivery API for transactional push notifications for websites and applications. Ideal for sending data-dr

A framework for easily testing Push Notifications and Routing in XCUITests
A framework for easily testing Push Notifications and Routing in XCUITests

Mussel 🦪 💪 A framework for easily testing Push Notifications, Universal Links and Routing in XCUITests. As of Xcode 11.4, users are able to test Pus

Simplifies iOS user permission requests (location, push notifications, camera, contacts, calendar, photos, etc).

ICanHas Swift 4 library that simplifies iOS user permission requests (push notifications, location, camera, photo library, contacts, calendar). Instal

An iOS pre-permissions utility that lets developers ask users on their own dialog for calendar, contacts, location, photos, reminders, twitter, push notifications and more, before making the system-based permission request.

An iOS pre-permissions utility that lets developers ask users on their own dialog for calendar, contacts, location, photos, reminders, twitter, push notifications and more, before making the system-based permission request.

The ToDoList application using FireBase allows you to register users
The ToDoList application using FireBase allows you to register users

ToDoFirebase Приложение ToDoList с использовавнием FireBase позволяет зарегистри

Build native iOS, Android, and Web apps with Capacitor and Remix.run 💿

This repository holds production ready Capacitor templates for building native mobile applications using Remix. Using Capacitor, you can quickly build out a native mobile application for iOS and Android using web technology, such as Remix.

🤨 Apple Push Notification service tutorial
🤨 Apple Push Notification service tutorial

APNsTutorial-iOS 🤨 Apple Push Notification service tutorial 단순히 순서를 따라서 가면 될 줄 알았는데 알아야할 것도 있었고 경우에 따라서 요구하는 파일도 달랐다. 그러니 천천히 읽어주시기 바랍니다. 먼저 어떤 서버 환경

A simple and attractive AlertView to ask permission to your users for Push Notification.
A simple and attractive AlertView to ask permission to your users for Push Notification.

A simple and attractive AlertView **to ask permission to your users for Push Notification.** PRESENTATION Ask permission to user for push notification

How to Add Local Push Notification With timeInterval & Test On Simulator

Technicalisto How to Add Local Push Notification With timeInterval & Test On Simulator In Project Target ( Signing & Capapilities ) Add Capapility : 1

Push Notification Registration for iOS

Orbiter Note: This project is no longer being maintained. For most iOS client / server applications, push notifications are negotiated through an inte

The debug application for Apple Push Notification Service (APNs).
The debug application for Apple Push Notification Service (APNs).

Knuff The debug application for Apple Push Notification Service (APNs). Download the latest version Features Send push notifications to APNS (Apple Pu

OS X and iOS application and framework to play with the Apple Push Notification service (APNs)
OS X and iOS application and framework to play with the Apple Push Notification service (APNs)

Pusher OS X and iOS application and framework to play with the Apple Push Notification service (APNs) Installation Install the Mac app using Homebrew

Releases(v1.0.2)
A library to inject your dependencies via property wrappers

?? DependencyInjection A library to inject your dependencies via property wrappers ?? Features DependencyInjection allows you to define the dependenci

Alberto Garcia 4 Dec 10, 2022
Elm-parcel-capacitor - A sample setup to build an app with Elm, Capacitor, Parcel and Tailwind CSS

Elm, Capacitor, Parcel and Tailwindcss This project is a sample setup to build a

Anthonny Quérouil 10 May 9, 2022
null 4 May 22, 2022
Push Hero - pure Swift native macOS application to test push notifications

Dropdowns ❤️ Support my app ❤️ Push Hero - pure Swift native macOS application to test push notifications Quick Access - Organise files in the Mac men

Khoa 307 Oct 17, 2022
OS X app for sending push with Apple Push Notification service (APNs)

pushHandle OS X app for sending push with Apple Push Notification service (APNs) About This app was created just to allow painless testing of push not

hbk3 3 Nov 17, 2022
A simple framework to output to a file, url, the console, or even register notification using UserNotifications

o is a simple framework to output to a file, url, the console, or even register notification using UserNotifications. o can also get input from a file, url, or console.

OpenBytes 4 Mar 18, 2022
An example implementation of using a native iOS Notification Service Extension (to display images in remote push notification) in Titanium.

Titanium iOS Notification Service Extension An example implementation of using a native iOS Notification Service Extension (to display images in remot

Hans Knöchel 8 Nov 21, 2022
Capacitor File Opener. The plugin is able to open a file given the mimeType and the file uri

Capacitor File Opener. The plugin is able to open a file given the mimeType and the file uri. This plugin is similar to cordova-plugin-file-opener2 without installation support.

Capacitor Community 32 Dec 21, 2022
Team Kodi 15k Jan 8, 2023
Hubby, the hub for workout buddies

Summary You've got a Google Fit and your friend has an Apple Watch. How do you keep up with each another's workouts and activity? Hubby is the hub for

Jaafar Rammal 1 Feb 8, 2022