Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Server to Phonegap push: SignalR vs Azure Notification Hub

Well, I'm in a kind of a dilemma to go on with my Phonegap application development: for real time event notification, should I go with Azure Notification Hub or SignalR?

For my understanding, SignalR is good for real time web applications through the use of Web Sockets. Whereas notification hub makes it easy to send push notifications across multiple platforms. To make it easy to respond, let me explain the structure that I currently have and what my app is supposed to do.

The App: It's basically an app where users can create groups and invite other users. The user can also make a group "online" so other users can "enter" the group. While the group is online and the user have entered , they can send questions, exchange messages and so forth.

The need: When a user ask a question in a group, or enter/leave a group, the other users needs to see the new user in the app screen. I could do a polling on the server to check that and update the UI according, but this is something the modern days don't allow. My searches on the subject lead me to two things: SignalR and NotificationHub.

The current architecture: Client -> PhoneGap application with backbone.js. Backend -> Asp.NET Web API with Entity Framework and Azure Sql Server.

I've already put some thinking in the use of notification hubs and tags for that. For example, when a user enter an online group, it sends a request to the server to register a "grouplisten:{groupId}" tag. The server then registers the tag with the user's device and also fires a notification to all other devices with the tag "grouplisten:{groupId}", so the other users update the UI with the recently joined user. Also when the user leaves the group, it sends a request to the server to remove the "grouplisten:{groupId}" tag and also notifiy the devices with "grouplisten:{groupId}". But with this simple example, looks like this can become unmanageable.

like image 697
digaomatias Avatar asked Sep 15 '14 03:09

digaomatias


People also ask

What is azure notifications hub?

Azure Notification Hubs is a massively scalable mobile push notification engine for quickly sending millions of notifications to iOS, Android, Windows, or Kindle devices, working with APNs (Apple Push Notification service), GCM (Google Cloud Messaging), WNS (Windows Push Notification Service), and more.

How do I send Azure push notifications?

To set up Windows Push Notification Service (WNS): In the Azure portal, on the Notification Hub page, select Windows (WNS) from the left menu. Enter values for Package SID and Security Key. Select Save.

What is azure SignalR service?

Azure SignalR Service simplifies the process of adding real-time web functionality to applications over HTTP. This real-time functionality allows the service to push content updates to connected clients, such as a single page web or mobile application.

How do I make Azure notification hub?

Sign in to the Azure portal. Select All services on the left menu, search for Notification Hub, select star ( * ) next to Notification Hub Namespaces to add it to the FAVORITES section on the left menu. Select Notification Hub Namespaces. On the Notification Hub Namespaces page, select your namespace from the list.


1 Answers

Both technologies have their pros and cons on mobile platforms:

SignalR

Pros:

  • Well suited for real-time delivery where time or receiving notifications from the server is important.
  • Web clients are supported by all major browsers, IE8+, FireFox, Chrome, Safari and Android WebView, iOS Safari, IE mobile, so they are working well.
  • Solution could be written in JS, without need for the knowing

Cons:

  • Required dedicated server, but possible hosting with shared hosting probably, since not performance hungry.
  • In Cordova particularly requires manual connection management for better user experience, instead of relying on the re-connection mechanism which SignalR provides (This is required for iOS which could drop network connection for battery preserving, on Android not an issue so far).
  • It has a known issue with Safari on iOS (which needs to run with long polling configuration, you can find more on that issue here) which - on real world scenarios with frequent ajax requests - forces you to use a different IP address for the SignalR Server for a seamless experience on iOS.

Azure Notification Hub

Pros:

  • Use existing infrastructure of Google, Apple and MS to deliver notifications to the user and each of them not guarantee immediate delivery of the notifications. You have to read each platforms separately:
    • Apple: Quality Service section of APNS docs
    • Google: GCM Advanced Topics
  • No need for the dedicated server

Cons:

  • No guarantee for the immediate deleivery.
  • Required working with each native platform's languages. (There excellent plugin for Cordova https://github.com/sgrebnov/cordova-plugin-azure-notificationhub, but it is does not allow receiving notifications when application paused on Android and don't have 64 bit build on iOS)
like image 138
codevision Avatar answered Oct 05 '22 09:10

codevision