这是基于vue-vben-admin 模板适用于abp Vnext的前端管理项目
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

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

  1. Implementation of IWxPusherUserStore interface is required to manage user associations with WxPusher.
  2. Message sending depends on WxPusher API, ensure network connectivity is stable.
  3. Set message content length reasonably to avoid exceeding WxPusher limits.
  4. When using multi-language features, ensure localization resources are properly configured.

Source Code

LINGYUN.Abp.Notifications.WxPusher