PHP code example of phnuestro / nativephp-local-notifications
1. Go to this page and download the library: Download phnuestro/nativephp-local-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/ */
phnuestro / nativephp-local-notifications example snippets
use NativePhp\LocalNotifications\Facades\LocalNotification;
LocalNotification::requestPermission();
LocalNotification::send(
title: 'Invoice due',
body: 'Invoice #42 is due tomorrow.',
at: now()->addDay(),
options: [
'id' => 'invoice-42',
'data' => ['invoice_id' => 42],
'url' => 'myapp://invoices/42',
'sound' => true,
'badge' => 1,
'channel_id' => 'billing',
'channel_name' => 'Billing reminders',
],
);
$status = LocalNotification::permissionStatus();
$pending = LocalNotification::pending();
LocalNotification::cancel('invoice-42');
LocalNotification::cancelAll();
shell
composer endor:publish --tag=nativephp-plugins-provider
php artisan native:plugin:register phnuestro/nativephp-local-notifications
php artisan native:plugin:validate
php artisan native:run
shell
php artisan vendor:publish --tag=local-notifications-config