Apple Push Notification Service:通过苹果服务器向app用户推送消息,无需启动app。

苹果官方文档:http://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_ref/doc/uid/TP40008194-CH100-SW9

对于这种第三方库,PHP官方称之为PEAR,需要按照PEAR标准开发(标准URI)。

PEAR的优势:一键安装到php/lib/php目录,require即可使用,很方便。

PHP PEAR上有一个Services_Apns,github上有一个Services_APNS,但都无法使用,所以我开发了一个,安装步骤如下:

pear channel-discover sinkcup.github.io/pear
pear install sinkcup/Services_Apple_PushNotification

使用步骤:

1、登录苹果开发者后台,下载dev或prod证书,合并成pem文件。在ios app里添加push权限,获得device token。参考:http://www.cnblogs.com/gpwzw/archive/2012/03/31/Apple_Push_Notification_Services_Tutorial_Part_1-2.html

2、demo(参考)

<?php
require_once 'Services/Apple/PushNotification.php';
$conf = array(
'password' => '',
'cert' => '/home/u1/cert.pem-sandbox',
);
$o = new Services_Apple_PushNotification('sandbox', $conf);
$deviceToken = 'aaaf818eaae8a5aa11aaaf9aa8f8aa15aaefae75a1aaaa597e51917aa2a1a111';
$data = array(
'aps' => array(
'alert' => '测试push sandbox',
'badge' => ,
'sound' => 'default',
)
);
$r = $o->send($deviceToken, $data);
var_dump($r);
exit;
?>

输出:

bool(true)

我的PEAR 频道:http://sinkcup.github.io/pear/

Services_Apple_PushNotification项目代码:https://github.com/sinkcup/Services_Apple_PushNotification

为Apple Push开发的PHP PEAR 包:Services_Apple_PushNotification的更多相关文章

  1. 为七牛云存储开发的PHP PEAR 包:Services_Qiniu

    七牛云存储Qiniu Resource (Cloud) Storage:用于存储图片.apk等静态资源. 优点: 1.使用七牛带宽和CDN,速度快,不占用开发者服务器. 2.支持图片任意格式.任意分辨 ...

  2. 为阿里云存储开发的PHP PEAR 包:Services_Aliyun_OSS

    阿里云开放存储服务 OSS:用于存储图片.apk等静态资源,使用阿里云带宽,不占用开发者服务器带宽. 阿里云官方PHP SDK: http://aliyun.com/product/oss/#help ...

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

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

  4. 改写百度云推送SDK,PHP PEAR 包:Services_Baidu_Push

    iPhone使用apple push很方便,而Android很多厂商删除了google push,而且google在大陆连不上,所以要用别的办法. Android常见的推送服务商有:极光推送(http ...

  5. [Erlang 0106] Erlang实现Apple Push Notifications消息推送

        我们的IOS移动应用要实现消息推送,告诉用户有多少条消息未读,类似下图的效果(笑果),特把APNS和Erlang相关解决方案笔记于此备忘.          上面图片中是Apple Notif ...

  6. PHP发短信 PEAR 包:Services_Sms

    PHP发短信 PEAR 包:Services_Sms 对于这种第三方库,PHP官方称之为PEAR,需要按照PEAR标准开发(标准URI). PEAR的优势:一键安装到php/lib/php目录,req ...

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

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

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

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

  9. PHP之pear包总结

    现在我们开发的时候,尤其是使用框架进行项目开发的时候,都会有一个专门的包管理工具,对,那就是composer,使用这个工具可以简单快速的引入一个代码包,十分快捷好用.接下就总结一下,经常使用到的pea ...

随机推荐

  1. Vector和Stack源码分析/List集合的总结

    序言 这篇文章算是在这list接口下的集合的最后一篇了,前面ArrayList.LinkedList都已经讲解完了,剩下就Vector和Vector的子类Stack啦.继续努力.一步一个脚印, --W ...

  2. dic+css页面布局分享

    HTML部分代码<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <t ...

  3. JS滚轮事件封装

    wheel(function(isTrue){ console.log(isTrue); }) function wheel(callback){ if(navigator.userAgent.ind ...

  4. java二维数组的常见初始化

    public class Test{ public static void main(String[] args){ //第一种: //int[][] arr1 = new int[][]{{1,2} ...

  5. MySQL PXC 高可用集群搭建

    一些名词介绍: WS:write set 写数据集    IST: Incremental State Transfer 增量同步    SST:State Snapshot Transfer 全量同 ...

  6. bootstrap-datetimepicker.js学习

    之前项目运用到了这个时间控件,期间bug还是一些.抽个时间,简单地看一下. 先看一下datetimepicker.js的结构 var DateTimePicker = function(element ...

  7. JS魔法堂:剖析源码理解Promises/A规范

    一.前言 Promises/A是由CommonJS组织制定的异步模式编程规范,有不少库已根据该规范及后来经改进的Promises/A+规范提供了实现 如Q, Bluebird, when, rsvp. ...

  8. 【web前端面试题整理03】来看一点CSS相关的吧

    前言 昨天我们整理了14到js的题,今天我们再来整理14到CSS相关的题目,昨天整理时候时间有点晚了我便有点心浮气躁,里面的一些题需要再次解答,好了看看今天有些什么吧. PS:我这里挑一点来做就好了, ...

  9. Linux RHCS 基础维护命令

    本文只是介绍Linux RHCS最基本的一些维护命令,属于DBA应该了解的层面. 查看集群状态 集群正常启动 集群正常关闭 查看服务是否关闭开机启动 1. 查看集群状态 clustat cman_to ...

  10. 一个比较有意思的C语言问题

    先看代码吧,学习c语言结构体中看到的一个问题 #include<stdio.h> int main(){ struct{ int a:2; }x; x.a=; x.a=x.a+; prin ...