$serviceAccountFile = '/var/www/html/credentials.json';
$scopes = ['https://www.googleapis.com/auth/firebase.messaging'];
$credentials = new ServiceAccountCredentials(
$scopes,
$serviceAccountFile
);
$token = $credentials->fetchAuthToken();
$accessToken = $token['access_token'];
{
"message": {
"token": "eVkcH93BTwmpd06HPtuxeY:APA91bHNW6ZIAOe1IOKmpdHmiRQSnN69X_s4Duq0bYbaCt6IVDsh80KkjBNRxVoUMRUyRoHjn6HQlRrm9I5_Kj0eciorJ9rrlfUqeDJwiBcrFpV5aZeNwsRmOXPIkPeZJeHHQdKSM_ERs",
"notification": {
"title": "Breaking News",
"body": "New news story available."
},
"data": {
"story_id": "story_12345"
}
}
}
{
"error": {
"code": 400,
"message": "The registration token is not a valid FCM registration token",
"status": "INVALID_ARGUMENT",
"details": [
{
"@type": "type.googleapis.com/google.firebase.fcm.v1.FcmError",
"errorCode": "INVALID_ARGUMENT"
}
]
}
}
'push_sender' => [AsyncPushSender::class, 'sendMessageNewChatMessage']
$push_sender = Yii::$app->getModule('server-chat')->push_sender;
$push_sender($message, $preparedData, $title, $type, $userID);
$push_sender = Yii::$app->getModule('server-chat')->push_sender;
$push_sender($message, $preparedData, $title, $type, $userID);
class Module extends \yii\base\Module
{
public $count_workers = 2;
public $domain = '192.168.1.1';
public $host = '127.0.0.1';
public $domain_workerman = 'php';
public $port = 2346;
public $ssl = false;
public $ssl_cert = '/etc/ssl/home-call.crt';
public $ssl_pkey = '/etc/ssl/home-call.key';
public $db = 'db';
public $push_sender = null;
}