Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
XiaoHuizhe committed Apr 5, 2017
1 parent 77c7f48 commit ec9074e
Showing 1 changed file with 18 additions and 2 deletions.
20 changes: 18 additions & 2 deletions src/Response.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,25 @@
* @see https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/CommunicatingwithAPNs.html#//apple_ref/doc/uid/TP40008194-CH11-SW17
* @package Apns2
*/
class Response{
class Response
{
public $device_id;
public $code;
public $status;
public $reason;
public $duration;

public function __construct($responseHeaderAndBody, $code, $duration)
{
$this->duration = $duration;
$this->code = $code;
$m = preg_match('/^\s+ (\d+).*?\\n(.*)$/s', $responseHeaderAndBody);
if ($m) {
$this->code = $m[1];
}
$body = $m[2];
if ($body) {
$json = json_decode($body);
$this->reason = isset($json->reason) ? $json->reason : '';
}
}
}

0 comments on commit ec9074e

Please sign in to comment.