Azure Notification Hubs provide an easy-to-use and scaled-out push engine that allows you to send notifications to any platform (iOS, Android, Windows, Kindle, Baidu, etc.) from any backend (cloud or on-premises). Push notifications is a form of app-to-user communication where users of mobile apps are notified of certain desired information, usually in a pop-up or dialog box on a mobile device.
This plugin allows Flutter developers to extend their apps with Azure Notification Hub functionality. For this plugin to work, one must setup a Notification Hub within Azure and add the necessary capabilities within the project.
Currently, this plugin only functions for iOS. Android support is planned.
To install this plugin, add azure_notification_hubs as a dependency in your pubspec.yaml file.
Refer to https://docs.microsoft.com/en-us/azure/notification-hubs/notification-hubs-ios-push-notifications-swift-apps-get-started to create your own Azure Notification Hub.
In XCode, find your target's Signing & Capabilities tab. Add Push Notifications and Background Modes. Additionally, in the Background Modes capability, check Background fetch and Remote notifications.
AzureNotificationHubs
init
function, passing your:
register
function to subscribe to the previously passed tags.unregister
function to unsubscribe from all tags.Push Notifications only work on a physical device, the simulator will not suffice!
To run the example, first clone the repo
git clone https://github.com/Sally-Assistant/azure_notification_hubs.git
Then you must set the NHInfoConnectionString
and NHInfoHubName
according to the data in your Notification Hub.
NHInfoHubName
is the name of your Notification Hub.NHInfoConnectionString
should be in the following format:
Endpoint=sb://<namespace>.servicebus.windows.net/;SharedAccessKeyName=<notificationHubKeyName>;SharedAccessKey=<notificationHubKey>
Finally, execute the following inside the example directory:
flutter run
You should be able to enter custom tags to register to upon which the app asks you for permission. You can then test send notifications to the device.
Push Notifications only work on a physical device, the simulator will not suffice!