这是基于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.4 KiB

LINGYUN.Abp.Notifications.Sms

SMS implementation of notification publishing provider

Most rewritten modules maintain the same name as the official modules and are distinguished by namespace, mainly because only a small part was rewritten or additional functionality was added. If most of the module code is rewritten, or if it's a completely extended module, then it will have its own name.

Note

Custom sending methods can be implemented by implementing the ##ISmsNotificationSender## interface or overriding ##SmsNotificationSender##

Features

  • SMS notification sending
  • SMS template support
  • Support for multiple SMS service providers
  • Support for SMS variable replacement
  • Support for batch sending

Configuration

  • This configuration item will be removed in the next major SMS-related version
{
  "Notifications": {
    "Sms": {
      "TemplateParamsPrefix": "SMS template variable prefix"
    }
  }
}
[DependsOn(typeof(AbpNotificationsSmsModule))]
public class YouProjectModule : AbpModule
{
  // other
}

Basic Usage

  1. Implement SMS sending interface
public class YourSmsNotificationSender : SmsNotificationSender
{
    public override async Task SendAsync(NotificationInfo notification)
    {
        var templateParams = GetTemplateParams(notification);
        await SmsService.SendAsync(
            notification.UserPhoneNumber,
            notification.Title,
            templateParams
        );
    }
}
  1. Register SMS sending service
Configure<AbpNotificationsSmsOptions>(options =>
{
    options.TemplateParamsPrefix = "sms_"; // SMS template variable prefix
});
  1. Send SMS notification
public class YourService
{
    private readonly INotificationSender _notificationSender;

    public YourService(INotificationSender notificationSender)
    {
        _notificationSender = notificationSender;
    }

    public async Task SendSmsNotificationAsync()
    {
        await _notificationSender.SendNofiterAsync(
            "YourNotification",
            new NotificationData
            {
                // SMS template parameters
                ["sms_code"] = "123456",
                ["sms_time"] = "5"
            },
            userIds: new[] { CurrentUser.Id }
        );
    }
}

More Information