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. lambda表达式初步

    // Lambda_test20140801.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <algorithm& ...

  2. obj-c中如何定义类的私有实例方法

    obj-c原生没有提供此项机制,不像java有private/protected/public方法的概念.obj-c中的@private以及类似的@protected和@public是用于修饰类的实例 ...

  3. LeetCode(29)-Plus One

    题目: Given a non-negative number represented as an array of digits, plus one to the number. The digit ...

  4. Cloud Carousel

    <div class="carousel1" id="carousel1" > <a href="#"><im ...

  5. Eclipse配置SpringBoot

    从这一博客开始学习SpringBoot,今天学习Eclipse配置SpringBoot.Eclipse导入SpringBoot有两种方式,一种是在线一个是离线方式. 一.在线安装 点击Eclipse中 ...

  6. 公司内网搭建代理DNS使用内网域名代替ip地址

    企业场景 一般在企业内部,开发.测试以及预生产都会有一套供开发以及测试人员使用的网络环境.运维人员会为每套环境的相关项目配置单独的Tomcat,然后开放一个端口,以 IP+Port 的形式访问.然而随 ...

  7. 重构:以Java POI 导出EXCEL为例

    重构 开头先抛出几个问题吧,这几个问题也是<重构:改善既有代码的设计>这本书第2章的问题. 什么是重构? 为什么要重构? 什么时候要重构? 接下来就从这几个问题出发,通过这几个问题来系统的 ...

  8. nginx 反向代理,支持跨域,前后分离

    前端开发往往涉及到跨域问题,其中解决方案很多: 1.jsonp 需要目标服务器配合一个callback函数. 2.window.name+iframe 需要目标服务器响应window.name. 3. ...

  9. 第一次作业 orm环境构建(hibernate)及基本的demo

    一.数据库 1.创建数据库hibernate01-1514010311 2.创建表 customer CREATE TABLE customer( id int(11) not null auto_i ...

  10. Python自学编程开发路线图(文中有免费资源)

    Python核心编程 免费视频资源<Python入门教程>:http://yun.itheima.com/course/145.html Python 基础学习大纲 所处阶段 主讲内容 技 ...