Пример #1
0
function pushAPNL()
{
    //APN简单推送
    //        $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
    //        $template = new IGtAPNTemplate();
    //        $apn = new IGtAPNPayload();
    //        $alertmsg=new SimpleAlertMsg();
    //        $alertmsg->alertMsg="";
    //        $apn->alertMsg=$alertmsg;
    ////        $apn->badge=2;
    ////        $apn->sound="";
    //        $apn->add_customMsg("payload","payload");
    //        $apn->contentAvailable=1;
    //        $apn->category="ACTIONABLE";
    //        $template->set_apnInfo($apn);
    //        $message = new IGtSingleMessage();
    //APN高级推送
    $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
    $template = new IGtAPNTemplate();
    $apn = new IGtAPNPayload();
    //        $alertmsg=new DictionaryAlertMsg();
    //        $alertmsg->body="body";
    //        $alertmsg->actionLocKey="ActionLockey";
    //        $alertmsg->locKey="LocKey";
    //        $alertmsg->locArgs=array("locargs");
    //        $alertmsg->launchImage="launchimage";
    ////        IOS8.2 支持
    //        $alertmsg->title="Title";
    //        $alertmsg->titleLocKey="TitleLocKey";
    //        $alertmsg->titleLocArgs=array("TitleLocArg");
    //        $apn->alertMsg=$alertmsg;
    //        $apn->badge=7;
    //        $apn->sound="com.gexin.ios.silence";
    $apn->add_customMsg("payload", "payload");
    //        $apn->contentAvailable=1;
    //        $apn->category="ACTIONABLE";
    $template->set_apnInfo($apn);
    $message = new IGtSingleMessage();
    //PushApn老方式传参
    //    $igt = new IGeTui(HOST,APPKEY,MASTERSECRET);
    //    $template = new IGtAPNTemplate();
    //    $template->set_pushInfo("", 4, "", "", "", "", "", "");
    //    $message = new IGtSingleMessage();
    //多个用户推送接口
    putenv("needDetails=true");
    $listmessage = new IGtListMessage();
    $listmessage->set_data($template);
    $contentId = $igt->getAPNContentId(APPID, $listmessage);
    //$deviceTokenList = array("3337de7aa297065657c087a041d28b3c90c9ed51bdc37c58e8d13ced523f5f5f");
    $deviceTokenList = array(DEVICETOKEN);
    $ret = $igt->pushAPNMessageToList(APPID, $contentId, $deviceTokenList);
    var_dump($ret);
}