Push messages to iOS with the apnsphp package

Source: Internet
Author: User
Tags getmessage message queue

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.