Asynchronous Requests (.NET)
Description
One benefit of server-side integration is that one can leverage the huge bandwidth and computing resources available on the server-side by using parallelism. Target .NET SDK supports asynchronous requests, making it easy to integrate Target into an app’s existing async workflow.
Supported Methods
.NET
Task<TargetDeliveryResponse> GetOffersAsync(TargetDeliveryRequest request);
Task<TargetDeliveryResponse> SendNotificationsAsync(TargetDeliveryRequest request);
Task<TargetAttributes> GetAttributesAsync(TargetDeliveryRequest request, params string[] mboxes);
Example
A sample async SDK API usage could appear as follows:
.NET
var deliveryRequest = new TargetDeliveryRequest.Builder()
.SetExecute(new ExecuteRequest(mboxes: new List<MboxRequest> { new MboxRequest(index: 1, name: "a1-serverside-ab") }))
.Build();
var response = await this.targetClient.GetOffersAsync(deliveryRequest);
var notificationRequest = new TargetDeliveryRequest.Builder()
.SetSessionId(response.Request.SessionId)
.SetTntId(response.Response?.Id?.TntId)
.SetNotifications(new List<Notification>
{
new (id: "1", type: MetricType.Display, timestamp: DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
mbox: new NotificationMbox("product1", "J+W1Fq18hxliDDJonTPfV0S+mzxapAO3d14M43EsM9f12A6QaqL+E3XKkRFlmq9U"),
tokens: new List<string> { "t0FRvoWosOqHmYL5G18QCZNWHtnQtQrJfmRrQugEa2qCnQ9Y9OaLL2gsdrWQTvE54PwSz67rmXWmSnkXpSSS2Q==" })
})
.Build();
var notificationResponse = await this.targetClient.SendNotificationsAsync(notificationRequest);
This example assumes you have initialized the SDK.
recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3