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

以下是大杂烩:

  1. 不要用一个开源的叫javapns的lib来推送,这个项目代码臃肿混乱,过度设计,还内存溢出;可以使用notnoop.apns
  2. Push会延时,也会被丢弃,似乎网络情况,Push本身带有Expiry,超过该值APNS会丢掉Push
  3. Push有三个基本属性,alert、badge、sound,通过将一些置空,可以实现只修改App上的气泡不出现文本、出现文本但不提示声音,发出声音而不出现任何提示等等效果
  4. Push除了三个基本属性,还可以附带任意json数据,但总大小不能超过256字节
  5. 要异步发送Push,可以将应用内的Push序列化到Redis队列再消费,并且增加队列监控
  6. 和国外服务的连接速度比较慢,要建立多个连接,使用多线程发送
  7. APNS有提供feedback服务,用于查询一个Token是否有效
  8. 一台iPhone上的一个App会有两种Token,一种是Developer的,一种是正式Product的,不能混用,在一个与APNS的SSL连接里,使用Developer Token向Product发送Push是无法送达的,同时在十几秒内即使用正确的Product Token发送也无法送达,效果就像直接丢弃
  9. iPhone上的App处于前台运行时,即使受到Push也不会在界面出现提示,此时App内的回调函数会收到
  10. 高速地向一台设备发送大量Push,Apple会自动丢掉部分Push

陌陌架构分享 – Apple Push Notification Service的更多相关文章

  1. Provider Communication with Apple Push Notification Service

    This chapter describes the interfaces that providers use for communication with Apple Push Notificat ...

  2. (转)在SAE使用Apple Push Notification Service服务开发iOS应用, 实现消息推送

    在SAE使用Apple Push Notification Service服务开发iOS应用, 实现消息推送 From: http://saeapns.sinaapp.com/doc.html 1,在 ...

  3. (转)How to build an Apple Push Notification provider server (tutorial)

    转自:https://blog.serverdensity.com/how-to-build-an-apple-push-notification-provider-server-tutorial/ ...

  4. (转)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 ...

  5. (转)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 ...

  6. (转)苹果推送通知服务教程 Apple Push Notification Services Tutorial

    本文译自http://www.raywenderlich.com/.原文由iOS教程团队 Matthijs Hollemans 撰写,经原网站管理员授权本博翻译. 在iOS系统,考虑到手机电池电量,应 ...

  7. 远程通知APNs(Apple Push Notification Server)

    推送通知是由应用服务提供商发起的,通过苹果的APNs(Apple Push Notification Server)发送到应用客户端.下面是苹果官方关于推送通知的过程示意图: 推送通知的过程可以分为以 ...

  8. (转)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 ...

  9. Microsoft Push Notification Service(MPNS)的最佳体验

    如何获得 Microsoft Push Notification Service(MPNS)的最佳体验 有很多同学抱怨MPNS的各种问题,其中包括服务超时.返回各种错误代码不知如何处理等等..今天我用 ...

随机推荐

  1. wince6.0 编译报错:"error C2220: warning treated as error - no 'object' file generated"的解决办法

    内容提要:wince6.0编译报错:"error C2220: warning treated as error - no 'object' file generated" 原因是 ...

  2. 用Xstream时候遇到的两个小异常

    第一个 com.thoughtworks.xstream.converters.ConversionException: Cannot construct ClassXXX as it does no ...

  3. ScrollView与ListView嵌套使用,导致ListView下拉失效

    在一次项目开发中,在Scrollv中嵌套进ListView,当触摸ListView范围下拉时,整个展示页面滑动,而不是ListView内容滑动, 也就是说ListView滑动事件被ScrollView ...

  4. 实现Redhat Linux 6和Windows通过Windows Server AD统一认证并共享访问Oracle ZS存储系统

    Windows Server 2012 AD设置 1.  建立新的组织单位OU 为用户提前建立好OU,是为了AD用户管理简单清晰. 2.  建立新的用户和用户组 建立新的用户的时候,要同时将用户归属到 ...

  5. (function(){xxx})(); 写法解释

    常见格式:(function() { /* code */ })(); 解释:包围函数(function(){})的第一对括号向脚本返回未命名的函数,随后一对空括号立即执行返回的未命名函数,括号内为匿 ...

  6. JavaScript数组中出现的次数最多的元素

    var arr = [1,-1,2,4,5,5,6,7,5,8,6]; var maxVal = arr[0]; // 数组中的最大值 var minVal = arr[0]; // 数组中的最小值 ...

  7. Resin4下JSP文件导出问题的解决

           之前我在Resin3下采用JSP代码对一些硬盘上的文件作读取以后再输出或者生成一些特殊格式文件(如Excel)再输出供下载,这些文件输出JSP代码在Resin4以后输出的文件都产生错误无 ...

  8. mysql distinct field1,field2,field3, .... from table

    mysql distinct field1,field2,field3, .... from table 我们知道 这样的sql可以去掉重复项 (field1的重复项); select distinc ...

  9. SublimeText3常用快捷键和优秀插件

    SublimeText3常用快捷键和优秀插件 SublimeText是前端的一个神器,以其精简和可DIY而让广大fans疯狂.好吧不吹了直入正题 -_-!! 首先是安装,如果你有什么软件管家的话搜一下 ...

  10. 基于ThreadPoolExecutor,自定义线程池简单实现

    一.线程池作用 在上一篇随笔中有提到多线程具有同一时刻处理多个任务的特点,即并行工作,因此多线程的用途非常广泛,特别在性能优化上显得尤为重要.然而,多线程处理消耗的时间包括创建线程时间T1.工作时间T ...