sin2x
sin2x
  • 发布:2016-06-30 11:33
  • 更新:2016-07-01 11:46
  • 阅读:5007

个推安卓和ios都可以收到消息,但是click事件不触发[附详细情况说明和代码]?

分类:5+ SDK

情况描述:
android: 可以受到消息通知提醒,但是点击没有任何反应,一次推送,好像还会受到两次提醒!
iOS: 没有受到消息中心通知,只在应用打开时弹出弹框,带一个取消和确定按钮,点确定没有任何反应!

我的意图:
服务器端用个推发送透传消息,不管时离线还是在线,我都想把消息处理成消息中心提醒,点击然后打开透传消息中指定的文章id的特定文章。

app代码:(放在plusReady事件内)

                plus.push.addEventListener("click", function(msg) {  
                    var pushMsg=JSON.parse(msg);  
                    var payloadJson=JSON.parse(pushMsg.payload);  
                    openRemote('https://heyheyhey.com/index.php/Api/appHttp/action/getArticleContentById/pageNum/1/pageSize/5/aid/' + payloadJson.aid, payloadJson.title);  
                }, false);  

                plus.push.addEventListener("receive", function(msg) {  
                    var pushMsg=JSON.parse(msg);  
                    var payloadJson=JSON.parse(pushMsg.payload);  
                    if (msg.aps) {   

                        if(!payloadJson.isLocalMsg){  
                            createLocalMsg('标题',JSON.stringify(payloadJson));  
                        }  

                    } else {  

                        if(!payloadJson.isLocalMsg){  
                            createLocalMsg('标题',JSON.stringify(payloadJson));  
                        }                         

                    }  

                }, false);  

            function createLocalMsg(title,payload){  
                var localJson=JSON.parse(payload);  
                localJson.isLocalMsg=true;                
                var options = {cover:false,title:title};  
                plus.push.createMessage( localJson.title, JSON.stringify(localJson), options );               
            }  

服务端推送代码:


    public function pushMessageToApp($title,$aid){  

        $igt = new \IGeTui(HOST,APPKEY,MASTERSECRET);  
        //定义透传模板,设置透传内容,和收到消息是否立即启动启用  
        $template = $this->IGtNotificationTemplate($title,$aid);  
        //$template = IGtLinkTemplateDemo();  
        // 定义"AppMessage"类型消息对象,设置消息内容模板、发送的目标App列表、是否支持离线发送、以及离线消息有效期(单位毫秒)  
        $message = new \IGtAppMessage();  
        $message->set_isOffline(true);  
        $message->set_offlineExpireTime(3600*1000*2);//离线时间单位为毫秒,例,两个小时离线为3600*1000*2  
        $message->set_data($template);  

        $appIdList=array(APPID);  
        //$phoneTypeList=array('ANDROID');  
        //$provinceList=array('浙江');  
        //$tagList=array('haha');  
        //用户属性  
        //$age = array("0000", "0010");  

        //$cdt = new AppConditions();  
       // $cdt->addCondition(AppConditions::PHONE_TYPE, $phoneTypeList);  
       // $cdt->addCondition(AppConditions::REGION, $provinceList);  
        //$cdt->addCondition(AppConditions::TAG, $tagList);  
        //$cdt->addCondition("age", $age);  

        $message->set_appIdList($appIdList);  
        //$message->set_conditions($cdt->getCondition());  

        $rep = $igt->pushMessageToApp($message);  

    }  

    public function IGtNotificationTemplate($title,$aid){  
        $pushInfo=array('title'=>$title,'content'=>$title,'payload'=>array('aid'=>$aid,'title'=>$title));  
        $template =  new \IGtNotificationTemplate();  
        $template->set_appId(APPID);                   //应用appid  
        $template->set_appkey(APPKEY);                 //应用appkey  
        $template->set_transmissionType(1);            //透传消息类型  
        $template->set_transmissionContent(json_encode($pushInfo));//透传内容  
        $template->set_title("标题");                  //通知栏标题  
        $template->set_text($title);     //通知栏内容  
        $template->set_logo("");                       //通知栏logo  
        $template->set_logoURL("");                    //通知栏logo链接  
        $template->set_isRing(true);                   //是否响铃  
        $template->set_isVibrate(true);                //是否震动  
        $template->set_isClearable(true);              //通知栏是否可清除  

        //设置通知定时展示时间,结束时间与开始时间相差需大于6分钟,消息推送后,客户端将在指定时间差内展示消息(误差6分钟)  
        //$begin = "2015-02-28 15:26:22";  
        //$end = "2015-02-28 15:31:24";  
        //$template->set_duration($begin,$end);  
        // iOS推送需要设置的pushInfo字段(老方法不推荐使用)  
        //$template ->set_pushInfo($actionLocKey,$badge,$message,$sound,$payload,$locKey,$locArgs,$launchImage);  
        //$template ->set_pushInfo("test",1,"message","","","","","");  
        //iOS推送需要设置的pushInfo字段  
        $apn = new \IGtAPNPayload();  
        //$apn->alertMsg = "alertMsg";  
        $apn->badge = 0;  
        //$apn->actionLocKey = "启动";  
        $apn->category = "ACTIONABLE";  
        $apn->contentAvailable = 1;  
        $apn->locKey = $title;  
        $apn->title = "通知栏标题";  
        //$apn->titleLocArgs = array("titleLocArgs");  
        //$apn->titleLocKey = "通知栏标题";  
        //$apn->body = "body";  
        $apn->customMsg = json_encode($pushInfo);  
        //$apn->launchImage = "launchImage";  
        //$apn->locArgs = array("locArgs");  
        //$apn->sound=("test1.wav");;  
        $template->set_apnInfo($apn);  
        return $template;  
    }  

请帮忙看下,谢谢~

2016-06-30 11:33 负责人:无 分享
已邀请:
getui_johny

getui_johny - 个推技术支持

android收到通知栏消息了,点击就会打开应用的呀。
如果收到了两条提示,那应该是服务端推送了两次或客户端处理了两次

iOS推送只能用透传消息模版TransmissionTemplate这个。android的用NotificationTemplate和TransmissionTemplate都可以的。

sin2x

sin2x (作者)

@getui_johny 感谢您的回答!我现在把服务端换成TransmissionTemplate:


    public function buildIGtTransmissionTemplate($title,$aid){  
        $pushInfo=array('title'=>'嘿嘿','content'=>$title,'payload'=>array('aid'=>$aid,'title'=>$title));  
        $template =  new \IGtTransmissionTemplate();  
        //应用appid  
        $template->set_appId(APPID);  
        //应用appkey  
        $template->set_appkey(APPKEY);  
        //透传消息类型  
        $template->set_transmissionType(1);  
        //透传内容  
        $template->set_transmissionContent($pushInfo);  

        $apn = new \IGtAPNPayload();  
        //$alertmsg=new SimpleAlertMsg();  
        //$alertmsg->alertMsg="";  
        //$apn->alertMsg=$alertmsg;  
        //$apn->badge=2;  
        //$apn->sound="";  
        $apn->add_customMsg("payload",$pushInfo);  
        $apn->contentAvailable=1;  
        $apn->category="ACTIONABLE";  
        $template->set_apnInfo($apn);  

        return $template;  
    }

但是除了同一条推送没有收到重复的两次之外,android上click 事件没有触发,iOS上只听到提醒声音,没有任何的事件或者ui触发,客户端的代码,还是和问题当中的一样,没有动过!您可以帮忙看看我服务器端的代码吗?再次感谢!

  • 云钦

    你的服务器端是IOS的推送方法

    2016-11-15 17:40

该问题目前已经被锁定, 无法添加新回复