Пример #1
0
 private function IGtNotificationTemplateDemo()
 {
     $template = new IGtNotificationTemplate();
     $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);
     //透传内容
     return $template;
 }
Пример #2
0
function IGtNotificationTemplateDemo()
{
    $template = new IGtNotificationTemplate();
    $template->set_appId(APPID);
    //应用appid
    $template->set_appkey(APPKEY);
    //应用appkey
    $template->set_transmissionType(1);
    //透传消息类型
    $template->set_transmissionContent("测试离线");
    //透传内容
    $template->set_title("个推");
    //通知栏标题
    $template->set_text("个推最新版点击下载");
    //通知栏内容
    $template->set_logo("http://wwww.igetui.com/logo.png");
    //通知栏logo
    $template->set_isRing(true);
    //是否响铃
    $template->set_isVibrate(true);
    //是否震动
    $template->set_isClearable(true);
    //通知栏是否可清除
    //$template->set_duration(BEGINTIME,ENDTIME); //设置ANDROID客户端在此时间区间内展示消息
    //iOS推送需要设置的pushInfo字段
    //        $apn = new IGtAPNPayload();
    //        $apn->alertMsg = "alertMsg";
    //        $apn->badge = 11;
    //        $apn->actionLocKey = "启动";
    //    //        $apn->category = "ACTIONABLE";
    //    //        $apn->contentAvailable = 1;
    //        $apn->locKey = "通知栏内容";
    //        $apn->title = "通知栏标题";
    //        $apn->titleLocArgs = array("titleLocArgs");
    //        $apn->titleLocKey = "通知栏标题";
    //        $apn->body = "body";
    //        $apn->customMsg = array("payload"=>"payload");
    //        $apn->launchImage = "launchImage";
    //        $apn->locArgs = array("locArgs");
    //
    //        $apn->sound=("test1.wav");;
    //        $template->set_apnInfo($apn);
    return $template;
}
Пример #3
0
function IGtNotificationTemplateDemo()
{
    $template = new IGtNotificationTemplate();
    $template->set_appId(APPID);
    //应用appid
    $template->set_appkey(APPKEY);
    //应用appkey
    $template->set_transmissionType(1);
    //透传消息类型
    $template->set_transmissionContent("测试离线");
    //透传内容
    $template->set_title("个推");
    //通知栏标题
    $template->set_text("个推最新版点击下载");
    //通知栏内容
    $template->set_logo("http://wwww.igetui.com/logo.png");
    //通知栏logo
    $template->set_isRing(true);
    //是否响铃
    $template->set_isVibrate(true);
    //是否震动
    $template->set_isClearable(true);
    //通知栏是否可清除
    // iOS推送需要设置的pushInfo字段
    //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);
    //$template ->set_pushInfo("test",1,"message","","","","","");
    return $template;
}
Пример #4
0
 function IGtNotificationTemplateDemo($tsid = 0, $title = '', $content = '')
 {
     $template = new IGtNotificationTemplate();
     $template->set_appId(self::APPID);
     //应用appid
     $template->set_appkey(self::APPKEY);
     //应用appkey
     $template->set_transmissionType(1);
     //透传消息类型
     $template->set_transmissionContent($tsid);
     //透传内容
     $template->set_title($title);
     //通知栏标题
     $template->set_text($content);
     //通知栏内容
     $template->set_logo("http://www.meilimei.com/images/logo1031-114.png");
     //通知栏logo
     $template->set_isRing(true);
     //是否响铃
     $template->set_isVibrate(true);
     //是否震动
     $template->set_isClearable(true);
     //通知栏是否可清除
     // iOS推送需要设置的pushInfo字段
     $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], "", "");
     }
     //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);
     //$template ->set_pushInfo("test",1,"message","","","","","");
     return $template;
 }
