PHP code example of mowahed / firebase-notification

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

    

mowahed / firebase-notification example snippets



 'channels' => [
    'firebase' => [
        'driver' => 'single',
        'path' => storage_path('logs/firebase.log'),
        'level' => 'error',
    ],
],


use Mowahed\FirebaseNotification\Facades\FirebaseNotification;

$response = FirebaseNotification::sendToDevice('device_fcm_token', [
    'title' => 'Welcome!',
    'body' => 'Thanks for installing our app!',
    'link' => 'https://yourapp.com',
    'sound' => 'default',
    'image' => 'https://example.com/notification.png',
    'priority' => 'high'
]);
 

FirebaseNotification::sendToTopic('news,' [
    'title' => 'Breaking News',
    'body' => 'Something big just happened!',
    'link' => 'https://yourapp.com/news',
    'sound' => 'default'
]);

$response = FirebaseNotification::subscribeToTopic(
    ['device_token_1', 'device_token_2'],
    'news'
);

$response = FirebaseNotification::sendToCondition(
    "'sports' in topics || 'news' in topics",
    [
        'title' => 'Sports News',
        'body' => 'Latest sports updates!',
        'link' => 'https://yourapp.com/sports'
    ]
);


$response = FirebaseNotification::unsubscribeFromTopic(
    ['device_token_1', 'device_token_2'],
    'news'
);