陌陌架构分享 – 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的各种问题,其中包括服务超时.返回各种错误代码不知如何处理等等..今天我用 ...
随机推荐
- Aandroid 图片加载库Glide 实战(一),初始,加载进阶到实践
原文: http://blog.csdn.net/sk719887916/article/details/39989293 skay 初识Glide 为何使用 Glide? 有经验的 Android ...
- LeetCode(69)-Reverse String
题目: Write a function that takes a string as input and returns the string reversed. Example: Given s ...
- Mac OS X汇编语言常识
首先OS X的syscall表位置在 /usr/include/sys/syscall.h
- 恶补web之七:html DOM知识
html DOM定义了访问和操作html文档的标准;dom是w3c的标准,dom定义了访问html和xml文档的标准: w3c文档对象模型(dom)是中立平台和语言的接口,它允许程序和脚本动态访问和更 ...
- eclipse中英文(等各国语言)版本转换发放
eclipse界面语言的切换方法 1.该方法只支持安装过中文包的eclipse(其实中文包中几乎包含了全世界所有的语言,只是调用了其中的中文简体而已) 2.在桌面的快捷方式中目标的地址后面加上参数-n ...
- 在 javascript 中,为什么 [1,2] + [3,4] 不等于 [1,2,3,4]?
在 stackoverflow 上有人提问:arrays - Why does [1,2] + [3,4] = "1,23,4" in JavaScript? 问题 我想将一个数组 ...
- left join 原理分析
left join 原理分析 [转贴 2006-11-15 16:19:50] 字号:大 中 小 案例分析 user表: id | name --------- 1 | libk ...
- Python人工智能之-三大数学难点 !
1. 微积分: 定积分与不定积分.全微分.最小二乘法.二重积分.微分方程与差分方程等... 2. 线性代数: 行列式.矩阵.向量.线性方程组.矩阵的特性和特性向量.二次型等... 3. 概率论和统计学 ...
- AWS技术会议笔记
Intel和云: SDI:软件定义架构 3D-XPointer:可以媲美内存速度的SSD 应用可以控制L3 Cache的使用 Helix物联网设备用 精益创业之路: 如何快速获得第一批用户---先要养 ...
- sql server数据字符串分割功能sql
--分割字符串函数 create FUNCTION [dbo].[GetSplitStringValueInIndex] ( ), --要分割的字符串 ), --分隔符号 @index INT --取 ...