What are the main differences between azure notification hub and mobile services
Which is best to use when.
Thanks
Those services have a totally different purpose.
Mobile Services allow you to provide a backend to (mobile) devices running your apps. Imagine a database that is exposed via a REST based API. You can react on CRUD operations by writing JavaScript code (Azure uses node.js for this purspose) and restrict the access to the database. This allows you to rapidly develop new apps (or at least proofs). Via JavaScript you can send push notifications by communicating the Windows Notification Service (WNS), the Apple Push Notification Service (APNS), etc. or by accessing an Azure Notification Hub, but that's not a native capability provided by the Mobile Services, it's just talking to external services.
Azure Notification Hub allows you to manage push subscriptions on multiple platforms (iOS, Android, WP8, Windows Store) with one single component. You no longer need to track the subscriptions in your own tables (like you would need to do with a solution just based on Mobile Services) and don't need to care about scaling. Imagine different devices registering at this hub and you have the ability to send a push message to those devices without the need to know, what kind of device you're talking to. It's just an abstraction of pushing messages.
To clearify:
Pseudo code with manual subscription handling vs. Notification Hub. Manual way with direct communication with WNS/APNS/...:
// query your data tables to determine the devices to notify
// note, that you need to manage (insert, delete) all of those entries as well
var subscriptions = ...;
for (var subscription in subscriptions )
{
if (subscription.Type == 0) // WP8
{
// communicate with the Windows Phone push service to push
}
else if (subscription.Type == 1) // iOS
{
// communicate with the Apple Push Notification Service push
}
else if // etc.
}
With Notification Hubs:
// determine subscriptions to notify by tag, it's just that simple
var tag = 'player:12345';
var hub = azure.createNotificationHubService(/* credentials */);
// you don't need to care about WNS/APNS/..., the hub will do that for you
hub.send(tag, yourMessage, /* callback */);
I hope you get the picture.
Last week happened the #AzureChat and they answered this question too:
Q4: When should I use push in Mobile Services vs push in Notification Hubs?
A4: Notification Hubs works with any backend, including Mobile Services, your custom backend in the cloud, or your on-premises backend. Use Notification Hubs with your custom backend (including on-premises), if your backend needs rich high scale personable push. Use Mobile Services direct push if your push needs in mobile services are direct. Use Mobile Services and Notification Hubs if you need richer push in your Mobile Services including broadcast & templating, etc. - @kirillg_msft
A4: Notification Hubs are optimized to broadcast millions of highly personalized push notifications within minutes. Mobile Services is great for sending event-triggered push notifications. In a two player game, for example, you would use push through Notification Hubs to broadcast special offers to everyone at once, but push through Mobile Services to notify Player B that Player A just completed his turn. - @mlunes90
http://blogs.msdn.com/b/windowsazure/archive/2013/10/11/recap-mobile-services-azurechat.aspx
Check the features/pricing of both on the official pages:
-
Azure Mobile Services provides a scalable cloud backend for building Windows Store, Windows Phone, Apple iOS, Android, and HTML/JavaScript applications. Store data in the cloud, authenticate users, and send push notifications to your application within minutes.
-
Azure Notification Hubs provides a highly scalable, cross-platform push notification infrastructure that enables you to either broadcast push notifications to millions of users at once or tailor notifications to individual users. You can use Notification Hubs with any connected mobile application—whether it’s built on Azure Virtual Machines, Cloud Services, Web Sites, or Mobile Services.
Use Azure Mobile Services if you need a server backend for your app, where you store data and implement server side logic. Azure Notification Hubs is included, which you can use for push notifications.
Use only Azure Notification Hubs if you don't need server side data or logic or are already using another service for this and only need a service to send push notifications.
来源:https://stackoverflow.com/questions/19424695/difference-between-azure-notification-hub-and-azure-mobile-services