PHP code example of medianet-dev / cloud-message

1. Go to this page and download the library: Download medianet-dev/cloud-message 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/ */

    

medianet-dev / cloud-message example snippets


use MedianetDev\CloudMessage\Facade\CloudMessage;

$message = [
    'title' => "Your notification title",
    'body' => "Your notification body",
];

$registrationTokens = [
    'token1',
    'token2'
];

// Send via Firebase (default)
$results = CloudMessage::sendToTokens($message, $registrationTokens);

// Send via Huawei
$results = CloudMessage::sendToTokens($message, $registrationTokens, 'huawei');

use MedianetDev\CloudMessage\Drivers\FirebaseNotification;

$message = [
    'title' => "Your notification title",
    'body' => "Your notification body",
];

$registrationTokens = [
    'token1',
    'token2'
];

$results = FirebaseNotification::sendToTokens($message, $registrationTokens);

$topic = 'guests'
$registrationTokens = [
    'token1',
    'token2'
];

$results = FirebaseNotification::subscribeToTopic($topic, $registrationTokens);

$topic = 'guests'
$registrationTokens = [
    'token1',
    'token2'
];

$results = FirebaseNotification::unsubscribeToTopic($topic, $registrationTokens);

return [
    // Other configurations...

    'async_requests' => env('CLOUD_MESSAGE_ASYNC_REQUESTS', false),
];
bash
php artisan vendor:publish --provider="MedianetDev\CloudMessage\CloudMessageServiceProvider" --tag="config"