陌陌架构分享 – 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的各种问题,其中包括服务超时.返回各种错误代码不知如何处理等等..今天我用 ...
随机推荐
- 使用“万能数据库查询分析器”的Windows 7、Windows 8、Windows 10的用户须知
与以前的Windows操作系统版本(包括WinXP/VISTA/Windows2000/WindowsNt/Win98)不同,Windows 7.Windows 8.Windows 10短日期采用的分 ...
- java--加强之 jdk1.5简单新特性,枚举,注解
转载请申明出处:http://blog.csdn.net/xmxkf/article/details/9944041 Jdk1.51新特性(静态导入,可变参数,加强for循环,自动拆装箱) 08.ja ...
- redis存入中文,取出来显示不正常
问题: 127.0.0.1:6379> set name 张泰松OK127.0.0.1:6379> get name"\xe5\xbc\xa0\xe6\xb3\xb0\xe6\x ...
- 学习MQ(一) 感知
声明:我的文字里出现的MQ,如没有特殊指明,就是指的IBM的websphere MQ 以前对MQ一无所知! MQ是IBM websphere的系列产品之一,是很好的一个中间件产品.其实我对这列产品并不 ...
- org.eclipse.swt.SWTException: Invalid thread access问题解决方法
转自 http://blog.csdn.net/ecjtuxuan/article/details/2125023 怎么解决SWT多线程错误:Caused by: org.eclipse.swt.SW ...
- plsql developer 使用 oracle instantclient的安装和配置
本文由ibyedo1贡献 1.下载 oracle instantclient basic package,在 oracle 官网下载就可以,地址如下: http://www.oracle.com/te ...
- jquery选择器项目实例分析
首先废话一句,jQuery选择器真心很强大! 在项目中遇到这么一个问题easyui的问题 如图所示,当前页面显示的是"原始报文查询"的页面,当时左侧导航栏却选中的是"重 ...
- Mysql安装和登录相关操作
一.mysql的下载和安装 1.下载链接地址 http://dev.mysql.com/downloads/mysql/ 安装如下操作进行下载. 2.mysql数据库安装(Windows环境) 1.解 ...
- C++各个存储区
#include<iostream.h>void main(){char a[]="abc";栈 char b[]="abc";栈 char* c= ...
- Linux 下常用的Shell 命令
英文原文链接:https://www.lopezferrando.com/30-interesting-shell-commands/ 1. 监控命令(每2秒运行一次) watch "ls ...