zfstarter/zfs-push-notification

dev-master 2014-05-22 15:21 UTC

This package is not auto-updated.

Last update: 2024-04-09 05:25:47 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License

ZFSPushNotification

###Установка:

Добавляем в composer.json:

{
    "require-dev": {
        "zfstarter/zfs-push-notification": "dev-master"
    }
}

И обновляем зависимость:

$ curl -s http://getcomposer.org/installer | php
$ php composer.phar update

В config\autoload\global.php

указываем SMTP настройки, дефолтные мыло и имя отправителя, а также, если необходимо заголовки:

return array(
//...
    'ZFSPushNotification' => array(
        'pathToPem' => realpath('file.p12.pem'),
        'sandbox' => true,
    ),
);

В config\autoload\application.config.php включаем модуль

    'modules'  => array(
        //...
        'ZFSPushNotification'
    ),
);

Также нужно убедиться, что у вас уже создана под него табличка:

CREATE TABLE `user_tokens` (
  `user_id` int(11) NOT NULL,
  `token` varchar(64) NOT NULL,
  `created` timestamp NULL DEFAULT NULL,
  PRIMARY KEY (`user_id`,`token`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

###Отправка мыла:

use ZFStarterMail\Model\Mail;
//...
$params = array(
    'userId' => 22,
    'message' => 'My notification!!!',
    'actionLocKey' => 'PLAY',
    'locKey' => 'GAME_PLAY_REQUEST_FORMAT',
    'locArgs' => array('Jenna', 'Frank'),
    'launchImage' => 'Play.png',
    'badge' => 5,
    'sound' => 'bingbong.aiff',
);
PushNotification::sendNotification($this->getServiceLocator(), $params);