Uniapp is pushed by the server and cannot be received offline. Detection steps: PHP on the server

Time:2021-10-23

1. Check whether the parameters are correct.
2. Do not use transparent transmission mode first.
3. Is the manufacturer channel message content set
4. Setting to open a specific page in the application is the intent parameter.
5. Whether the intent parameter is correct
intent:#Intent; Component = package name / io.dcloud.pandoraentry; S.UP-OL-SU=true; S. Title = ". URLEncode"; S. Content = ". URLEncode ($content)."; S. Payload = ". Json_encode"; end

6. PHP side reference code.

$api = new GTClient("https://restapi.getui.com/","", "","");  
       $stt = ['default'=>1];  
       //Set push parameters 
       $push = new GTPushRequest();  
       $push->setRequestId(time());  
       $message = new GTPushMessage();  
       $notify = new GTNotification();  
       $channel = new GTPushChannel();  

       //Configure push conditions 
       $str = new GTStrategy();  
       $str->setDefault(1);  
       $str->setHw(1);  
       $setting = new GTSettings();  // Timed push not available 
       $setting->setStrategy($str);  
       $push->setSettings($setting);  
       $setting->setTtl(3600000); //// The message validity period needs to be set for the manufacturer's message 

      //Push Apple offline notification title content 
       $alert = new GTAlert();  
        $alert->setTitle($title);  
      $alert->setBody($content);  
       $aps = new GTAps();  
       //1 indicates silent push (no notification bar message). No other parameters need to be filled in during silent push. 
       //Apple recommends pushing up to 3 silent messages an hour 
       $aps->setContentAvailable(0);  
      $aps->setSound("default");  
      $aps->setAlert($alert);  
      $iosDto = new GTIos();  
      $iosDto->setAps($aps);  
       $iosDto->setType("notify");  
       $pushChannel = new GTPushChannel();  
       $pushChannel->setIos($iosDto);  

       //Android offline vendor channel push message body 
       $pushChannel = new GTPushChannel();  
       $androidDTO = new GTAndroid();  
       $ups = new GTUps();  
       $notification1 = new GTThirdNotification();;  
       $notification1->setTitle($title);  
       $notification1->setBody($content);  
       $ups->setNotification($notification1);  
       If ($clicktype = ='none ') // set the push type 
       {  
           $notification1->setClickType($clickType);  
       }Else if ($clicktype = ='payload '| $clicktype = ='payload_custom') {// customize the message to open and not open app 
           $notification1->setClickType($clickType);  
           $notification1->setPayload(json_encode($data));  
       }Else if ($clicktype = ='url ') {// open URL 
           $notification1->setClickType($clickType);  
           $notification1->setUrl($url);  
       }Else if ($clicktype = ='intent ') {// open a specific page 
           $notification1->setClickType($clickType);  
           $NOTIFICATION1 - > setintent ("intent: #intent; component = package name / io.dcloud.pandoraentry; s.up-ol-su = true; s.title =". URLEncode ($title) "; s.content =". URLEncode ($content) "; s.payload =". Json_encode ($data) "; end");  
       }else{  
           $notification1->setClickType($clickType);  
       }  
           //Individual settings of each manufacturer's own functions 
       if($time){  
           $message->setDuration($time);  // Set push time 
           $data = json_encode(array('title'=>$title,'content'=>$content,'duration'=>$time,'importance'=>'HIGH','payload'=>json_encode($data)));  
       }else{  
           $data = json_encode(array('title'=>$title,'content'=>$content,'payload'=>json_encode($data)));  
       }  
       //$ups->setTransmission($data); 
       $androidDTO->setUps($ups);  
       $pushChannel->setAndroid($androidDTO);  
       $push->setPushChannel($pushChannel);  

       //Push online channel 
       $notify->setTitle($title);  
       $notify->setBody($content);  
       if($img) $notify->setBigImage($img); // Push picture 
       //1. Intent: open a specific page in the application. 2. URL: open the web page address. 3. Payload: customize the message content to start the application. 4、payload_ Custom: the custom message content does not start the application. 5. Startapp: open the application home page. 6. None: pure notification, no follow-up action 
       If ($clicktype = ='none ') // set the push type 
       {  
           $notify->setClickType($clickType);  
       }Else if ($clicktype = ='payload '| $clicktype = ='payload_custom') {// customize the message to open and not open app 
           $notify->setClickType($clickType);  
           $notify->setPayload(json_encode($data));  
       }Else if ($clicktype = ='url ') {// open URL 
           $notify->setClickType($clickType);  
           $notify->setUrl($url);  
       }Else if ($clicktype = ='intent ') {// open a specific page 
           $notify->setClickType($clickType);  
           $notify - > setintent ("intent: #intent; component = package name / io.dcloud.pandoraentry; s.up-ol-su = true; s.title =". URLEncode ($title) "; s.content =". URLEncode ($content) "; s.payload =". Json_encode ($data). "End");  
       }else{  
           $notify->setClickType($clickType);  
       }  
       $message->setNotification($notify);  
       $push->setPushMessage($message);  
     /*  if($time){  
           $message->setDuration($time);  // Set push time  
           $data = json_encode(array('title'=>$title,'body'=>$content,'duration'=>$time,'importance'=>'HIGH','payload'=>json_encode($data)));  
       }else{  
           $data = json_encode(array('title'=>$title,'body'=>$content,'payload'=>json_encode($data)));  
       }  
       $ups->setTransmission($data);  //  
       $android->setUps($ups);  
       $channel->setAndroid($android);  
       $push->setPushChannel($channel);  
       $push->setPushMessage($message);*/  
       If ($CID) // push to a user 
       {  
           $push->setCid($cid);  
           //Processing returned results 
           $result = $api->pushApi()->pushToSingleByCid($push);  
       }else{  
           $result = $api->pushApi()->pushAll($push);  
       }  
       Log:: info ('Push data: [push] '. Json_encode ($result))// Write log 
       return $result;

Recommended Today

Swift advanced (XV) extension

The extension in swift is somewhat similar to the category in OC Extension can beenumeration、structural morphology、class、agreementAdd new features□ you can add methods, calculation attributes, subscripts, (convenient) initializers, nested types, protocols, etc What extensions can’t do:□ original functions cannot be overwritten□ you cannot add storage attributes or add attribute observers to existing attributes□ cannot add parent […]