cowinr
8/8/2019 - 3:13 PM

Notification Hubs

General

A multi-platform, scalable push-notification engine.

Targets iOS, Android, Windows, Kindle, Baidu, etc.

Back-ends: cloud or on-premises.

Platform Notification Systems

Push notifications delivered through platform-specific infrastructures called Platform Notification Systems (PNSs).

To send a notification to all customers across the Android, iOS, and Windows versions of an app, the developer must work with Apple Push Notification Service (APNS), Firebase Cloud Messaging (FCM), and Windows Notification Service (WNS) separately.

Why Notification Hub

  • Eliminates all complexities associated with pushing notifications on your own from your app backend.
  • Support for all major push platforms.
  • Common interface to push to all platforms.
  • .NET, Node.js, Java, Python, etc.
  • Rich set of delivery patterns
    • Broadcast to one or multiple platforms
    • Push to device
    • Push to user
    • Push to segment with dynamic tags
    • Localized push
    • Silent push
    • Scheduled push
    • Direct push
    • Personalized push
var channel = await PushNotificationChannelManager.CreatePushNotificationChannelForApplicationAsync();
var hub = new NotificationHub("[HubName]", "[DefaultListenSharedAccessSignature]");
var result = await hub.RegisterNativeAsync(channel.Uri);

// Displays the registration ID so you know it was successful
if (result.RegistrationId != null)
{
    var dialog = new MessageDialog("Registration successful: " + result.RegistrationId);
    dialog.Commands.Add(new UICommand("OK"));
    await dialog.ShowAsync();
}
var nhClient = NotificationHubClient.CreateClientFromConnectionString("ConnectionString", "HubName");

// Register fake device - Firebase
var fcmDeviceId = Guid.NewGuid().ToString();
var fcmInstallation = new Installation
{
    InstallationId = "fake-fcm-install-id",
    Platform = NotificationPlatform.Fcm,
    PushChannel = fcmDeviceId,
    PushChannelExpired = false,
    Tags = new[] { "fcm" }
};
await nhClient.CreateOrUpdateInstallationAsync(fcmInstallation);

// Broadcast
var outcomeFcm = await nhClient.SendFcmNativeNotificationAsync(FcmSampleNotificationContent);