akshita / notification-firebase-twilio-email-package
通过电子邮件和Twilio短信以及Firebase推送通知向用户发送通知
dev-main
2023-10-27 12:12 UTC
Requires
- php: ^7.3
- illuminate/notifications: ^8.0
- illuminate/support: ^8.0
- kreait/laravel-firebase: ^4.2
- laravel/framework: ^8.0
This package is auto-updated.
Last update: 2024-09-27 14:20:24 UTC
README
通过Firebase云消息、Twilio短信和电子邮件简化并简化发送通知的过程。
目录
简介
欢迎来到 Notification Firebase Twilio Email Package!本包提供了一种无缝发送各种类型通知的方法 - 如短信、SMS和电子邮件 - 通过Firebase云消息、Twilio SMS和Laravel内置的电子邮件功能发送给用户。使用本包,您可以轻松地使用用户首选的通信渠道与他们互动。
功能
- 使用Firebase云消息发送通知,以触达用户的移动设备。
- 利用Twilio SMS功能向用户的手机发送简短的消息。
- 利用Laravel的本地电子邮件支持通过电子邮件发送详细的提示。
- 自定义和配置您的通知,以适应您的应用程序需求。
安装
要开始使用 Notification Firebase Twilio Email Package,请按照以下步骤操作
-
通过Composer安装包
composer require akshita/notification-firebase-twilio-email-package
-
在您的Laravel项目的
config/app.php
中添加服务提供者
'providers' => [ // ... Akshita\NotificationFirebaseTwilioEmailPackage\Providers\NotificationServiceProvider::class, ],
用法
使用 Notification Firebase Twilio Email Package 发送通知非常简单。以下是您如何在Laravel应用程序中使用它的方法
use Akshita\NotificationFirebaseTwilioEmailPackage\Notification; // Test this package by Notification::test(); // Send all notification by one function based on Content_Configuration $recipient = ['FirebaseDeviceToken']; // one or more according to the need $action = 'login'; // data defined in the notification content file //veriables you want to replace $extra_data = [ 'user_name' => 'akshita', 'full_name' => 'Akshita Manlgik', 'otp' => '1234', ]; $result = Notification::sendNotification($recipientData, $action, $extra_data = null) if ($result) { // Notification sent successfully. } else { // Notification sending failed. } // Send a Firebase Cloud Messaging notification $recipient = ['FirebaseDeviceToken']; $data = [ "title" => $content['title'], "body" => $content['body'], "click_action" => $content['click_action'], ]; $result = Notification::sendFirebaseMessage($recipient, $content, $extra_data = null ); // Send a Twilio SMS notification $recipient = '+1234567890'; $message = 'Hello from Twilio SMS!'; Notification::sendTwilioSMS($recipient, $message); Notification::sendNexmoSMS($recipient, $message); // Send an email notification $recipient = 'user@example.com'; $subject = 'Important Update'; $message = 'Hello from Email Notification!'; Notification::sendEmail($recipient, $subject, $message);
配置
通过修改您的Laravel应用程序中的 config/notification.php
文件来配置您的通知选项。自定义设置,如API凭证、发送者信息等,以满足您的需求。
... FIREBASE_SERVER_KEY NOTIFICATION_MESSAGE_DRIVER // twilio or nexmo TWILIO_ACCOUNT_SID TWILIO_AUTH_TOKEN TWILIO_SERVICE_ID NEXMO_API_KEY NEXMO_API_SECRET NEXMO_FROM MAIL_MAILER MAIL_HOST MAIL_USERNAME MAIL_PASSWORD MAIL_FROM_NAME ...
内容配置
通过修改您的Laravel应用程序中的 config/notificationContent.php
文件来配置您的通知选项。自定义设置,如要发送的通知、其内容等,以满足您的需求。
return [ 'action' => [ 'push_notification' => 'true', 'title' => 'title', 'body' => 'body', 'click_action' => '', 'sms_message' => 'false', 'sms_message_body' => 'sms_message_body', 'email' => 'false', 'email_title' => 'email_title', 'email_body' => 'email_body' ], 'login' => [ 'push_notification' => 'true', 'title' => 'Login Successful', 'body' => '{{full_name}}, you have logged in successfully.', 'click_action' => '', 'sms_message' => 'true', 'sms_message_body' => '{{full_name}}, you have logged in successfully.', 'email' => 'false', 'email_title' => 'Login Successful Email Subject', 'email_body' => '{{full_name}}, you have logged in successfully.' ], .... ];
贡献
欢迎贡献!如果您遇到问题或想提出改进建议,请打开GitHub上的问题或提交拉取请求。
许可
本软件包是开源软件,许可协议为MIT许可证。