Пример #5
0
 function IGtNotificationTemplateDemo($content, $title, $tz_content)
 {
     $template = new \IGtNotificationTemplate();
     $template->set_appId(appid);
     //应用appid
     $template->set_appkey(APPKEY);
     //应用appkey
     $template->set_transmissionType(1);
     //透传消息类型
     $template->set_transmissionContent($content);
     //透传内容
     $template->set_title($title);
     //通知栏标题
     $template->set_text($tz_content);
     //通知栏内容
     $template->set_logo("");
     //通知栏logo
     $template->set_isRing(true);
     //是否响铃
     $template->set_isVibrate(true);
     //是否震动
     $template->set_isClearable(true);
     //通知栏是否可清除
     return $template;
 }
Пример #6
0
 /**
  * 创建通知透传功能模板
  * 注:IOS离线推送需通过APN进行转发,需填写pushInfo字段,目前仅不支持通知弹框下载功能
  * @param array $options array(
  *     'transmission_content' => '',    // 透传内容
  *     'title'                => '',    // 通知栏标题
  *     'text'                 => '',    // 通知栏内容
  *     'is_ring'              => true,  // 是否响铃
  *     'is_vibrate'           => true,  // 是否震动
  *     'push_info' => array(
  *         'action_loc_key' => '',
  *         'badge'          => 0,
  *         'message'        => '',
  *         'sound'          => '',
  *         'payload'        => '',
  *         'loc_key'        => '',
  *         'loc_args'       => '',
  *         'launch_image'   => '',
  *     )
  *   )
  */
 public function createNotificationTemplate($options)
 {
     $_options = array('transmission_content' => isset($options['transmission_content']) ? $options['transmission_content'] : '透传内容', 'title' => isset($options['title']) ? $options['title'] : '个推', 'text' => isset($options['text']) ? $options['text'] : '个推最新版点击下载', 'is_ring' => isset($options['is_ring']) ? $options['is_ring'] : true, 'is_vibrate' => isset($options['is_vibrate']) ? $options['is_vibrate'] : true, 'push_info' => isset($options['push_info']) ? $options['push_info'] : '');
     $template = new IGtNotificationTemplate();
     $template->set_appId($this->_appid);
     // 应用appid
     $template->set_appkey($this->_appkey);
     // 应用appkey
     $template->set_transmissionType(1);
     // 透传消息类型
     $template->set_transmissionContent($_options['transmission_content']);
     // 透传内容
     $template->set_title($_options['title']);
     // 通知栏标题
     $template->set_text($_options['text']);
     // 通知栏内容
     $template->set_isRing($_options['is_ring']);
     // 是否响铃
     $template->set_isVibrate($_options['is_vibrate']);
     // 是否震动
     $template->set_isClearable(true);
     // 通知栏是否可清除
     // 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;
 }
Пример #7
0
/**
 * 创建普通通知
 * @param $t  推送通知标题
 * @param $c  推送通知内容
 * @param $p  推送透传内容(客户端暂时未处理此数据)
 * @return IGtNotificationTemplate
 */
