0

通知系统用于向特定用户发送一些消息。但全局事件在 js 文件中不可用。

js中的代码

        abp.event.on('abp.notifications.received', function (userNotification) {
        console.log("userNotification", userNotification);
    });

应用程序中的代码

    public class NotificationTestService : AcsAppServiceBase, INotificationTestService
    {
        private INotificationPublisher _notificationPublisher;
        private readonly IRepository<User, long> _userRepository;

        public NotificationTestService(INotificationPublisher notificationPublisher, IRepository<User, long> userRepository)
        {
            _notificationPublisher = notificationPublisher;
            _userRepository = userRepository;
        }

        public async void NotificationTest()
        {
            string message = "Test Message";

            var currentUser = (await this.GetCurrentUserAsync()).ToUserIdentifier();

            _notificationPublisher.Publish("NotificationTest", new MessageNotificationData(message), severity: NotificationSeverity.Info, userIds: new[] { currentUser });
        }
    }
  1. 通知数据 1
  2. 通知数据 2

我在数据库中找到了通知数据,但是在 js 文件中没有触发事件。没有异常抛出。感谢您的任何帮助。

4

0 回答 0