陌陌架构分享 – Apple Push Notification Service
http://blog.latermoon.com/?p=878
先描述下基本概念,标准的iPhone应用是没有后台运行的,要实现实时推送消息到手机,需要借助Apple提供的APNS服务。
iPhone会和APNS服务器保持长连接,每台iPhone针对每个App都会有一个唯一Token,要向一台手机发送即时消息,需要自己的服务器和APNS服务器建立连接,然后将信息(Payload)和要发往的设备Token发送给APNS服务器,剩下的推送就交给Apple了。

详细的官方文档:《Local
and Push Notification Programming Guide》
以下是大杂烩:
- 不要用一个开源的叫javapns的lib来推送,这个项目代码臃肿混乱,过度设计,还内存溢出;可以使用notnoop.apns
- Push会延时,也会被丢弃,似乎网络情况,Push本身带有Expiry,超过该值APNS会丢掉Push
- Push有三个基本属性,alert、badge、sound,通过将一些置空,可以实现只修改App上的气泡不出现文本、出现文本但不提示声音,发出声音而不出现任何提示等等效果
- Push除了三个基本属性,还可以附带任意json数据,但总大小不能超过256字节
- 要异步发送Push,可以将应用内的Push序列化到Redis队列再消费,并且增加队列监控
- 和国外服务的连接速度比较慢,要建立多个连接,使用多线程发送
- APNS有提供feedback服务,用于查询一个Token是否有效
- 一台iPhone上的一个App会有两种Token,一种是Developer的,一种是正式Product的,不能混用,在一个与APNS的SSL连接里,使用Developer Token向Product发送Push是无法送达的,同时在十几秒内即使用正确的Product Token发送也无法送达,效果就像直接丢弃
- iPhone上的App处于前台运行时,即使受到Push也不会在界面出现提示,此时App内的回调函数会收到
- 高速地向一台设备发送大量Push,Apple会自动丢掉部分Push
陌陌架构分享 – Apple Push Notification Service的更多相关文章
- Provider Communication with Apple Push Notification Service
This chapter describes the interfaces that providers use for communication with Apple Push Notificat ...
- (转)在SAE使用Apple Push Notification Service服务开发iOS应用, 实现消息推送
在SAE使用Apple Push Notification Service服务开发iOS应用, 实现消息推送 From: http://saeapns.sinaapp.com/doc.html 1,在 ...
- (转)How to build an Apple Push Notification provider server (tutorial)
转自:https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/ ...
- (转)Apple Push Notification Services in iOS 6 Tutorial: Part 2/2
转自:http://www.raywenderlich.com/32963/apple-push-notification-services-in-ios-6-tutorial-part-2 Upda ...
- (转)Apple Push Notification Services in iOS 6 Tutorial: Part 1/2
转自:http://www.raywenderlich.com/32960/apple-push-notification-services-in-ios-6-tutorial-part-1 Upda ...
- (转)苹果推送通知服务教程 Apple Push Notification Services Tutorial
本文译自http://www.raywenderlich.com/.原文由iOS教程团队 Matthijs Hollemans 撰写,经原网站管理员授权本博翻译. 在iOS系统,考虑到手机电池电量,应 ...
- 远程通知APNs(Apple Push Notification Server)
推送通知是由应用服务提供商发起的,通过苹果的APNs(Apple Push Notification Server)发送到应用客户端.下面是苹果官方关于推送通知的过程示意图: 推送通知的过程可以分为以 ...
- (转)How to renew your Apple Push Notification Push SSL Certificate
转自:https://blog.serverdensity.com/how-to-renew-your-apple-push-notification-push-ssl-certificate/ It ...
- Microsoft Push Notification Service(MPNS)的最佳体验
如何获得 Microsoft Push Notification Service(MPNS)的最佳体验 有很多同学抱怨MPNS的各种问题,其中包括服务超时.返回各种错误代码不知如何处理等等..今天我用 ...
随机推荐
- 速度之王 — LZ4压缩算法(一)
LZ4 (Extremely Fast Compression algorithm) 项目:http://code.google.com/p/lz4/ 作者:Yann Collet 本文作者:zhan ...
- Google主推-Android开发利器——Android Studio,这可能是最全的AS教程!
Android Studio使用手册 "工欲善其事必先利其器" 作为一个Android开发人员来说,一款好的开发工具也是相当重要的,在相当长的时间礼,Google都是基于Eclip ...
- 【Android 应用开发】对Android体系结构的理解--后续会补充
1.最底层_硬件 任何Android设备最底层的硬件包括 显示屏, wifi ,存储设备 等. Android最底层的硬件会根据需要进行裁剪,选择自己需要的硬件. 2.Linux内核层 该层主要对硬件 ...
- 图文并茂的生产者消费者应用实例demo
前面的几篇文章<<.NET 中的阻塞队列BlockingCollection的正确打开方式>><<项目开发中应用如何并发处理的一二事>>从代码以及理论角 ...
- java多继承
众所周知,java面向对象语言中只有单继承的编程语言,也许你会说,通过实现多个接口这种变通的方式达到多继承的目的.没错,你说的对,不过这并不是本片文章要说到的内容,本文要讲到的内容是java中实实在在 ...
- sql语句查询表中重复字段以及显示字段重复条数
今天跟大家分享两条SQL语句,是关于查询某表中重复字段以及显示该字段的重复条数. 1.select * from 表名 where 列名 in (select 列名 from 表名 group by ...
- JVM terminated. Exit code=8096
http://www-01.ibm.com/support/docview.wss?uid=swg21303648 Technote (troubleshooting) Problem(Abstrac ...
- Memocache 详细的工作机制
memcached集群 2013-04-26 13:56:37| 分类: memcached | 标签:集群 memcached |举报|字号 订阅 集群架构方面的问题 memcach ...
- 手把手教你用Jenkins自动发布dotnet core程序
Jenkins部分 首先,我们要有个Jenkins咯,下载链接:https://jenkins.io/download/ 我们安装官网教程安装好jenkins,安装教程略.... 嗯?不是说好手把手么 ...
- SQLServer2PostgreSQL迁移过程中的几个问题
1.PostgreSQL 跨平台迁移工具Migration Toolkit的使用指南:http://www.enterprisedb.com/docs/en/8.4/mtkguide/Table%20 ...