Sparc.Notifications.Twilio
7.0.0
See the version list below for details.
dotnet add package Sparc.Notifications.Twilio --version 7.0.0
NuGet\Install-Package Sparc.Notifications.Twilio -Version 7.0.0
<PackageReference Include="Sparc.Notifications.Twilio" Version="7.0.0" />
paket add Sparc.Notifications.Twilio --version 7.0.0
#r "nuget: Sparc.Notifications.Twilio, 7.0.0"
// Install Sparc.Notifications.Twilio as a Cake Addin #addin nuget:?package=Sparc.Notifications.Twilio&version=7.0.0 // Install Sparc.Notifications.Twilio as a Cake Tool #tool nuget:?package=Sparc.Notifications.Twilio&version=7.0.0
Sparc.Notifications.Twilio
The Sparc.Notifications.Twilio
plugin is a plugin that enables low-configuration email and SMS notifications in your application, using Twilio as the provider.
Get Started with Sparc.Notifications.Twilio
In Your Features Project:
Add the following settings to your
appsettings.json
file:{ "Twilio": { "AccountSid": "", // the SID from your Twilio account "AuthToken": "", // the secret Auth Token from your Twilio account (preferably store this in usersecrets.json) "FromPhoneNumber": "+1555121212", // the configured Twilio Phone Number to send SMSs "FromEmailAddress": "info@myapp.com", // the email address all emails will come from "FromName": "My App", // the From name for all outbound emails "SendGridApiKey": "", // the SendGrid API key from your Twilio / Sendgrid account }
Add the following line of code to your
Startup.cs
file to register theSparc.Notifications.Twilio
plugin. It will automatically read the configuration from theTwilio
section of yourappsettings.json
file.services.AddTwilio(Configuration);
Inject
TwilioService
into any feature that needs to send emails or SMS messages. For example:public class SendRegistrationNotification : Feature<bool> { IRepository<User> Users { get; set; } TwilioService Twilio { get; set; } public SendRegistrationNotification(IRepository<User> users, TwilioService twilio) { Users = users; Twilio = twilio; } public override async Task<bool> ExecuteAsync() { var user = await Users.FindAsync(User.Id()); var message = "You have successfully registered!"; if (user.PhoneNumber != null) await Twilio.SendSmsAsync(user.PhoneNumber, message); else await Twilio.SendEmailAsync(user.Email, message); // or simply call Twilio.SendAsync and pass in either an email or phone number, and the plugin will send an SMS or email accordingly await Twilio.SendAsync(user.PhoneNumber ?? user.Email, message); return true; } }
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net7.0
- Microsoft.Extensions.Configuration.Binder (>= 7.0.0)
- Microsoft.Extensions.DependencyInjection.Abstractions (>= 7.0.0)
- SendGrid (>= 9.28.1)
- SendGrid.Extensions.DependencyInjection (>= 1.0.1)
- Twilio (>= 6.0.0-rc.2)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.