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.9 KiB
2.9 KiB
LINGYUN.Abp.Notifications.WxPusher
ABP notification module implemented through WxPusher, providing real-time notification functionality via WxPusher.
Features
- Support for multiple message types
- Text messages
- HTML messages
- Markdown messages
- Flexible message targeting
- Send to specific users
- Send to specific Topics
- Multi-language support
- Localized message content
- Multi-language titles and descriptions
- Feature toggle control
- Message sending controlled by feature switches
Installation
dotnet add package LINGYUN.Abp.Notifications.WxPusher
Module Reference
[DependsOn(typeof(AbpNotificationsWxPusherModule))]
public class YouProjectModule : AbpModule
{
// other
}
Configuration
1. Notification Definition Configuration
public class YourNotificationDefinitionProvider : NotificationDefinitionProvider
{
public override void Define(INotificationDefinitionContext context)
{
var notification = context.Create(
name: "App.Notification.Test",
displayName: L("TestNotification"))
.WithContentType(MessageContentType.Text) // Set message type
.WithTopics(new List<int> { 1, 2 }) // Set message Topics
.WithUrl("https://example.com"); // Set URL to jump to when clicking the message
}
}
2. Sending Notifications
public class YourService
{
private readonly INotificationPublisher _notificationPublisher;
public YourService(INotificationPublisher notificationPublisher)
{
_notificationPublisher = notificationPublisher;
}
public async Task SendNotificationAsync()
{
var notificationData = new NotificationData();
// Set message content
notificationData.TrySetData("title", "Message Title");
notificationData.TrySetData("message", "Message Content");
notificationData.SetUrl("https://example.com"); // Set URL to jump to when clicking the message
await _notificationPublisher.PublishAsync(
"App.Notification.Test", // Notification name
notificationData, // Notification data
userIds: new[] { "userId" }, // Recipient user IDs
tenantIds: new[] { "tenantId" } // Tenant IDs
);
}
}
Important Notes
- Implementation of
IWxPusherUserStoreinterface is required to manage user associations with WxPusher. - Message sending depends on WxPusher API, ensure network connectivity is stable.
- Set message content length reasonably to avoid exceeding WxPusher limits.
- When using multi-language features, ensure localization resources are properly configured.