PHP code example of muneebkh2 / laravel-fcm-notifications
1. Go to this page and download the library: Download muneebkh2/laravel-fcm-notifications 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/ */
muneebkh2 / laravel-fcm-notifications example snippets
<php
use Muneebkh2\LaravelFcmNotifications\Facades\LaravelFCM;
LaravelFCM::sendNotification($deviceToken, 'Test Title', 'Test Body');
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Muneebkh2\LaravelFcmNotifications\Facades\LaravelFCM;
class NotificationController extends Controller
{
public function sendPushNotification(Request $request)
{
$deviceToken = $request->input('device_token');
$title = $request->input('title');
$body = $request->input('body');
LaravelFCM::sendNotification($deviceToken, $title, $body);
return response()->json(['message' => 'Notification sent successfully']);
}
}