nstdio / yii2-notymo
此包已被废弃且不再维护。未建议替代包。
Yii2的iOS和Android推送通知扩展
dev-master
2016-10-08 10:07 UTC
Requires
- nstdio/notymo: dev-master
- yiisoft/yii2: ~2.0.6
- yiisoft/yii2-mongodb: ~2.1.0
This package is not auto-updated.
Last update: 2020-01-24 16:24:28 UTC
README
Yii2的iOS和Android推送通知扩展。
安装
建议的安装方法是使用 composer
$ composer require nstdio/yii2-notymo: "dev-master"
或者在您的 composer.json
文件的 require
部分添加以下内容:
"nstdio/yii2-notymo": "dev-master"
使用
定义为一个应用程序组件
// web.php or console.php 'component' => [ // ... 'notymo' => [ 'class' => 'nstdio\yii2notymo\PushNotification', 'push' => [ // If you dоn't want to use one of the services we can just skip them loading. // It's obvious that the skipped service is not necessary to configure. // 'skipApns' => true, // 'skipGcm' => true, 'apns' => [ 'live' => true, // Whether to use live credentials. 'cert' => 'path/to/apns_live_cert.pem', 'sandboxCert' => 'path/to/apns_sandbox_cert.pem', ], 'gcm' => [ 'apiKey' => 'api_key' // Here goes GCM Service API key. ], ], 'dataProvider' => [ 'class' => 'nstdio\yii2notymo\provider\SQLDataProvider', 'table' => 'device_token', // The table from which the data will be obtained. 'identifier' => 'user_id', // The identifier that defines the criteria for what data will be obtained. In this case, it is the column name from the table. 'apns' => 'apns_token', // The column name for APNS device tokens. 'gcm' => 'gcm_token', // The column name for GCM device tokens. ], ], ], // For example SiteController.php use nstdio\notymo\Message; // ... $userIds = [1, 2, 3, 4, 5]; /** @var \nstdio\yii2notymo\PushNotification $push */ $push = Yii::$app->notymo; $msg = new Message(); $msg->setMessage("Test msg."); $push->send($msg, $userIds); // Message will be sent to mentioned users.