You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.7 KiB
2.7 KiB
LINGYUN.Abp.Notifications.PushPlus
PushPlus implementation of the notification module
Enables applications to publish real-time notifications through PushPlus
Features
- Support for multiple message types
- Text messages
- HTML messages
- Markdown messages
- Image messages
- Custom template messages
- Message callback support
- Custom callback URL support
- Message sending status callback support
- Multi-channel push support
- WeChat Official Account
- WeChat Work
- SMS
- WebHook
- Group message support
- Group push support
- Group management support
Module Reference
[DependsOn(typeof(AbpNotificationsPushPlusModule))]
public class YouProjectModule : AbpModule
{
// other
}
Configuration
{
"PushPlus": {
"Token": "Your PushPlus Token",
"DefaultChannel": "wechat", // Default push channel: wechat/webhook/mail/sms
"DefaultTemplate": "html", // Default message template: html/json/markdown/txt
"DefaultWebhook": "", // Default Webhook URL
"DefaultCallbackUrl": "" // Default callback URL
}
}
Basic Usage
- Configure PushPlus Service
public override void ConfigureServices(ServiceConfigurationContext context)
{
Configure<AbpNotificationsPushPlusOptions>(options =>
{
options.Token = "Your PushPlus Token";
options.DefaultChannel = "wechat";
options.DefaultTemplate = "html";
});
}
- Send Notification
public class YourService
{
private readonly INotificationSender _notificationSender;
public YourService(INotificationSender notificationSender)
{
_notificationSender = notificationSender;
}
public async Task SendNotificationAsync()
{
var notificationData = new NotificationData();
notificationData.TrySetData("title", "Message Title");
notificationData.TrySetData("content", "Message Content");
notificationData.SetWebhook("https://your-webhook.com");
notificationData.SetCallbackUrl("https://your-callback.com");
await _notificationSender.SendNofiterAsync(
"YourNotification",
notificationData,
userIds: new[] { CurrentUser.Id }
);
}
}
Important Notes
- Registration on the PushPlus platform and obtaining a Token is required before use.
- Ensure the configured Token is valid and has sufficient permissions.
- Callback URL must be accessible from the public internet.
- Different channels may have different message format requirements.
- Message sending depends on PushPlus API, ensure network connectivity is stable.