I am quite new to Laravel and couldn't find any practical example of the library https://github.com/Alymosul/laravel-exponent-push-notifications. I want to create a simple Welcome-Notification.
My Notification looks like this:
<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Notifications\Notification;
use NotificationChannels\ExpoPushNotifications\ExpoChannel;
use NotificationChannels\ExpoPushNotifications\ExpoMessage;
class WelcomeNotification extends Notification
{
use Queueable;
public function __construct(){
}
public function via($notifiable)
{
return [ExpoChannel::class];
}
public function toExpoPush($notifiable)
{
return ExpoMessage::create()
->badge(1)
->title("Hello World!")
->enableSound()
->body("Hello World!");
}
public function toArray($notifiable)
{
return [
];
}
}
I already subscribed a user with the help of the subscribe route (successfully created an DB entry).
Now i want to send the notification to the user:
public function sendNotification(Request $request)
{
$getUserByEmail = User::where('email', '[email protected]')->first();
$getUserByEmail->notify(new WelcomeNotification());
}
I didn't receive the notification. When using the expo notification tool it works as expected.
Could you please explain to me what am I doing wrong?