Exemple #1
1
 /**
  * Private method to send push or broadcast.
  *
  * @param string  $alert
  * @param string  $tag
  *
  */
 function _send_broadcast_or_push($alert, $tag, $url = false, $disable_sound = false)
 {
     // Strip escape slashes, otherwise double escaping would happen
     $alert = html_entity_decode(stripcslashes(strip_tags($alert)));
     // Grab an instance of PushRequest
     $response = $this->airship->push();
     // If tag is broadcast use Push\all const, otherwise set audience to tag
     $audience = $tag == 'broadcast' ? P\all : P\tag($tag);
     $response->setAudience($audience);
     // Sound part of ios push
     if (!$disable_sound && isset($this->sounds["blimply_sound_{$tag}"]) && !empty($this->sounds["blimply_sound_{$tag}"])) {
         $sound = $this->sounds["blimply_sound_{$tag}"];
     } elseif (!$disable_sound) {
         $sound = 'default';
     } else {
         $sound = null;
     }
     // Set extra payload arguments, for now it's just the url
     $extra = $url ? array('url' => $url) : null;
     // iOS and Android specific parts of payload
     $ios = P\ios($alert, '+1', $sound, false, $extra);
     $android = P\android($alert, null, null, null, $extra);
     // TODO: Windows and Blackberry payloads (HA!)
     // Payload filter (allows to workaround quirks of UA API if any and/or fine tuning of payload data)
     $payload = apply_filters('blimply_payload_override', P\notification($alert, array('ios' => $ios, 'android' => $android)));
     $response->setNotification($payload)->setDeviceTypes(P\all);
     do_action('blimply_before_send_push', $payload);
     try {
         $response->send();
     } catch (\Exception $e) {
         return new WP_Error($e->getCode(), $e->getMessage());
     }
     return $response;
 }
 /**
  * @expectedException        InvalidArgumentException
  */
 public function testInvalidBadgeType()
 {
     P\ios(null, true);
 }