samtny / fastapns
一个库,用于以超高速将APNs通知推送到苹果服务器
1.0.4
2016-04-18 22:17 UTC
Requires
- php: >=5.4.0
This package is not auto-updated.
Last update: 2024-09-26 01:20:22 UTC
README
这个库将以尽可能快的速度将推送通知发送到苹果,并报告任何无效的令牌。
灵感来源于这篇StackOverflow文章
http://stackoverflow.com/a/18491136/1569360
... 并仔细阅读这里的“推送通知故障排除”
使用示例
$payload = array( 'aps' => array( 'alert' => 'some alert', ), ); $tokens = array( 'ca360e9029938b9ed8ed435640f3760620526bd72037017d3c50cfa264b7914f', 'ca360e9029938b9ed8ed435640f3760620526bd72037017d3c50cfa264b79150', 'ca360e9029938b9ed8ed435640f3760620526bd72037017d3c50cfa264b79151', 'ca360e9029938b9ed8ed435640f3760620526bd72037017d3c50cfa264b79152', 'ca360e9029938b9ed8ed435640f3760620526bd72037017d3c50cfa264b79153', ); $expiry = (new \DateTime('+24 hours'))->getTimestamp(); $client = FastAPNS\ClientBuilder::create() ->setLocalCert(__DIR__ . '/ssl/MyAppCertificate.includesprivatekey.pem') ->setPassphrase('p@ssword') ->build(); $client->send($payload, $tokens, $expiry); var_dump($client->getBadTokens());
确保您的APNS证书以PEM格式编码,并包含私钥。此文件应设置为模式0400。
END