服务器到PhoneGap推送:SignalR与Azure通知中心 [英] Server to Phonegap push: SignalR vs Azure Notification Hub

查看:339
本文介绍了服务器到PhoneGap推送:SignalR与Azure通知中心的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我有一个困境继续我的Phonegap应用程序开发:对于实时事件通知,我应该去Azure Notification Hub或SignalR?

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?

为了我的理解,SignalR适用于通过使用Web套接字的实时Web应用程序。而通知中心可以轻松地在多个平台之间发送推送通知。
为了方便回复,让我解释一下我目前的结构以及我的应用程序应该做什么。

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.

需要:
当用户在群组中提出问题或输入/离开群组时,其他用户需要在应用程序屏幕。我可以在服务器上进行轮询检查和更新UI,但这是现代日子不允许的东西。我对这个主题的搜索引导我两个东西:SignalR和NotificationHub。

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.

当前的架构:
Client - > PhoneGap应用程序与backbone.js。
后端 - > Asp.NET Web API与Entity框架和Azure Sql Server。

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

我已经在使用通知集线器和标签时考虑过了。
例如,当用户输入在线组时,它向服务器发送注册grouplisten:{groupId}标记的请求。服务器然后向用户的设备注册标签,并且还向具有标签grouplisten:{groupId}的所有其他设备发出通知,因此其他用户用最近加入的用户更新UI。此外,当用户离开组时,它向服务器发送删除grouplisten:{groupId}标记的请求,并使用grouplisten:{groupId}命令通知设备。但是用这个简单的例子,看起来像这样可以变得难以管理。

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.

推荐答案

这两种技术在移动平台上都有其优缺点:

Both technologies have their pros and cons on mobile platforms:

优点:


  • 非常适合实时交货

  • 所有主流浏览器,IE8 +,FireFox,Chrome,Safari和Android WebView,iOS Safari,IE移动都支持Web客户端,因此他们正在工作

缺点:


  • 需要专用服务器,但可能是托管共享托管,因为性能不高。

  • 在Cordova,特别需要手动连接管理,以获得更好的用户体验,而不是依赖于SignalR提供的重新连接机制(这是需要的iOS,可以放弃网络连接电池保持,在Android上不是迄今为止的问题)。

  • 它在iOS上的Safari上有一个已知问题(需要使用长轮询配置运行,您可以在这里找到更多的问题在这里) - 在真实情况下与频繁ajax请求 - 强制您使用不同的IP地址为SignalR服务器在iOS上的无缝体验。

  • 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.

优点:


  • 使用Google,Apple和MS的现有基础架构向用户发送通知,而且每个人都不能保证立即传送通知。您必须分别阅读每个平台:
    • 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 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)

      这篇关于服务器到PhoneGap推送:SignalR与Azure通知中心的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