Ejemplo n.º 1
0
 private function ios()
 {
     $template = new IGtTransmissionTemplate();
     $template->set_appId(APPID);
     //应用appid
     $template->set_appkey(APPKEY);
     //应用appkey
     $template->set_transmissionType(2);
     //透传消息类型
     #$template->set_transmissionContent("title=".title.'&nr='.nr."&type=".type."&id=".id);//透传内容
     $template->set_transmissionContent("title=" . TITLE . '&content=' . CONTENT . "&type=" . TYPE . "&id=" . ID);
     //透传内容
     #$template->set_pushInfo("actionLocKey","badge","message","sound","payload","locKey","locArgs","launchImage");
     $apn = new IGtAPNPayload();
     $alertmsg = new SimpleAlertMsg();
     $alertmsg->alertMsg = "";
     $apn->alertMsg = $alertmsg;
     $apn->badge = 2;
     $apn->sound = "";
     $apn->add_customMsg("payload", "title=" . TITLE . '&content=' . CONTENT . "&type=" . TYPE . "&id=" . ID);
     #        $apn->contentAvailable=1;
     $apn->category = "ACTIONABLE";
     $template->set_apnInfo($apn);
     $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
     $message = new IGtSingleMessage();
     $message->set_data($template);
     $ret = $igt->pushAPNMessageToSingle(APPID, DEVICETOKEN, $message);
     var_dump($ret);
 }
Ejemplo n.º 2
0
function IGtTransmissionTemplateDemo()
{
    $template = new IGtTransmissionTemplate();
    $template->set_appId(APPID);
    //应用appid
    $template->set_appkey(APPKEY);
    //应用appkey
    $template->set_transmissionType(1);
    //透传消息类型
    $template->set_transmissionContent("测试离线ddd");
    //透传内容
    //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
    //APN简单推送
    //        $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高级推送
    $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 = "";
    $apn->add_customMsg("payload", "payload");
    $apn->contentAvailable = 1;
    $apn->category = "ACTIONABLE";
    $template->set_apnInfo($apn);
    //PushApn老方式传参
    //    $template = new IGtAPNTemplate();
    //          $template->set_pushInfo("", 10, "", "com.gexin.ios.silence", "", "", "", "");
    return $template;
}
Ejemplo n.º 3
0
function IGtTransmissionTemplateDemo()
{
    $template = new IGtTransmissionTemplate();
    $template->set_appId(APPID);
    //应用appid
    $template->set_appkey(APPKEY);
    //应用appkey
    $template->set_transmissionType(1);
    //透传消息类型
    $template->set_transmissionContent("测试离线");
    //透传内容
    //iOS推送需要设置的pushInfo字段
    //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);
    //$template ->set_pushInfo("", 0, "", "", "", "", "", "");
    return $template;
}
Ejemplo n.º 4
0
 public static function IGtTransmissionTemplateDemo($payload)
 {
     $template = new \IGtTransmissionTemplate();
     $template->set_appId(config('getui-push.android.id'));
     //应用appid
     $template->set_appkey(config('getui-push.android.key'));
     //应用appkey
     $template->set_transmissionType(1);
     //透传消息类型
     $template->set_transmissionContent($payload);
     //透传内容
     return $template;
 }
Ejemplo n.º 5
0
 /**
  * 创建透传功能模板
  * 注:IOS离线推送需通过APN进行转发,需填写pushInfo字段,目前仅不支持通知弹框下载功能
  * @param array $options array(
  *     'transmission_content' => '',    // 透传内容
  *     'push_info' => array(
  *         'action_loc_key' => '',
  *         'badge'          => 0,
  *         'message'        => '',
  *         'sound'          => '',
  *         'payload'        => '',
  *         'loc_key'        => '',
  *         'loc_args'       => '',
  *         'launch_image'   => '',
  *     )
  *   )
  */
 public function createTransmissionTemplate($options)
 {
     $_options = array('transmission_content' => isset($options['transmission_content']) ? $options['transmission_content'] : '透传内容', 'push_info' => isset($options['push_info']) ? $options['push_info'] : '');
     $template = new IGtTransmissionTemplate();
     $template->set_appId($this->_appid);
     // 应用appid
     $template->set_appkey($this->_appkey);
     // 应用appkey
     $template->set_transmissionType(1);
     // 透传消息类型
     $template->set_transmissionContent($_options['transmission_content']);
     // 透传内容
     //iOS推送需要设置的pushInfo字段
     if ($_options['push_info']) {
         $push_info = $_options['push_info'];
         $template->set_pushInfo($push_info['action_loc_key'], $push_info['badge'], $push_info['message'], $push_info['sound'], $push_info['payload'], $push_info['loc_key'], $push_info['loc_args'], $push_info['launch_image']);
         //$template ->set_pushInfo("test",1,"message","","","","","");
     }
     return $template;
 }
