PHP code example of smronju / nativephp-local-notifications

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

    

smronju / nativephp-local-notifications example snippets


use Smronju\NativephpLocalNotifications\Facades\LocalNotifications;

// Ask once, wherever makes sense in your app (e.g. the first time a user sets
// a reminder). Fire-and-forget — there's no result to branch on, since the OS
// simply won't show a notification the user never granted permission for.
LocalNotifications::requestPermission();

// Schedule — `$at` is anything implementing DateTimeInterface (Carbon , since nothing in your app
// re-evaluates it at fire time. Fires every day at 09:00 local time, forever,
// even if the app is never reopened after scheduling.
LocalNotifications::scheduleDaily(
    id: 'daily-overdue-reminder',
    title: 'IOU reminder',
    body: 'Check your overdue entries — open IOU now!.',
    hour: 9,
    minute: 0,
);
LocalNotifications::cancel('daily-overdue-reminder');