1. Go to this page and download the library: Download irice/yii2-fcm-manager 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/ */
$result = Yii::$app->fcm->deviceRegisterClass::registerDevice(
'<registed_device_token>', // or ['<registed_device_token1>', '<registed_device_token2>']
<user_id> // user identity id
);
$result = Yii::$app->fcm->subscribeToTopic(
'<topic-name>',
'<registed_device_token>' // or ['<registed_device_token1>', '<registed_device_token2>']
);
$result = Yii::$app->fcm->unSubscribeFromTopic(
'<topic-name>',
'<registed_device_token>' // or ['<registed_device_token1>', '<registed_device_token2>']
);
class Notification extends \yii\db\ActiveRecord implements \fcm\manager\models\NotificationInterface
{
...
public function getSuccessStatus()
{
return static::STATUS['SENDED'];
}
public function getFailStatus()
{
return static::STATUS['FAILED'];
}
public function updateStatus($value)
{
$this->status = $value;
return $this->save();
}
}
php yii migrate
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.