SkillAgentSearch skills...

NotificationHubs

Sample to help developers to implement Push Notification, through Azure Notification Hubs, in mobile applications.

Install / Use

/learn @saramgsilva/NotificationHubs
About this skill

Quality Score

0/100

Supported Platforms

Universal

README

Azure Notification Hubs Sample

This sample is related to the article from MSDN Magazine (April 2015):

Azure Notification Hubs: Best Pratices Managing Devices

<MTMarkdownOptions output='html4'> <a href="https://msdn.microsoft.com/pt-pt/magazine/dn948105(en-us).aspx"><img src="http://s20.postimg.org/ayjtmjbh9/MSDNMagazine_2.png" height="400"/></a>

:white_medium_square: Table of contents

:white_medium_square: What is this?

The sample provided has the goal to help developers add Push Notifications to their applications, through Azure Notification Hubs and this sample supports:

  • The two main ways to manage devices in Azure Notification Hubs, using the Registration Model:

    • Case 1 - Devices register directly in Azure Notification Hubs
    • Case 2 - Devices register in Azure Notification Hubs through backend
  • Azure Mobile Services;

:white_medium_square: Sample Status

  • Key: :white_check_mark: = Supported, :x: = Not Supported, :wrench: = In development
Windows Applications - Using XAML / CSharp

Platform | Azure Mobile Services| Registration Model (Case1) | Registration Model (Case2) | :---------- | :------------------------ | :------------------------ | :------------------------ | Windows Store 8.1 (WinRT) | :white_check_mark: | :white_check_mark: | :white_check_mark: Windows Phone 8.1 (WinRT) | :white_check_mark: | :white_check_mark: | :white_check_mark:
Windows Phone 8.1 (SL)| :white_check_mark: | :white_check_mark: | :white_check_mark:

Windows Applications - Using XAML / Visual Basic

Platform | Azure Mobile Services| Registration Model (Case1) | Registration Model (Case2) | :---------- | :------------------------ | :------------------------ | :------------------------ | Windows Store 8.1 (WinRT) | :white_check_mark: | :white_check_mark: | :white_check_mark: Windows Phone 8.1 (WinRT) | :white_check_mark: | :white_check_mark: | :white_check_mark:
Windows Phone 8.1 (SL)| :white_check_mark: | :white_check_mark: | :white_check_mark:

Xamarin Applications

Platform | Azure Mobile Services| Registration Model (Case1) | Registration Model (Case2) | :---------- | :------------------------ | :------------------------ | :------------------------ | Xamarin Android | :white_check_mark: | :white_check_mark: | :white_check_mark: | Xamarin IOS | :white_check_mark: | :white_check_mark: | :white_check_mark: |

Others

Platform | Azure Mobile Services| Registration Model (Case1) | Registration Model (Case2) | :---------- | :------------------------ | :------------------------ | :------------------------ | Android Native | :white_check_mark: | :x:| :x: | IOS Native | :x: |:white_check_mark:| :x:| Cordova | :x: | :x: | :x: |

:warning: Notes:

  1. The Windows Phone 8.0 implementation is similar to Windows Phone 8.1 SL implementation, this way it will not be provided.

  2. For Cordova apps, see the article MSDN Magazine - Push Notifications to Cordova Apps with Microsoft Azure by Glenn Gailey.

:white_medium_square: Requirements

  • Create the Azure Notification Hubs in Azure Portal (Azure Mobile Service create it by default)
  • Create the required data, in Push Notification Service (WNS, GCM, APNs...), to support push notification for each Platform
  • Configure the Azure Notification Hub, in Azure Portal, with the data from Push Notification Services (WNS, GCM, APNs...)
  • Add connection string and hub name from the Azure Notification Hub created (in the sample it is defined in Contants.cs file

:warning: Change required before run each sample

The Contants.cs file should be defined, which:

  • SenderID: define the ProjectID used in Xamarin Android and Android projects to request a registrationId from Google Cloud Messaging (GCM)

  • HubName: define the Notification Hub's name created in Azure Portal

  • ConnectionString: define the Notification Hub's connection string for the client applications connect with Notification Hub.

  • BackEndConnectionString: define the Notification Hub's connection string for the backend connect with Notification Hub.

  • AMSEndpoint: define the url from the Azure Mobile Services, used by the client application when create the object to connect with Azure Mobile Services

  • AMSKey: define the admin key used by the client application when create the object to connect with Azure Mobile Services.

:white_medium_square: The Source Code

The sample has the following project's struture:

  • Shared
  • BackEnd
  • Windows
    • CSharp
      • Windows Phone 8.1 (WinRT)
      • Windows Store Apps (WinRT)
      • Windows Phone 8.1 (SL)
    • Visual Basic
      • Windows Phone 8.1 (WinRT)
      • Windows Store Apps (WinRT)
      • Windows Phone 8.1 (SL)
  • Xamarin
    • Xamarin.Android
    • Xamarin.IOS

:white_medium_square: Build the projects

To develop on this project, just clone the project to your computer, package restore is enable so build the solution first, if you get any errors try to build again and if necessary close the solution and open again to load the references.

:white_medium_square: Resources

:white_medium_square: Common Issues

The following list provide some common issues I found when I did the sample or even when help others developers.

In General

  • The connection string from Notification Hubs is wrong;
  • The xml/json that define the template are not well defined;
  • When debug the notification is not using the correct tag or forget to use the tag;
  • Is missing the configurations in Azure Portal for each application;
  • In Azure Mobile Services developers uses the Notification Hubs API to manage devices and it is not necessary because Azure Mobile Service give us it out-of-box;
  • When developers implement the registration in devices do not use the debug feature to verify if the devices was registered correctly;
  • Developers implements the Case 1 when they want to implement the Case 2 and mixes the two cases;

In Windows (WinRT) apps:

  • In manifest should be defined the Toast capable;
  • In manifest should be defined the Internet capability;
  • Associate with store;

In Windows Phone (SL) apps:

  • In manifest should be defined Internet capability, Toast capable and the ID_CAP_PushNotification
  • Should be handled the notification when the app is running

In Android apps:

  • The Project Id is wrong;
  • The GCM component is missing;
  • In debug mode, after stop the debug be aware that is need to run again the app to receive the notifications;
  • The manifest file must have the package's name starting with lower case;
  • The key used in the payload is not the same in the application;

In iOS apps:

  • To enable push notification is required the certificates that enable it. The process is not simple to create it and it is easy to do a mess between steps;
  • Developers should confirm which version of the certificate is on Azure Portal and it is used by application. This means if in Azure Portal has the production certificate the application must have the production certificate;
  • The plist must have the push notification checked and the bundle must match with the bounded created;

:white_medium_square: Tips

Azure Notification Hubs API

:warning: It was published a new nuget: Microsoft Azure Notification Hubs

Used in Case 2 sample

Platform | Azure Notification Hubs API :---------- | :------------------------ Windows Store 8.1 (WinRT) | WindowsAzure.Messaging.Managed Windows Phone 8.1 (WinRT) | WindowsAzure.Messaging.Managed Windows Phone 8.1 (SL)| WindowsAzure.Messaging.Managed Xamarin Android | Azure Messaging Xamarin IOS | [Azure Messaging](ht

View on GitHub
GitHub Stars24
CategoryDevelopment
Updated4mo ago
Forks15

Languages

C#

Security Score

87/100

Audited on Oct 31, 2025

No findings