You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Maybe i'm just making a mistake and overlooking something but at the moment I'm trying to send notifications to all my OneSignal subscribers. I don't have their OneSIgnal player id's stored in my database because I'm creating a news application where people can subscribe but don't need an user account for it.
So the default laravel functionality in my controller Notification::send(User::all(), new OneSignalNotification($news->title,'fijeoapwq', \route('admin.news.show',$news->id)));
Will not work for me. But testing with this and in User class hard coding public function routeNotificationForOneSignal(){ return 'ONESIGNAL_PLAYER_ID'; }
Actually works for me but for the love of god i can't figure how to get it working sending the notification to my Active Users segment.
I have tried things like this in my OneSignalNotification class:
namespace App\Notifications;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Notifications\Notification;
use NotificationChannels\OneSignal\OneSignalChannel;
use NotificationChannels\OneSignal\OneSignalMessage;
class OneSignalNotification extends Notification
{
use Queueable;
/**
* Create a new notification instance.
*
* @return void
*/
public function __construct(public string $subject, public string $body, public string $url)
{
//
}
/**
* Get the notification's delivery channels.
*
* @param mixed $notifiable
* @return array
*/
public function via($notifiable)
{
return [OneSignalChannel::class];
}
public function toOneSignal($notifiable)
{
return OneSignalMessage::create()
->setSubject($this->subject)
->setBody($this->body)
->setUrl($this->url)
->setParameter('included_segments','Active Users');
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
}
Is something broken or could someone help my figuring this out?
The text was updated successfully, but these errors were encountered:
Hi,
Maybe i'm just making a mistake and overlooking something but at the moment I'm trying to send notifications to all my OneSignal subscribers. I don't have their OneSIgnal player id's stored in my database because I'm creating a news application where people can subscribe but don't need an user account for it.
So the default laravel functionality in my controller
Notification::send(User::all(), new OneSignalNotification($news->title,'fijeoapwq', \route('admin.news.show',$news->id)));
Will not work for me. But testing with this and in User class hard coding
public function routeNotificationForOneSignal(){ return 'ONESIGNAL_PLAYER_ID'; }
Actually works for me but for the love of god i can't figure how to get it working sending the notification to my Active Users segment.
I have tried things like this in my OneSignalNotification class:
Is something broken or could someone help my figuring this out?
The text was updated successfully, but these errors were encountered: