Closed clickervinod closed 5 years ago
Sorry but i did not get your question. Do you want to send notifications from the User and the Admin Model? This is already possible, you just need to add the Illuminate\Notifications\Notifiable
trait to your model. See https://laravel.com/docs/5.8/notifications#using-the-notifiable-trait for more information about this.
hi, Thank for reply let me explain. I have two App in Onsignal with the different app package name and FCM ID in this package there is only one option to add API Key
in Onesignal account, there is two different ONESIGNAL APP ID and REST API KEY for both App User App- http://prntscr.com/njep9g Admin App - http://prntscr.com/njeps6
Laravel Cofig file- http://prntscr.com/njer2u
Now if I have to send some notification to Admin App and User App. How I do this?
Thanks
You can change your OneSignal Credentials on the fly. See https://github.com/laravel-notification-channels/onesignal/issues/79 for more details.
@ClickerVinod Are you able to achieve it and if yes can you share how you did it? I need to do something similar to this. I need to load the ONSIGNAL APP ID and REST API KEY based on the channels i receive.
you can do that by creating a custom onesignal channel and list the models and its' config :
<?php
namespace App\Notifications\Channels;
use Berkayk\OneSignal\OneSignalClient;
use Illuminate\Notifications\Notification;
use NotificationChannels\OneSignal\OneSignalChannel as vendorOneSignalChannel;
class OneSignalChannel extends vendorOneSignalChannel
{
public function send($notifiable, Notification $notification)
{
$config = match (class_basename($notifiable)) {
'User' => config('services.user_onesignal'),
'StoreAdmin' => config('services.store_onesignal'),
};
$this->oneSignal = new OneSignalClient(...array_values($config));
return parent::send($notifiable, $notification);
}
}
then in your notification you must use this channel instead of the package's one.
Hi,
I have two App User App and Admin App, using two laurel Model "User" and "Admin" how to send notification
on both App
Thanks