日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > php >内容正文

php

为Apple Push开发的PHP PEAR 包:Services_Apple_PushNotification

發布時間:2025/3/15 php 26 豆豆
生活随笔 收集整理的這篇文章主要介紹了 为Apple Push开发的PHP PEAR 包:Services_Apple_PushNotification 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

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' => '12346','cert' => '/home/u1/cert.pem-sandbox', ); $o = new Services_Apple_PushNotification('sandbox', $conf); $deviceToken = 'aaaf818eaae8a5aa11aaaf9aa8f8aa15aaefae75a1aaaa597e51917aa2a1a111'; $data = array('aps' => array('alert' => '測試push sandbox','badge' => 2,'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

轉載于:https://www.cnblogs.com/sink_cup/p/PHP-PEAR-Services_Apple_PushNotification.html

總結

以上是生活随笔為你收集整理的为Apple Push开发的PHP PEAR 包:Services_Apple_PushNotification的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。