AppleNotificationPush
1.0.0
一個中間件,可協助您將通知從伺服器推送到 Apple 裝置(iPhone、iPad)
$ message = new AppleNotificationPush Message Message ();
$ message -> setAlert ( ' SEARCH_ACTIVITY title ' );
$ message -> setSound ( ' default ' );
$ message -> setIdentifier ( mt_rand ( 10 , 1000 ));
$ message -> setDeviceToken ( ' f83f0f2fc1efc0a549601437128bf2d94fea83b4c31b0750d3d9f8f98d5e7a87 ' );
$ message -> setPriority ( 10 );
// $message->setCustomerData(array('id'=> 123));
// $message->setCustomerData(array('url' => 'sdfd'));
$ message -> setCustomerData ( array (
' id ' => mt_rand ( 10 , 2000 ),
' content ' => ' SEARCH_ACTIVITY content ' ,
' url ' => ' MY_ORDER_ACTIVITY_UNRECEIVE ' ,
' extra ' => ' [] '
));
// $message->setDeviceToken('ss')->setSound('s')->setAlert('alert');
// var_dump($message->getPayloadData());
$ certificate = " path/to/cetificate.pem " ;
$ connection = new Connection ( 1 , $ certificate , C ( ' jpush.apns.password ' ));
$ notification = new Notification ( $ connection );
$ notification -> sendMessage ( $ message );
public function feedback ()
{
$ certificate = " path/to/cetificate.pem " ;
$ connection = new AppleNotificationPush Feedback Connection ( 1 , $ certificate , $ password );
// var_dump($connection);
$ feedback = new Feedback ( $ connection );
$ feedback -> getConnection ()-> create ();
var_dump ( $ feedback -> getInvalidDevices ());
// var_dump($feedback);
}
將調試或記錄的權限完全鎖定開發者,自由定義。
用法如:
$ this -> log ( ' info ' , sprintf (
' %d device tokens received from feedback service. ' ,
count ( $ feedback )
));
具體的實作文件可以參考我放在部落格上:[socket的ios自適應類別庫的實作] (http://www.fzb.me/2015-9-7-sockect-implement-for-apns.html )
© 馮宗寶 fzb.me
根據 MIT 許可證發布