/
sendNotification.php
30 lines (28 loc) · 1021 Bytes
/
sendNotification.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
<?php
include_once 'ApnsPHP/Autoload.php';
class sendNotification
{
function sendNotificationByApns($deviceToken, $msg,$type, $userId)
{
$push = new ApnsPHP_Push(
ApnsPHP_Abstract::ENVIRONMENT_PRODUCTION, 'certificate/aps_dist_certi.pem'
);
$push->setRootCertificationAuthority('certificate/aps_dist_certi.pem');
$push->connect();
$message = new ApnsPHP_Message($deviceToken);
// $message = new ApnsPHP_Message("407fa2549e4cb290c4f13059340a36e69679d9e1ba34b40751663819d98281ab");
$message->setCustomProperty('type',$type);
$message->setCustomProperty('userId',$userId);
// $message->setCustomProperty('channelName',$channelName);
$message->setText($msg);
$message->setBadge(1);
$message->setSound();
$push->add($message);
$res = $push->send();
$push->disconnect();
// return true;
// echo "sese";
// exit;
}
}
?>