Header (' Content-type:text/html;charset=utf-8 '); require_once ' apnsphp/autoload.php '; require_once ' ApnsPHP/ push.php '; require_once ' apnsphp/message.php '; require_once ' apnsphp/push/exception.php '; function Push_ios_message ( $fans, $push _id, $text, $message _type, $artist _id) {$user _count = count ($fans); if ($user _count = = 0) {return; } $pem = './aaa.pem '; $password = ' 1234 '; $mode = Apnsphp_abstract::environment_sandbox; $mode = apnsphp_abstract::environment_production; Instanciate a new Apnsphp_push object $push = new Apnsphp_push ($mode, $pem, $password); Set the Root Certificate autority to verify the Apple remote peer $push->setrootcertificationauthority ($PEM); Connect to the Apple Push Notification Service $push->connect (); $message = "; for ($i = 0; $i < $user _count; $i + +) {$fans [$i] [' device_token '] = Trim ($fans [$i] [' Device_token ']); try {//instantiate a new Message with a single reCipient $message = new Apnsphp_message ($fans [$i] [' Device_token ']); Set a custom identifier. To get the identifier with the Getcustomidentifier () method//Over a Apnsphp_message object retrieved wit H the GetErrors () message. $message->setcustomidentifier ("message-badge-3"); Set badge icon to "3" $message->setbadge (8); Set a simple welcome text $message->settext ($text); Play The default sound $message->setsound (); $message->setcustomproperty (' push_id ', $push _id); $message->setcustomproperty (' Message_type ', $message _type); Set the expiry value to seconds $message->setexpiry (30); ADD the message to the message queue $push->add ($message); } catch (Exception $e) {$message = '; Var_dump ($e->getmessage ()); }} try{$pUsh->send (); $push->disconnect (); Examine the error message container $aErrorQueue = $push->geterrors (); if (!empty ($aErrorQueue)) {var_dump ($aErrorQueue); Var_dump (Serialize ($aErrorQueue)); }} catch (Exception $e) {echo ' Exception: '; Var_dump ($e->getmessage ()); }}
Three-party Package
Https://github.com/zhoutingze/adtuu.git
Push messages to iOS with the apnsphp package