国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home php教程 php手冊 為Apple Push開發(fā)的PHP PEAR 包:Services

為Apple Push開發(fā)的PHP PEAR 包:Services

Jun 06, 2016 pm 07:43 PM
apple pear php push service develop

Apple Push Notification Service:通過蘋果服務(wù)器向app用戶推送消息,無需啟動app。 蘋果官方文檔:http://developer.apple.com/library/mac/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/Chapters/ApplePushService.html#//apple_r

Apple Push Notification Service:通過蘋果服務(wù)器向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標(biāo)準(zhǔn)開發(fā)(標(biāo)準(zhǔn)URI)。

PEAR的優(yōu)勢:一鍵安裝到php/lib/php目錄,require即可使用,很方便。

PHP PEAR上有一個Services_Apns,github上有一個Services_APNS,但都無法使用,所以我開發(fā)了一個,安裝步驟如下:

pear channel-discover sinkcup.github.io/<span>pear
pear </span><span>install</span> sinkcup/Services_Apple_PushNotification

使用步驟:

1、登錄蘋果開發(fā)者后臺,下載dev或prod證書,合并成pem文件。在ios app里添加push權(quán)限,獲得device token。參考:http://www.cnblogs.com/gpwzw/archive/2012/03/31/Apple_Push_Notification_Services_Tutorial_Part_1-2.html

2、demo(參考)

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

輸出:

<span>bool</span>(<span>true</span>)

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

Services_Apple_PushNotification項目代碼:https://github.com/sinkcup/Services_Apple_PushNotification

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Writing Effective PHP Comments Writing Effective PHP Comments Jul 18, 2025 am 04:44 AM

Comments cannot be careless because they want to explain the reasons for the existence of the code rather than the functions, such as compatibility with old interfaces or third-party restrictions, otherwise people who read the code can only rely on guessing. The areas that must be commented include complex conditional judgments, special error handling logic, and temporary bypass restrictions. A more practical way to write comments is to select single-line comments or block comments based on the scene. Use document block comments to explain parameters and return values at the beginning of functions, classes, and files, and keep comments updated. For complex logic, you can add a line to the previous one to summarize the overall intention. At the same time, do not use comments to seal code, but use version control tools.

Mastering PHP Block Comments Mastering PHP Block Comments Jul 18, 2025 am 04:35 AM

PHPblockcommentsareusefulforwritingmulti-lineexplanations,temporarilydisablingcode,andgeneratingdocumentation.Theyshouldnotbenestedorleftunclosed.BlockcommentshelpindocumentingfunctionswithPHPDoc,whichtoolslikePhpStormuseforauto-completionanderrorche

Improving Readability with Comments Improving Readability with Comments Jul 18, 2025 am 04:46 AM

The key to writing good comments is to explain "why" rather than just "what was done" to improve the readability of the code. 1. Comments should explain logical reasons, such as considerations behind value selection or processing; 2. Use paragraph annotations for complex logic to summarize the overall idea of functions or algorithms; 3. Regularly maintain comments to ensure consistency with the code, avoid misleading, and delete outdated content if necessary; 4. Synchronously check comments when reviewing the code, and record public logic through documents to reduce the burden of code comments.

Learning PHP: A Beginner's Guide Learning PHP: A Beginner's Guide Jul 18, 2025 am 04:54 AM

TolearnPHPeffectively,startbysettingupalocalserverenvironmentusingtoolslikeXAMPPandacodeeditorlikeVSCode.1)InstallXAMPPforApache,MySQL,andPHP.2)Useacodeeditorforsyntaxsupport.3)TestyoursetupwithasimplePHPfile.Next,learnPHPbasicsincludingvariables,ech

PHP Development Environment Setup PHP Development Environment Setup Jul 18, 2025 am 04:55 AM

The first step is to select the integrated environment package XAMPP or MAMP to build a local server; the second step is to select the appropriate PHP version according to the project needs and configure multiple version switching; the third step is to select VSCode or PhpStorm as the editor and debug with Xdebug; in addition, you need to install Composer, PHP_CodeSniffer, PHPUnit and other tools to assist in development.

A Simple Guide to PHP Setup A Simple Guide to PHP Setup Jul 18, 2025 am 04:25 AM

The key to setting up PHP is to clarify the installation method, configure php.ini, connect to the web server and enable necessary extensions. 1. Install PHP: Use apt for Linux, Homebrew for Mac, and XAMPP recommended for Windows; 2. Configure php.ini: Adjust error reports, upload restrictions, etc. and restart the server; 3. Use web server: Apache uses mod_php, Nginx uses PHP-FPM; 4. Install commonly used extensions: such as mysqli, json, mbstring, etc. to support full functions.

PHP Syntax Basics PHP Syntax Basics Jul 18, 2025 am 04:32 AM

To learn PHP, you need to master variables and data types, control structures, function definitions and call specifications, and avoid common syntax errors. 1. Variables start with $, case sensitive, and types include strings, integers, booleans, etc.; 2. The control structure supports if/else/loop, and the template can use colon syntax instead of curly braces, foreach can handle arrays conveniently; 3. Functions are defined with function, supporting default parameters and variable parameters; 4. Common errors include missing semicolons, confusion == and ===, splicing characters errors, and improper use of array subscripts.

Effective PHP Commenting Effective PHP Commenting Jul 18, 2025 am 04:33 AM

The key to writing PHP comments is clear, useful and concise. 1. Comments should explain the intention behind the code rather than just describing the code itself, such as explaining the logical purpose of complex conditional judgments; 2. Add comments to key scenarios such as magic values, old code compatibility, API interfaces, etc. to improve readability; 3. Avoid duplicate code content, keep it concise and specific, and use standard formats such as PHPDoc; 4. Comments should be updated synchronously with the code to ensure accuracy. Good comments should be thought from the perspective of others, reduce the cost of understanding, and become a code understanding navigation device.

See all articles