function createNotiMessage($t, $c, $p)
{
    $template = new IGtNotificationTemplate();
    $template->set_appId(APPID);
    //应用appid
    $template->set_appkey(APPKEY);
    //应用appkey
    $template->set_transmissionType(1);
    //透传消息类型,Android平台控制点击消息后是否启动应用
    if (!empty($p)) {
        $template->set_transmissionContent($p);
        //透传内容,点击消息后触发透传数据
    }
    $template->set_title($t);
    //通知栏标题
    $template->set_text($c);
    //通知栏内容
    //    $template->set_logo("http://wwww.igetui.com/logo.png");//通知栏logo,不设置使用默认程序图标
    $template->set_isRing(true);
    //是否响铃
    $template->set_isVibrate(true);
    //是否震动
    $template->set_isClearable(true);
    //通知栏是否可清除
    return $template;
}
 public function getPush(Request $request)
 {
     header("Content-Type: text/html; charset=utf-8");
     require_once dirname(__FILE__) . '/JiulePush/' . 'IGt.Push.php';
     define('APPKEY', 'w5FhVpAEBcAewXzpmEVHHA');
     define('APPID', '63GHvHb4Qr8cIluoXJF797');
     define('MASTERSECRET', 'CiB2pa7jZn6nhIVOkamyV9');
     define('HOST', 'http://sdk.open.api.igexin.com/apiex.htm');
     define('CID', '');
     //define('CID2','请输入ClientID');
     define('ALIAS', $request->input('userid'));
     $igt = new \IGeTui(HOST, APPKEY, MASTERSECRET);
     //		$res = $igt->queryAlias(APPID, ALIAS);
     //		dd($res)
     //消息模版:
     // 1.TransmissionTemplate:透传功能模板
     // 2.LinkTemplate:通知打开链接功能模板
     // 3.NotificationTemplate:通知透传功能模板
     // 4.NotyPopLoadTemplate:通知弹框下载功能模板
     //$template = IGtNotyPopLoadTemplateDemo();
     //$template = IGtLinkTemplateDemo();
     //$template = IGtNotificationTemplateDemo();
     //$template = IGtTransmissionTemplateDemo();
     $template = new \IGtNotificationTemplate();
     $template->set_appId(APPID);
     //应用appid
     $template->set_appkey(APPKEY);
     //应用appkey
     $template->set_transmissionType(1);
     //透传消息类型
     $template->set_transmissionContent("测试离线");
     //透传内容
     $template->set_title($request->input('title'));
     //通知栏标题
     $template->set_text($request->input('content'));
     //通知栏内容
     $template->set_logo("logo.png");
     //通知栏logo
     $template->set_logoURL(public_path() . '/images/logo.png');
     //通知栏logo链接
     $template->set_isRing(true);
     //是否响铃
     $template->set_isVibrate(true);
     //是否震动
     $template->set_isClearable(true);
     //通知栏是否可清除
     //个推信息体
     $message = new \IGtSingleMessage();
     $message->set_isOffline(true);
     //是否离线
     $message->set_offlineExpireTime(3600 * 12 * 1000);
     //离线时间
     $message->set_data($template);
     //设置推送消息类型
     $message->set_PushNetWorkType(0);
     //设置是否根据WIFI推送消息,1为wifi推送,0为不限制推送
     //接收方
     $target = new \IGtTarget();
     $target->set_appId(APPID);
     //		$target->set_clientId(CID);
     $target->set_alias(ALIAS);
     $rep = $igt->pushMessageToSingle($message, $target);
     if ($rep['result'] == 'ok') {
         $pushlog = new PushLog();
         $pushlog->msgtitle = $request->input('title');
         $pushlog->msgcontent = $request->input('content');
         $pushlog->msgtype = $request->input('userid');
         $pushlog->msgsno = $rep['taskId'];
         $pushlog->msgtime = Carbon::now()->timestamp;
         $pushlog->save();
     }
     return $rep;
 }
Пример #9
0
define('MASTERSECRET', 'Gt19kYh3N88tMRODZp4rH2');
define('HOST', 'http://sdk.open.api.igexin.com/apiex.htm');
define('CID', '');
//define('CID2','请输入ClientID');
define('ALIAS', $_GET['userid']);
$igt = new IGeTui(HOST, APPKEY, MASTERSECRET);
//消息模版:
// 1.TransmissionTemplate:透传功能模板
// 2.LinkTemplate:通知打开链接功能模板
// 3.NotificationTemplate:通知透传功能模板
// 4.NotyPopLoadTemplate:通知弹框下载功能模板
//$template = IGtNotyPopLoadTemplateDemo();
//$template = IGtLinkTemplateDemo();
//$template = IGtNotificationTemplateDemo();
//$template = IGtTransmissionTemplateDemo();
$template = new IGtNotificationTemplate();
$template->set_appId(APPID);
//应用appid
$template->set_appkey(APPKEY);
//应用appkey
$template->set_transmissionType(1);
//透传消息类型
$template->set_transmissionContent("测试离线");
//透传内容
$template->set_title($_GET["title"]);
//通知栏标题
$template->set_text($_GET["content"]);
//通知栏内容
$template->set_logo("logo.png");
//通知栏logo
$template->set_logoURL("http://wwww.igetui.com/logo.png");