PHP code example of medianet-dev / fcm

1. Go to this page and download the library: Download medianet-dev/fcm 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 / fcm example snippets


# FCM Log
FCM_LOG=true
# URL path for the images
FCM_IMAGE_UPLOAD_URL="http://localhost/fcm/public/uploads"
# Firebase KEYS
FCM_SERVER_KEY="my_secret_server_key"
FCM_SENDER_ID="my_secret_sender_id"
# Huawei KEYS
HUAWEI_APP_ID="my_secret_server_key"
HUAWEI_APP_SECRET="my_secret_sender_id"
# Notifiable model
FCM_MODEL="App\Models\User"
FCM_USER_ID="id"

$notificationService = new PushNotificationService();

$users = config('fcm.notifiable.model')::get();

$notificationService->send($users, [
	'title' => 'title',
	'description' => 'description'
]);