1. Go to this page and download the library: Download uzdevid/yii2-fcm library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
uzdevid / yii2-fcm example snippets
return [
// ...
'components' => [
// ...
'notifier' => [
'class' => 'uzdevid\fcm\Notifier',
'serverKey' => '{serverKey}', // Cloud Messaging API (Legacy) ni faollashtirganingizdan so'ng, "Server key" beriladi.
],
// ...
],
// ...
]
$token = "frYfozsx0K7e..."; // Push habar qabul qiluvchi qurilmaning tokeni
$notification = [
'title' => 'Salom, dunyo!',
'body' => 'Bu birinchi push habarim',
'data' => [
// qo'shimcha ma'lumotlar
]
];
$params = [
// qo'shimcha parametrlar (majburiy emas)
];
Yii::app()->notifier->notify($token, $notification, $params);