Sparc.Notifications.Twilio 7.0.2

dotnet add package Sparc.Notifications.Twilio --version 7.0.2
NuGet\Install-Package Sparc.Notifications.Twilio -Version 7.0.2
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sparc.Notifications.Twilio" Version="7.0.2" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Sparc.Notifications.Twilio --version 7.0.2
#r "nuget: Sparc.Notifications.Twilio, 7.0.2"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install Sparc.Notifications.Twilio as a Cake Addin
#addin nuget:?package=Sparc.Notifications.Twilio&version=7.0.2

// Install Sparc.Notifications.Twilio as a Cake Tool
#tool nuget:?package=Sparc.Notifications.Twilio&version=7.0.2

Sparc.Notifications.Twilio

Nuget

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:

  1. Add the Sparc.Notifications.Twilio Nuget package: Nuget

  2. 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
    }
    
  3. Add the following line of code to your Startup.cs file to register the Sparc.Notifications.Twilio plugin. It will automatically read the configuration from the Twilio section of your appsettings.json file.

    services.AddTwilio(Configuration);
    
  4. 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
7.0.2 397 11/9/2022
7.0.0 105 11/7/2022
6.1.0 629 3/2/2022
6.0.0 336 11/19/2021
2.0.4 362 9/2/2021
2.0.3 356 7/21/2021
2.0.2 333 7/21/2021
2.0.1 320 7/21/2021
2.0.0 307 7/21/2021