- What is this?
- Requirements
- Sample Status
- The Solution
- Screenshots
- Resources
- Common Issues
- Tips
- Build the project
- Contributors
- Contribute
- License
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:
- Case 1 - Devices register directly in Azure Notification Hubs
- Case 2 - Devices register in Azure Notification Hubs through backend
- 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 connectiong string and hub name from the Azure Notification Hub created (in the sample it is defined in Contants.cs file)
- Key: ✅ = Supported, ❌ = Not Supported, 🔧 = In development
Platform | Case 1 | Case 2 using WebAPI (V1) | Case 2 using WebAPI (V2) | Case 2 using AMS (V2) |
---|---|---|---|---|
Windows Store 8.1 (WinRT) | ✅ | ✅ | ✅ | ✅ |
Windows Phone 8.1 (WinRT) | ✅ | ✅ | ✅ | ✅ |
Windows Phone 8.1 (SL) | ✅ | ✅ | ✅ | ✅ |
Xamarin Android | ✅ | ✅ | ✅ | ✅ |
Xamarin IOS | 🔧 | 🔧 | 🔧 | 🔧 |
Android Native | ❌ | ❌ | ❌ | ❌ |
IOS Native | ✅ | ❌ | ❌ | ❌ |
-
The Case V1 was created in June 2014 following the documentation, but it changed and the Case 2 V2 was created to show the new version. At the end all version will work and for example the Azure Mobile Services will uses a solution similar to the Case 2 V1.
-
The Windows Phone 8.0 implementation is similar to Windows Phone 8.1 SL implementation, this way it will not be provided.
-
For Cordova apps, see the article MSDN Magazine - Push Notifications to Cordova Apps with Microsoft Azure by Glenn Gailey.
The solution have two main cases:
- Case 1 - Devices register directly in Azure Notification Hubs
- Case 2 - Devices register in Azure Notification Hubs through backend
Solution showing the main folders (Case 1 and Case 2)
Solution showing projects provided for Case 1 - Devices register directly in Azure Notification Hubs
Solution showing main folders for Case 2 - Devices register in Azure Notification Hubs through backends (Version V1 and V2)
Solution showing projects provided for Case 2 - Devices register in Azure Notification Hubs through backends
The Sceenshots folder contains image for each platform provided.
Presentation
[MSDN Documentation] (http://msdn.microsoft.com/en-us/library/jj891130.aspx)
[Curah! Azure Notification Hubs] (https://curah.microsoft.com/72603/notification-hubs)
[Azure Notification Hubs – All resources you need](http://www.saramgsilva.com/index.php/2014/azure-notification-hubs-all-resources-you-need/)
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;
Push Notification Service by Platform
Platform | Push Notification Service |
---|---|
Windows Store 8.1 (WinRT) | Windows Push Notification Services (WNS) |
Windows Phone 8.1 (WinRT) | Windows Push Notification Services (WNS) |
Windows Phone 8.1 (SL) | Microsoft Push Notification Service (MPNS) |
Windows Phone 8.0 (SL) | Microsoft Push Notification Service (MPNS) |
Android | Google Cloud Service (GCM) |
IOS | Apple Push Notification Service (APNs) |
Development In Xamarin.Android
If you are using simulator and do the deploy for install the app or debug it, you can receive Push Notification while the app run, but if you stop and try to send another Push Notification the simulator will not receive it, you should run again the app without VS to get the push notification
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.
Everbody is welcome to contribute, only is required to provide all cases to manage devices in Azure Notification Hubs.
Twitter hashtag : #notificationhubs
MIT License (MIT), read more about it in the LICENSE file.