public function sendPushIOSMultiple($logFile, $pushArr, $pushListId, $pushTitle, $pushMessage, $timePush, $pushImage = null, $pushLink = null)
{
var_dump($pushTitle);
echo PHP_EOL;
var_dump($pushMessage);
public function sendPushIOSMultiple($logFile, $pushArr, $pushListId, $pushTitle, $pushMessage, $timePush, $pushImage = null, $pushLink = null)
{
$deviceTokenArr = ArrayHelper::getColumn($pushArr, 'deviceToken');
$options = [
'данные для авторизации'
];
$authProvider = AuthProvider\Token::create($options);
$notifications = [];
foreach ($pushArr as $pushItem) {
$alert = Alert::create()->setTitle($pushTitle);
$alert = $alert->setBody($pushMessage);
var_dump($alert);
$payload = Payload::create()->setAlert($alert);
$payload->setContentAvailability(true);
$payload->setBadge($pushItem['badge']);
$payload->setSound('default');
if ($pushImage) {
$payload->setMutableContent(true);
$payload->setCustomValue('image', $pushImage);
}
if ($pushLink) {
$payload->setMutableContent(true);
$payload->setCustomValue('link', $pushLink);
}
$notifications[] = new Notification($payload, $pushItem['deviceToken']);
}
if ($notifications) {
$client = new Client($authProvider, $production = true);
$client->addNotifications($notifications);
$responses = $client->push();
# В зависимости от статуса ответа увеличиваем счетчики успешных/неуспешных уведомлений и изменяет столбец sended
foreach ($responses as $item) {
if ($item->getStatusCode() === 200) {
Yii::$app->db->createCommand()
->update('push', ['sended' => self::SENDED_SEND], ['deviceToken' => $item->getDeviceToken()])
->execute();
} elseif ($item->getStatusCode() === 400) {
Yii::$app->db->createCommand()
->update('push', ['sended' => self::SENDED_ERROR_SEND], ['deviceToken' => $item->getDeviceToken()])
->execute();
}
}
}
}