Skip to content

[Bug]: Notifications Not Showing #48

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
JordanDalton opened this issue Jul 22, 2023 · 11 comments
Closed

[Bug]: Notifications Not Showing #48

JordanDalton opened this issue Jul 22, 2023 · 11 comments
Labels
bug Something isn't working

Comments

@JordanDalton
Copy link

What happened?

I'm unable to successfully create a notification. I'm using the documentation from Native's website pertaining to Notifications.

I've noticed that the path to the facade, Native\Laravel\Facades\Notification, is not in Native's file path.

Here's the shared trace for it: https://flareapp.io/share/95Jll42P

How to reproduce the bug

Use the following snippet from: https://nativephp.com/docs/1/the-basics/notifications

`use Native\Laravel\Facades\Notification;

Notification::title('Hello from NativePHP')
->message('This is a detail message coming from your Laravel app.')
->show();`

Package Version

0.1.0

PHP Version

8.2.8

Laravel Version

10.15.0

Which operating systems does with happen with?

macOS

Notes

No response

@JordanDalton JordanDalton added the bug Something isn't working label Jul 22, 2023
@khalmurad
Copy link

khalmurad commented Jul 22, 2023

Hi.
I used like this:

$client = new Client();
$notification = new Notification($client);
$notification->title('Hello from NativeApp')
     ->message('This is a detailed message coming from your native app.')
     ->show();

The reason is that the Notification class is not in the place written in the documentation, but it is located in this place: Native\Laravel\Notification

In addition, the title function in the Notification class is not static.

@balduinofernando
Copy link

Thanks @khalmurad

This solution you pointed worked out fine...

Screenshot from 2023-07-22 16-42-30

@JordanDalton
Copy link
Author

The update removed the error, but a notification isn't appearing.

@csfh
Copy link

csfh commented Jul 23, 2023

At this time, the latest published package is not synced with the documentation.

To build off of the example above.

use Native\Laravel\Client\Client;
use Native\Laravel\Notification;

function createAndShowNotification() {
  $client = new Client();
  $notification->title('Hello from NativePHP')
    ->message('This is a detail message coming from your Laravel app.')
    ->show();
}

Make sure you are invoking this from within the Electron (or eventually Tauri) since if you are using artisan commands or just visiting your site via the browser, there's nothing to receive the notification.

And then of course, make sure you allow notifications from Electron (or eventually Tauri) and that you are not silencing them for example via your system notification center.

@multipacman
Copy link

multipacman commented Jul 24, 2023

You could also achieve this using only the Notification import since they have already initialised a client with the new function.

use Native\Laravel\Notification;

function createAndShowNotification() {
    Notification::new()
          ->title('Hello from NativePHP')
          ->message('This is a detail message coming from your Laravel app.')
          ->show();
}

@khalmurad
Copy link

khalmurad commented Jul 24, 2023

Thanks @khalmurad

This solution you pointed worked out fine...

Screenshot from 2023-07-22 16-42-30

There have been minor updates. Now you can write it like this:

use Native\Laravel\Notification;

Notification::new()
    ->title('Hello from NativeApp')
    ->message('This is a detail message coming from your native app.')
    ->show();

@ArielMejiaDev
Copy link

@JordanDalton do you check your settings, Apple requires to allow for every single app permission to show notifications.

@abishekrsrikaanth
Copy link

Is there a way to change the icon on the notifications? Do see any docs for that. I am assuming that changing the icon for the app will automatically do that, but still not sure how to do that.

@simonhamp
Copy link
Member

The Notification facade was added in #25 and was released in v0.1.1

@abishekrsrikaanth please could you raise the icon issue as a feature request?

@abishekrsrikaanth
Copy link

@simonhamp the feature request templates was not working, is that fixed?

@simonhamp
Copy link
Member

@abishekrsrikaanth Yes I fixed that a little earlier today

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants