From df557a3390205740851d0f7df50139f44962a4ed Mon Sep 17 00:00:00 2001 From: Ahmet Date: Wed, 7 Apr 2021 18:49:58 +0300 Subject: [PATCH 1/4] Prepare SMS-Sending documentation --- docs/en/SMS-Sending.md | 98 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 96 insertions(+), 2 deletions(-) diff --git a/docs/en/SMS-Sending.md b/docs/en/SMS-Sending.md index 75069aacbe..8d5cd8da1e 100644 --- a/docs/en/SMS-Sending.md +++ b/docs/en/SMS-Sending.md @@ -1,3 +1,97 @@ -# Emailing +# SMS Sending -TODO! \ No newline at end of file +The ABP Framework provides an abstraction to sending SMS. Having such an abstraction has some benefits; + +- You can **easily integrate** to your favorite SMS sender with a few lines of configuration. +- You can then **easily change** your SMS sender without changing your application code. +- If you want to create **reusable application modules**, you don't need to make assumption about how the SMS are sent. + +## Installation + +It is suggested to use the [ABP CLI](CLI.md) to install this package. + +### Using the ABP CLI + +Open a command line window in the folder of the project (.csproj file) and type the following command: + +```bash +abp add-package Volo.Abp.Sms +``` + +### Manual Installation + +If you want to manually install; + +1. Add the [Volo.Abp.Sms](https://www.nuget.org/packages/Volo.Abp.Sms) NuGet package to your project: + +``` +Install-Package Volo.Abp.Sms +``` + +2. Add the `AbpSmsModule` to the dependency list of your module: + +```csharp +[DependsOn( + //...other dependencies + typeof(AbpSmsModule) //Add the new module dependency + )] +public class YourModule : AbpModule +{ +} +``` + +## Sending SMS + +[Inject](Dependency-Injection.md) the `ISmsSender` into any service and use the `SendAsync` method to send a SMS. + +**Example** + +```csharp +using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; +using Volo.Abp.Sms; + +namespace MyProject +{ + public class MyService : ITransientDependency + { + private readonly ISmsSender _smsSender; + + public MyService(ISmsSender smsSender) + { + _smsSender = smsSender; + } + + public async Task DoItAsync() + { + await _smsSender.SendAsync( + "+012345678901", // target phone number + "This is test sms..." // SMS text + ); + } + } +} +``` + +The given `SendAsync` method in the example is an extension method to send sms with primitive paremeters, it basicly creates `SmsMessage` object and pass it. You can also use the default `SendAsync` method which requires `SmsMessage` object. + +> `IEmailSender` is the suggested way to send emails, since it makes your code provider independent. + +## SmsMessage + +In addition to use primitive parameters, you can pass a `SmsMessage` object to the `SendAsync` method. + +- `PhoneNumber` (string): Target phone number to send sms. +- `Text` (string): SMS Text +- `Properties` (Dictionary): string key-value pair to handle different usages by senders. + +## NullSmsSender + +`NullSmsSender` is a built-in class that implements the `ISmsSender`, but writes sms contents to the [standard log system](Logging.md), rathen than actually sending the SMSs. + +This class can be useful especially in development time where you generally don't want to send real sms. +`NullSmsSender` will try to register itself automatically if there is no other registrated sms sender. + +## See also + +- [Twilio SMS Sender](https://docs.abp.io/en/commercial/latest/modules/twilio-sms) with [ABP Commercial](https://commercial.abp.io/). From e6c88b6eafb6eb9f566dfd88323c422d692ccafd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ahmet=20=C3=87otur?= Date: Thu, 8 Apr 2021 10:28:06 +0300 Subject: [PATCH 2/4] Update docs/en/SMS-Sending.md Co-authored-by: Qingxiao Ren --- docs/en/SMS-Sending.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/en/SMS-Sending.md b/docs/en/SMS-Sending.md index 8d5cd8da1e..9ee5b06d00 100644 --- a/docs/en/SMS-Sending.md +++ b/docs/en/SMS-Sending.md @@ -75,7 +75,7 @@ namespace MyProject The given `SendAsync` method in the example is an extension method to send sms with primitive paremeters, it basicly creates `SmsMessage` object and pass it. You can also use the default `SendAsync` method which requires `SmsMessage` object. -> `IEmailSender` is the suggested way to send emails, since it makes your code provider independent. +> `ISmsSender` is the suggested way to send SMS, since it makes your code provider independent. ## SmsMessage From 5e328bb9d2020d02157a316b5b878492c220bff1 Mon Sep 17 00:00:00 2001 From: Ahmet Date: Thu, 8 Apr 2021 11:07:27 +0300 Subject: [PATCH 3/4] Update SMS-Sending.md --- docs/en/SMS-Sending.md | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/docs/en/SMS-Sending.md b/docs/en/SMS-Sending.md index 9ee5b06d00..7662a8a465 100644 --- a/docs/en/SMS-Sending.md +++ b/docs/en/SMS-Sending.md @@ -92,6 +92,30 @@ In addition to use primitive parameters, you can pass a `SmsMessage` object to t This class can be useful especially in development time where you generally don't want to send real sms. `NullSmsSender` will try to register itself automatically if there is no other registrated sms sender. +## Creating a custom SMS sender + +You can easily create your custom provider by creating a class that implements the `ISmsSender` interface. + +```csharp +using System.IO; +using System.Threading.Tasks; +using Volo.Abp.Sms; +using Volo.Abp.DependencyInjection; + +namespace AbpDemo +{ + public class MyCustomSmsSender : ISmsSender, ITransientDependency + { + public async Task SendAsync(SmsMessage smsMessage) + { + // Send sms + } + } +} +``` + +That's all. Now you can send SMS by using `MyCustomSmsSender` in your application. + ## See also - [Twilio SMS Sender](https://docs.abp.io/en/commercial/latest/modules/twilio-sms) with [ABP Commercial](https://commercial.abp.io/). From f71a9a9d8ee2e58ee8dcc4a05e381a9b66197fc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 8 Apr 2021 14:05:39 +0300 Subject: [PATCH 4/4] SMS Sender document revised. --- docs/en/SMS-Sending.md | 34 ++++++++++++---------------------- docs/en/docs-nav.json | 4 ++++ 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/docs/en/SMS-Sending.md b/docs/en/SMS-Sending.md index 7662a8a465..99d06fa903 100644 --- a/docs/en/SMS-Sending.md +++ b/docs/en/SMS-Sending.md @@ -2,7 +2,6 @@ The ABP Framework provides an abstraction to sending SMS. Having such an abstraction has some benefits; -- You can **easily integrate** to your favorite SMS sender with a few lines of configuration. - You can then **easily change** your SMS sender without changing your application code. - If you want to create **reusable application modules**, you don't need to make assumption about how the SMS are sent. @@ -44,7 +43,7 @@ public class YourModule : AbpModule [Inject](Dependency-Injection.md) the `ISmsSender` into any service and use the `SendAsync` method to send a SMS. -**Example** +**Example:** ```csharp using System.Threading.Tasks; @@ -66,35 +65,28 @@ namespace MyProject { await _smsSender.SendAsync( "+012345678901", // target phone number - "This is test sms..." // SMS text + "This is test sms..." // message text ); } } } ``` -The given `SendAsync` method in the example is an extension method to send sms with primitive paremeters, it basicly creates `SmsMessage` object and pass it. You can also use the default `SendAsync` method which requires `SmsMessage` object. +The given `SendAsync` method in the example is an extension method to send an SMS with primitive parameters. In addition, you can pass an `SmsMessage` object which has the following properties: -> `ISmsSender` is the suggested way to send SMS, since it makes your code provider independent. - -## SmsMessage - -In addition to use primitive parameters, you can pass a `SmsMessage` object to the `SendAsync` method. - -- `PhoneNumber` (string): Target phone number to send sms. -- `Text` (string): SMS Text -- `Properties` (Dictionary): string key-value pair to handle different usages by senders. +- `PhoneNumber` (`string`): Target phone number +- `Text` (`string`): Message text +- `Properties` (`Dictionary`): Key-value pairs to pass custom arguments ## NullSmsSender -`NullSmsSender` is a built-in class that implements the `ISmsSender`, but writes sms contents to the [standard log system](Logging.md), rathen than actually sending the SMSs. +`NullSmsSender` is a the default implementation of the `ISmsSender`. It writes SMS content to the [standard logler](Logging.md), rather than actually sending the SMS. -This class can be useful especially in development time where you generally don't want to send real sms. -`NullSmsSender` will try to register itself automatically if there is no other registrated sms sender. +This class can be useful especially in development time where you generally don't want to send real SMS. **However, if you want to actually send SMS, you should implement the `IsSmsSender` in your application code.** -## Creating a custom SMS sender +## Implementing the ISmsSender -You can easily create your custom provider by creating a class that implements the `ISmsSender` interface. +You can easily create your SMS sending implementation by creating a class that implements the `ISmsSender` interface, as shown below: ```csharp using System.IO; @@ -114,8 +106,6 @@ namespace AbpDemo } ``` -That's all. Now you can send SMS by using `MyCustomSmsSender` in your application. - -## See also +## More -- [Twilio SMS Sender](https://docs.abp.io/en/commercial/latest/modules/twilio-sms) with [ABP Commercial](https://commercial.abp.io/). +[ABP Commercial](https://commercial.abp.io/) provides Twilio integration package to send SMS over [Twilio service](https://docs.abp.io/en/commercial/latest/modules/twilio-sms). \ No newline at end of file diff --git a/docs/en/docs-nav.json b/docs/en/docs-nav.json index 32e62eccbe..5e0f0b469a 100644 --- a/docs/en/docs-nav.json +++ b/docs/en/docs-nav.json @@ -285,6 +285,10 @@ } ] }, + { + "text": "SMS Sending", + "path": "SMS-Sending.md" + }, { "text": "Event Bus", "items": [