amrikasir/firebasecmclient

PHP库客户端 Firebase云消息服务

v1.0 2017-07-20 16:35 UTC

This package is auto-updated.

Last update: 2024-09-13 15:49:53 UTC


README

使用composer安装

>$ composer require amrikasir/firebasecmclient

现在在PHP中。

<?php
require_once __DIR__ . '/vendor/autoload.php';

use ald\FirebaseCM;
use ald\Push;

设置推送参数

$push = new Push(
    "ALD Push Notification", //Title
    "dari: " . $_SERVER['HTTP_HOST'] //Message
);

设置服务器密钥

$notification = new FirebaseCM(
    //this is key from server Firebase Cloud Messaging Console
    //and this is new Server key
    "SERVER_KEY_FROM_FCM_CONSOLE"

    //old legacy server key
    //"OR_LEGACY_SERVER_KEY"
);

最终...

设置服务器密钥

echo $notification->send(
    //This is token from client (Android / iOS)
    //You can store this token in mysql server or other dbms
    array(
        'REGISTRATION_TOKEN',
        'OTHER_REGISTRATION_TOKEN'
    ),
    $push->getPush()
);

是为团队内部使用而创建的。

如果有需要,并且(如果可能)改进它。