This is a .NET6 library for interacting with the LINE Notify Api.
dotnet add package Line.Notify.Api.Client
{
"Line": {
"Notify": {
"BaseUrl": "https://notify-api.line.me",
"AuthToken": "YOUR_LINE_AUTH_TOKEN"
}
}
}
using Line.Notify.Api.Client.Extensions;
ConfigureServices(IServiceCollection services, IConfiguration configuration)
{
// this injects as SINGLETON
services.AddLineNotifyApiServices(configuration);
// you can also inject as SCOPED or TRANSIENT by specifying the ServiceLifetime
services.AddLineNotifyApiServices(configuration, ServiceLifetime.Scoped);
}
using Line.Notify.Api.Client.Interfaces;
using Line.Notify.Api.Client.Services;
using Line.Notify.Api.Client.Models.Requests;
public class MyProcess
{
private readonly INotifyService _notifyService;
public MyProcess(INotifyService notifyService) =>
_notifyService = notifyService;
public async Task NotifyAsync()
{
// use the default token from appsettings.json
var result = await _notifyService.NotifyAsync(new MessageModel
{
Message = "Test message"
});
// or pass in another token so you can send notification to multiple LINE account at the same time
var dynamicTokenResult = await _notifyService.NotifyAsync(
new MessageModel
{
Message = "Test message"
},
"MyAuthToken");
}
}