-
Notifications
You must be signed in to change notification settings - Fork 39
/
AbstractApnsGcm.php
36 lines (30 loc) · 1.09 KB
/
AbstractApnsGcm.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
<?php
/**
* @author Bryan Jayson Tan <[email protected]>
* @link http://bryantan.info
*/
namespace bryglen\apnsgcm;
use Yii;
use yii\base\Component;
use yii\log\Logger;
abstract class AbstractApnsGcm extends Component
{
public $retryTimes = 3;
public $dryRun = false;
public $enableLogging = false;
public $errors = [];
public $success = false;
public function log($tokens, $text, $payloadData = [], $args = [])
{
$payloadData = http_build_query($payloadData);
$args = http_build_query($args);
$tokens = is_array($tokens) ? implode(', ', $tokens) : $tokens;
$msg = "Sending push notifications to " . $tokens . "\n" .
"message: {$text}\n" .
"payload data: " . str_replace('&', ', ', $payloadData) . "\n" .
"arguments: " . str_replace('&', ', ', $args);
Yii::getLogger()->log($msg, Logger::LEVEL_INFO, 'bryglen/apnsgcm');
}
abstract public function send($token, $text, $payloadData = [], $args = []);
abstract public function sendMulti($tokens, $text, $payloadData = [], $args = []);
}