Knock.net
0.1.12
.NET Standard 2.0
This package targets .NET Standard 2.0. The package is compatible with this framework or higher.
.NET Framework 4.6.1
This package targets .NET Framework 4.6.1. The package is compatible with this framework or higher.
dotnet add package Knock.net --version 0.1.12
NuGet\Install-Package Knock.net -Version 0.1.12
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="Knock.net" Version="0.1.12" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Knock.net --version 0.1.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Knock.net, 0.1.12"
#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 Knock.net as a Cake Addin
#addin nuget:?package=Knock.net&version=0.1.12
// Install Knock.net as a Cake Tool
#tool nuget:?package=Knock.net&version=0.1.12
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Knock .NET Library
Knock API access for applications using .NET. Supports .NET Standard 2.0+ and .NET Framework 4.6.1+.
Documentation
See the API documentation for usage examples.
Installation
There are several options to install the Knock .NET SDK.
Via the NuGet Package Manager
nuget install Knock.net
Via the .NET Core Command Line Tools
dotnet add package Knock.net
Via Visual Studio IDE
Install-Package Knock.net
Configuration
To use the Knock client, you must provide an API key from the Knock dashboard.
using Knock;
var knockClient = new KnockClient(
new KnockOptions { ApiKey = "sk_12345" });
Usage
Identifying users
var knockClient = new KnockClient(
new KnockOptions { ApiKey = "sk_12345" });
var identifyUserParams = new Dictionary<string, object>{
{ "name", "John Hammond" },
{ "email", "jhammond@ingen.net" }
};
var user = await knockClient.Users.Identify("jhammond", identifyUserParams)
Retrieving users
var knockClient = new KnockClient(
new KnockOptions { ApiKey = "sk_12345" });
var user = await knockClient.Users.Get("jhammond")
Triggering workflows
var knockClient = new KnockClient(
new KnockOptions { ApiKey = "sk_12345" });
var workflowTrigger = new TriggerWorkflow {
// list of user ids for who should receive the notif
Recipients = ["jhammond", "agrant", "imalcolm", "esattler"],
// user id of who performed the action
Actor: "dnedry",
// an optional cancellation key
CancellationKey: alert.Id,
// an optional tenant
Tenant: "jurassic-park",
// data payload to send through
Data: new Dictionary<string, object>{
{"type", "trex"},
{"priority", "1"}
},
};
var result = await knockClient.Workflows.Trigger("dinosaurs-loose", workflowTrigger)
Preferences
var knockClient = new KnockClient(
new KnockOptions { ApiKey = "sk_12345" });
// Set preference set for user
var preferenceSetUpdate = new SetPreferenceSet {
ChannelTypes = new Dictionary<string, boolean> {
{"email", false}
}
};
var result = await knockClient.Users.SetPreferences("jhammond", preferenceSetUpdate);
// Set granular channel type preferences
var result = await knockClient.Users.SetChannelTypePreferences("jhammond", "email", true);
// Set granular workflow preferences
var result = await knockClient.Users.SetWorkflowPreferences("jhammond", "dinosaurs-loose", false);
// Retrieve preferences
var preferenceSet = await knockClient.Users.GetPreferences("jhammond");
Getting and setting channel data
var knockClient = new KnockClient(
new KnockOptions { ApiKey = "sk_12345" });
// Set channel data for an APNS channel
var channelData = new Dictionary<string, List<string>>{
{"tokens", [apnsToken]},
};
var result = await knockClient.Users.SetChannelData("jhammond", knockApnsChannelId, channelData);
// Get channel data for the APNS channel
var result = await knockClient.Users.GetChannelData("jhammond", knockApnsChannelId);
Canceling notifies
var knockClient = new KnockClient(
new KnockOptions { ApiKey = "sk_12345" });
var cancelParams = new CancelWorkflow {
// Optional list of recipients to cancel the workflow run for
Recipients = ["dnedry"],
// The cancellation key that corresponds with the original workflow run
CancellationKey = alert.id,
};
var result = await knockClient.Workflows.cancel("dinosaurs-loose", cancelParams);
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. 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. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 is compatible. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
.NETFramework 4.6.1
- Microsoft.Bcl.AsyncInterfaces (>= 1.1.0)
- Newtonsoft.Json (>= 12.0.3)
- System.Runtime.InteropServices.RuntimeInformation (>= 4.3.0)
-
.NETStandard 2.0
- Microsoft.Bcl.AsyncInterfaces (>= 1.1.0)
- Newtonsoft.Json (>= 12.0.3)
- System.Configuration.ConfigurationManager (>= 4.5.0)
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 |
---|---|---|
0.1.12 | 10,402 | 6/7/2023 |
0.1.11 | 3,809 | 5/24/2023 |
0.1.10 | 146 | 5/10/2023 |
0.1.9 | 167 | 4/10/2023 |
0.1.8 | 407 | 1/18/2023 |
0.1.7 | 4,241 | 7/18/2022 |
0.1.6 | 374 | 6/29/2022 |
0.1.5 | 376 | 5/10/2022 |
0.1.4 | 383 | 4/19/2022 |
0.1.3 | 646 | 2/10/2022 |
0.1.2 | 409 | 1/21/2022 |
0.1.1 | 469 | 1/11/2022 |
0.1.0 | 6,151 | 11/24/2021 |