Messaging API version.
use Illuminate\Notifications\Notification;
use Revolution\Line\Notifications\LineChannel;
use Revolution\Line\Notifications\LineMessage;
class TestNotification extends Notification
{
public function via(object $notifiable): array
{
return [
LineChannel::class
];
}
public function toLine(object $notifiable): LineMessage
{
return LineMessage::create(text: 'test');
}
}
use Illuminate\Support\Facades\Notification;
Notification::route('line', 'to')
->notify(new TestNotification());
use Illuminate\Notifications\Notifiable;
class User
{
use Notifiable;
public function routeNotificationForLine($notification): string
{
return $this->line_id;
}
}
$user->notify(new TestNotification());
userId or groupId. ID can be obtained from FollowEvent or JoinEvent.
You can send up to 5 messages.
use Revolution\Line\Notifications\LineMessage;
public function toLine(object $notifiable): LineMessage
{
return LineMessage::create()
->text('text 1')
->text('text 2');
}
Make sure you use withSender()
before any other message adding methods.
use Revolution\Line\Notifications\LineMessage;
public function toLine(object $notifiable): LineMessage
{
return LineMessage::create()
->withSender(name: 'alt-name', icon: 'https://...png')
->text('text 1')
->text('text 2');
}
You can also specify a name and icon with create()
method, which is easier if you're just creating a single text message.
use Revolution\Line\Notifications\LineMessage;
public function toLine(object $notifiable): LineMessage
{
return LineMessage::create(text: 'test', name: 'alt-name', icon: 'https://...png');
}
Only the stickers on this page can be used. https://developers.line.biz/en/docs/messaging-api/sticker-list/
use Revolution\Line\Notifications\LineMessage;
public function toLine(object $notifiable): LineMessage
{
return LineMessage::create()
->text('test')
->sticker(package: 446, sticker: 1988);
}
Specify a public URL.
use Revolution\Line\Notifications\LineMessage;
public function toLine(object $notifiable): LineMessage
{
return LineMessage::create()
->image(original: 'https://.../test.png', preview: 'https://.../preview.png');
}
Specify a public URL.
use Revolution\Line\Notifications\LineMessage;
public function toLine(object $notifiable): LineMessage
{
return LineMessage::create()
->video(original: 'https://.../test.mp4', preview: 'https://.../preview.png');
}
You can add any message type with message()
. Don't forget to specify the type with setType()
.
use LINE\Clients\MessagingApi\Model\LocationMessage;
use LINE\Constants\MessageType;
use Revolution\Line\Notifications\LineMessage;
public function toLine(object $notifiable): LineMessage
{
$location = (new LocationMessage())
->setType(MessageType::LOCATION)
->setTitle('title')
->setAddress('address')
->setLatitude(0.0)
->setLongitude(0.0);
return LineMessage::create()
->message($location);
}