DocumentazioneGuida per gli sviluppatori di Target

Richieste asincrone (.NET)

Ultimo aggiornamento: 20 luglio 2024
  • Argomenti:
  • APIs/SDKs

Creato per:

  • Sviluppatore

Descrizione

Uno dei vantaggi dell'integrazione lato server è la possibilità di sfruttare l'enorme larghezza di banda e le risorse informatiche disponibili sul lato server utilizzando il parallelismo. Target .NET SDK supporta le richieste asincrone, semplificando l'integrazione di Target nel flusso di lavoro asincrono esistente dell'app.

Metodi supportati

.NET

Task<TargetDeliveryResponse> GetOffersAsync(TargetDeliveryRequest request);
Task<TargetDeliveryResponse> SendNotificationsAsync(TargetDeliveryRequest request);
Task<TargetAttributes> GetAttributesAsync(TargetDeliveryRequest request, params string[] mboxes);

Esempio

Di seguito è riportato un esempio di utilizzo asincrono dell’API SDK:

.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);

Questo esempio presuppone che tu abbia inizializzato l'SDK.

recommendation-more-help
6906415f-169c-422b-89d3-7118e147c4e3