From 0cb1ca53a9f28eb4793e81dfba4e9366da0cdd2a Mon Sep 17 00:00:00 2001 From: Andreas Creten Date: Thu, 20 Feb 2025 22:07:32 +0100 Subject: [PATCH 1/2] Update Notifications docs --- .../desktop/1/the-basics/notifications.md | 89 +++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/resources/views/docs/desktop/1/the-basics/notifications.md b/resources/views/docs/desktop/1/the-basics/notifications.md index f2406603..e6e6773c 100644 --- a/resources/views/docs/desktop/1/the-basics/notifications.md +++ b/resources/views/docs/desktop/1/the-basics/notifications.md @@ -40,8 +40,97 @@ Notification::title('Hello from NativePHP') ->show(); ``` +### Notification Reference + +To keep track of different notifications, each notification gets a reference once created. You can manually set a reference using the `reference()` method. +By default, the current unix timestamp is used as the reference. Once the notification is shown, the reference is stored in the notification class. + +``` +$notification = Notification::title('Hello from NativePHP')->show(); +$notification->reference; // <-- This property contains the reference +``` + +## Configuring Notifications + +### Notification Title + +You may set the notification's title using the `title()` method. + +```php +Notification::title('Hello from NativePHP') + ->show(); +``` + +### Notification Reference + +You can use the `reference()` method to set an event identifier and track which notification triggered a certain event. +This reference will be sent along with any event triggered by the notification. By default, the current unix timestamp is used as the reference. + +```php +Notification::title('Hello from NativePHP') + ->reference(Str::uuid()) + ->show(); +``` + +### Notification Message + +You may set the notification's message using the `message()` method. + +```php +Notification::title('Hello from NativePHP') + ->message('This is a detail message coming from your Laravel app.') + ->show(); +``` + +### Notification Reply + +On macOS, you can allow the user to reply to a notification using the `hasReply()` method. + +```php +Notification::title('Hello from NativePHP') + ->hasReply() + ->show(); +``` + +The `hasReply()` method accepts a placeholder reply message as an argument. + +```php +Notification::title('Hello from NativePHP') + ->hasReply('This is a placeholder') + ->show(); +``` + +### Notification Actions + +On macOS, you can add action buttons to a notification using the `addAction()` method. + +```php +Notification::title('Hello from NativePHP') + ->addAction('Click here') + ->show(); +``` + +You can call the `addAction()` method multiple times if you need to add multiple buttons. + +```php +Notification::title('Hello from NativePHP') + ->addAction('Button One') + ->addAction('Button Two') + ->show(); +``` + ## Events ### `NotificationClicked` The `Native\Laravel\Events\Notifications\NotificationClicked` event is dispatched when a user clicks on a notification. +### `NotificationClosed` +The `Native\Laravel\Events\Notifications\NotificationClosed` event is dispatched when a user closes a notification. + +### `NotificationReply` +The `Native\Laravel\Events\Notifications\NotificationReply` event is dispatched when a user replies to a notification. + +### `NotificationActionClicked` +The `Native\Laravel\Events\Notifications\NotificationActionClicked` event is dispatched when a user clicks an action button on a notification. + +The `$index` references to the order of the buttons. The first button added has an index of `0`. From 5680c0f08995f59f7df56dd755139bbc5c6133bf Mon Sep 17 00:00:00 2001 From: Eser DENIZ Date: Fri, 21 Feb 2025 14:46:53 +0100 Subject: [PATCH 2/2] Update notifications.md --- resources/views/docs/desktop/1/the-basics/notifications.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/resources/views/docs/desktop/1/the-basics/notifications.md b/resources/views/docs/desktop/1/the-basics/notifications.md index e6e6773c..efe38941 100644 --- a/resources/views/docs/desktop/1/the-basics/notifications.md +++ b/resources/views/docs/desktop/1/the-basics/notifications.md @@ -43,7 +43,7 @@ Notification::title('Hello from NativePHP') ### Notification Reference To keep track of different notifications, each notification gets a reference once created. You can manually set a reference using the `reference()` method. -By default, the current unix timestamp is used as the reference. Once the notification is shown, the reference is stored in the notification class. +By default, a unique id is used as the reference. Once the notification is shown, the reference is stored in the notification class. ``` $notification = Notification::title('Hello from NativePHP')->show(); @@ -64,7 +64,7 @@ Notification::title('Hello from NativePHP') ### Notification Reference You can use the `reference()` method to set an event identifier and track which notification triggered a certain event. -This reference will be sent along with any event triggered by the notification. By default, the current unix timestamp is used as the reference. +This reference will be sent along with any event triggered by the notification. By default, a unique id is used as the reference. ```php Notification::title('Hello from NativePHP')