Closed sncbtz closed 2 years ago
@soyjesus did you manage to find a way to send expo-notifications? We're also i need of sending data only notifications.
I'm building Finni.app and we are using the following Notification class to send data-only messages.
<?php
namespace App\Notifications;
.........
class AppAlertDashboardReady 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 [FcmChannel::class];
}
/**
* Get the array representation of the notification.
*
* @param mixed $notifiable
* @return array
*/
public function toArray($notifiable)
{
return [
//
];
}
public function toFcm($notifiable)
{
$message = "You can view your financial report now";
return FcmMessage::create()
->setNotification(null)
->setData([
'type' => 'testtext',
'title' => 'Your Finni Dashboard is Ready',
'body' => $message
])
->setAndroid(
AndroidConfig::create()
->setFcmOptions(
AndroidFcmOptions::create()->setAnalyticsLabel(
'analytics'
)
)
);
}
}
Happy to look over any PR that wants to take a stab at implementing this.
Is there a way to set the notification type as mentioned in the FCM docs?
I'm having problems implementing with React Native (expo managed projec) and found a little piece of advice in the expo docs: