Closed masterbater closed 8 months ago
The usingClient
method takes an instance of Kreait\Firebase\Contract\Messaging::class
. All that example is showing you is getting an instance of that class from Laravel's container. You can instead get your own instance and pass it into the message as you like. Hope this helps.
The
usingClient
method takes an instance ofKreait\Firebase\Contract\Messaging::class
. All that example is showing you is getting an instance of that class from Laravel's container. You can instead get your own instance and pass it into the message as you like. Hope this helps.
My goals is to use a different project config on the fly. Please give an example of code.
Inside your toFcm method create a new Firebase instance for the project you wish, and then pass the messaging component into the client method. You'll need to read up on the Kreait docs to see how to configure this as you need.
@masterbater can u share code for this?
In case this is helpful to anybody, this is how I pulled this off:
public function toFcm(mixed $notifiable): FcmMessage
{
$projectManager = app(\Kreait\Laravel\Firebase\FirebaseProjectManager::class);
$client = $projectManager->project('another-app')->messaging()
return FcmMessage::create()->usingClient($client);
}
With the underlying Firebase we can set another project using config/firebase.php just add another entry like another-app
In this project, how can call underlying project like another-app, is the usingClient is the use case for this, but I dont understand this line
$client = app(\Kreait\Firebase\Contract\Messaging::class);