Ejemplo n.º 6
0
 function IGtTransmissionTemplateDemo($content = '')
 {
     $template = new IGtTransmissionTemplate();
     $template->set_appId(self::APPID);
     //应用appid
     $template->set_appkey(self::APPKEY);
     //应用appkey
     $template->set_transmissionType(2);
     //透传消息类型
     $template->set_transmissionContent($content);
     //透传内容
     $arr = explode(':', $content);
     if (strlen($content) > 100 || strlen($arr[3]) > 100) {
         $substr_content = substr($content, 0, 100);
         $substr_arr = substr($arr[3], 0, 100);
         $template->set_pushInfo("a", 0, $content, "com.gexin.ios.silence", $substr_content, $substr_arr, "", "");
     } else {
         $template->set_pushInfo("a", 0, $content, "com.gexin.ios.silence", $content, $arr[3], "", "");
     }
     //iOS推送需要设置的pushInfo字段
     //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);
     //$template ->set_pushInfo("", 0, "", "", "", "", "", "");
     return $template;
 }
Ejemplo n.º 7
0
 private function IGtTransmissionTemplateDemo()
 {
     $template = new IGtTransmissionTemplate();
     $template->set_appId(self::APPID);
     // 应用appid
     $template->set_appkey(self::APPKEY);
     // 应用appkey
     $template->set_transmissionType(1);
     // 透传消息类型,1会自动启动应用
     $template->set_transmissionContent($this->content);
     // 透传内容
     // iOS推送需要设置的pushInfo字段
     $template->set_pushInfo('', 0, $this->content, 'default', $this->messageNoContent, '', '', '');
     return $template;
 }
Ejemplo n.º 8
0
 private function touchuandemo()
 {
     $template = new IGtTransmissionTemplate();
     $template->set_appId(APPID);
     //应用appid
     $template->set_appkey(APPKEY);
     //应用appkey
     $template->set_transmissionType(2);
     //透传消息类型
     $template->set_transmissionContent("url=" . url . "&title=" . title . '&nr=' . nr . "&type=" . type . "&id=" . id);
     //透传内容
     #$template->set_pushInfo("actionLocKey","badge","message","sound","payload","locKey","locArgs","launchImage");
     $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);
     return $template;
 }
Ejemplo n.º 9
0
/**
 * 创建透传通知
 * @param $p  推送数据内容
 * @return IGtNotificationTemplate
 */
function createTranMessage($p)
{
    $template = new IGtTransmissionTemplate();
    $template->set_appId(APPID);
    //应用appid
    $template->set_appkey(APPKEY);
    //应用appkey
    $template->set_transmissionType(2);
    //透传消息类型:1为激活客户端启动
    $template->set_transmissionContent($p);
    //透传内容
    //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
    return $template;
}
Ejemplo n.º 10
0
 private function androidTemplate($title, $body, $data = "", $edage = 0)
 {
     $template = new IGtTransmissionTemplate();
     $template->set_appId($this->appid);
     //应用appid
     $template->set_appkey($this->appkey);
     //应用appkey
     $template->set_transmissionType(2);
     //透传消息类型
     $template->set_transmissionContent($body);
     //透传内容
     //iOS推送需要设置的pushInfo字段
     //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);
     //$template->set_pushInfo("", 5, "", "", "", "", "", "");
     //$template->set_pushInfo('', $edage, $title, "", $body, '', '', '');
     // $template->set_pushInfo('', 3, '你还好么', '');
     return $template;
 }
Ejemplo n.º 11
0
 function pushNotificationMessageToList($title = "alarm", $text = "是的, 您木有看错..这是测试信息", $clientIds)
 {
     $igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
     //消息类型 :状态栏链接 点击通知打开网页
     $template = new IGtTransmissionTemplate();
     $template->set_appId(APPID);
     //应用appid
     $template->set_appkey(APPKEY);
     //应用appkey
     $template->set_transmissionType(2);
     //透传消息类型
     $template->set_transmissionContent($text);
     //透传内容
     //个推信息体
     $message = new IGtSingleMessage();
     $message->set_isOffline(true);
     //是否离线
     $message->set_offlineExpireTime(3600 * 12);
     //离线时间
     $message->set_data($template);
     //设置推送消息类型
     $contentId = $igt->getContentId($message);
     //接收方1
     $target1 = new IGtTarget();
     $target1->set_appId(APPID);
     foreach ($clientIds as $clientId) {
         $target1->set_clientId($clientId);
         $targetList[] = $target1;
     }
     if (isset($targetList)) {
         $rep = $igt->pushMessageToList($contentId, $targetList);
     }
     return $rep;
 }