Closed ALiSHERBE closed 6 years ago
Hello,
What did you try? Have you setup everything Like the Readme says?
Hello,
I did everything as written in readme.md. Laravel 5.5. Do I need to create a rootNotificationFormone Signal if I want to send notifications to everyone?
Can you provide any error log or information to help us figure out where the problem is?
Closed due to lack of inactivity.
same here too, ... it is not even getting to the method that sends the notification , ... changed the via method to mail and it got to the toMail method
`<?php
namespace App\Notifications;
use Illuminate\Bus\Queueable; use Illuminate\Notifications\Notification; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; use NotificationChannels\OneSignal\OneSignalChannel; use NotificationChannels\OneSignal\OneSignalMessage; use NotificationChannels\OneSignal\OneSignalWebButton;
class GeneralMessage extends Notification { use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct()
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [OneSignalChannel::class];
}
public function toOneSignal($notifiable)
{
dd('dd');
return OneSignalMessage::create()
->subject("Your {$notifiable->service} account was approved!")
->body("Click here to see details.")
->url('http://onesignal.com')
->webButton(
OneSignalWebButton::create('link-1')
->text('Click here')
->icon('https://upload.wikimedia.org/wikipedia/commons/4/4f/Laravel_logo.png')
->url('http://laravel.com')
);
}
public function routeNotificationForOneSignal()
{
return 'b6d8104b-576d-4919-8bdf-c1f9534875f1';
// return ['tags' => ['key' => 'device_uuid', 'relation' => '=', 'value' => '1234567890-abcdefgh-1234567']];
}
/**
* Get the mail representation of the notification.
*
* @param mixed $notifiable
* @return \Illuminate\Notifications\Messages\MailMessage
*/
public function toMail($notifiable)
{
dd('fff');
return (new MailMessage)
->line('The introduction to the notification.')
->action('Notification Action', url('/'))
->line('Thank you for using our application!');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}`
@rylxes the 'routeNotificationForOneSignal()' method goes in your Notifiable model (ie the user model), you then send the notification to that user.
Not working notification.