可一个iPhone应用程序充当服务器发送消息或推送通知? [英] Can an iPhone app act as a server to send messages or push notifications?

查看:173
本文介绍了可一个iPhone应用程序充当服务器发送消息或推送通知?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想写一个iOS应用程序,可以作为一个客户端的和行动的一个服务器向其他iPhone手机在蜂窝数据网络(即没有一个典型的集中式服务器)。该目标是通过通知一些手段来分享系列约200短事件消息,一次一个,从iPhone服务器到多个iPhone客户端。苹果推送通知服务将是罚款这样的通知,但没有必要专门使用它。

I want to write an iOS app that can act as a client and a server to other iPhones over the cellular data network (i.e., without a typical centralized server). The goal is to share series of about 200 short event messages, one at a time, from the iPhone server to multiple iPhone clients by some means of notification. Apple Push Notification service would be fine for such notifications, but there is no need to use it specifically.

我想发送推送通知从一个iPhone到另一个在<一个描述是从服务iPhone连接到 gateway.push.apple.com 可能href=\"http://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Introduction/Introduction.html#//apple_ref/doc/uid/TP40008194\"相对=nofollow>本地和推送通知编程指南,但我无法找到任何人讨论这个做法(也许是太明显了?)。

I think sending push notifications from one iPhone to another is possible by connecting to gateway.push.apple.com from the serving iPhone as described in the Local and Push Notification Programming Guide, but I can't find anyone else discussing this approach (maybe it's too obvious?).

这样做的原因是所有试图避免的基础设施的开销。如果这是不可行的,它最大限度地减少或避免额外的硬件方案是受欢迎的。

The reason for all this is an attempt to avoid the overhead of infrastructure. If this isn't feasible, alternatives which minimize or avoid additional hardware are welcome.

要求


  • 通信必须是[严格]通过蜂窝数据网络

    • 的Wi-Fi无法使用

    • 蓝牙没有足够的范围

    更新11年5月4日2:12 EST:只是要清楚,我没有使用的APN的任何特殊要求;我认为它可能在此设置一直是可行的,但是从下面的讨论,这听起来像那不是如此。不过,我仍然有兴趣在其他任何系统,可以帮助我实现某种类型的消息传递或通信的类似形式的相同的最终结果。

    Update 5/4/11 2:12 AM EST: Just to be clear, I don't have any particular requirement to use APNs; I thought it may have been feasible in this setup, but from the discussion below, it sounds like that's not the case. However, I'm still interested in any other system that could help me achieve the same end result with some type of message passing or similar form of communication.

    推荐答案

    从理论上讲,你应该能够编写一个iOS应用,可以连接到APNS并发送通知到运行的应用程序的其它设备。但是,您的主要问题将是实际获得的其它设备的令牌。当你有一个集中的服务器做的工作,它永远在线,因此,客户端可以通过HTTP'谈'它和注册它们自己(给他们的令牌到服务器的过程中)。因此,服务器知道客户端令牌,它可以使用它们通过APNS将通知发送给客户端。

    Theoretically you should be able to write a iOS app that can connect to the APNS and send notifications to other devices running your applications. However, your main problem will be to actually acquire the 'tokens' of other devices. When you have a centralized server doing the job, its always online and thus, the clients can 'talk' to it via http and register them self (giving their tokens to the server in the process). Thus the server knows the client token and it can use them to send notifications to the clients via APNS.

    但是,这是不可能的,你所谈到的情况。但是,这并不是说其是不可能的。可能是你可以使用一个电子邮件帐户X,来存储所有客户端的令牌。每个客户端将发送电子邮件到这个帐户与他们在它的令牌。所以,当一个又一个的客户想将通知发送到另一个客户端,它可以通过reffering的电子邮件帐户的收件箱中找出令牌(您可以缓存这些东西,当然在数不胜数的办法优化它)。

    However this is not possible in the scenario you are talking about. But this is not to say its impossible. May be you could use an email account X, to store all client tokens. Every client will send a email to this account with their token in it. So when a another 'client' want to send a notification to another client, it can find out the token by reffering to the inbox of the email account (you can cache this stuff and optimize it in a zillion ways of course).

    但问题是一些如何(第三方(例如:电子邮件服务提供商)/你自己)。服务器在线24/7将参与这个过程。

    But the point is some how a (third party(ex: email service provider)/your own) server that is online 24/7 will be involved in the process.

    让我们知道你是如何与这种进步。这将是有趣知道。

    Let us know how you progress with this. It would be interesting to know.

    这篇关于可一个iPhone应用程序充当服务器发送消息或推送通知?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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