PHP code example of mrgarest / laravel-firebase-sender

1. Go to this page and download the library: Download mrgarest/laravel-firebase-sender 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/ */

    

mrgarest / laravel-firebase-sender example snippets


$firebaseSender = new FirebaseSender('MY_SERVICE_ACCOUNT_NAME');

$firebaseSender->setDeviceToken('DEVICE_TOKEN');

$firebaseSender->setTopic('TOPIC_NAME')

$firebaseSender->setTopic(TopicCondition::make()
    ->topic('topicA')
    ->and()
    ->group(fn($group) => $group->topic('topicB')->or()->topic('topicC'))
);

$firebaseSender->setNotification(new NotificationPush(
    title: 'TITLE',
    body: 'BODY'
));

$firebaseSender->setAndroid(new AndroidPush(
    title: 'TITLE',
    body: 'BODY'
));

$firebaseSender->setApns(new ApnsPush(
    title: 'TITLE',
    body: 'BODY'
));

$firebaseSender->send();

$firebaseSender->setMessage([
    'token' => 'DEVICE_TOKEN',
    'notification' => [
        'title' => 'TITLE',
        'body' => 'BODY'
    ]
]);

$auth = $firebaseSender->getAuthToken();

[
  "access_token" => "access_token"
  "expires_in" => 3599
  "token_type" => "Bearer"
]

$firebaseSender->setDatabaseLog();

$firebaseSender->setDatabaseLog('TEST_VALUE');

$isValue = FirebaseSenderLog::isValue('TEST_VALUE', 'MY_TOPIC');

$isValue = FirebaseSenderLog::isValueByTimeRange(Carbon::now()->subMinutes(30), 'TEST_VALUE', 'MY_TOPIC');

$isValue = FirebaseSenderLog::isToByTimeRange(Carbon::now()->subMinutes(30), 'MY_TOPIC');

php artisan vendor:publish --tag=firebase-sender-config

php artisan vendor:publish --tag=firebase-sender-migrations

php artisan make:migration