Eventos in-app
Resumen General
Los eventos in-app brindan insights sobre lo que está sucediendo en tu aplicación. Se recomienda tomarse el tiempo y definir los eventos que deseas medir para que puedas medir el ROI (Retorno de la inversión) y el LTV (Valor de vida útil).
El registro de los eventos in-app se realiza llamando a sendEvent
con los parámetros de nombre y valor del evento. Consulta la documentación sobre eventos in-app para conocer más detalles.
Encuentra más información sobre el registro de eventos aquí.
Evento de envío
void sendEvent(string eventName, Dictionary<string, string> eventValues)
parameter | type | description |
---|---|---|
eventName | string | El nombre del evento |
eventValues | Dictionary<string, string> | Los valores del evento que se envían con el evento |
Ejemplo:
Dictionary<string, string> eventValues = new Dictionary<string, string>();
eventValues.Add(AFInAppEvents.CURRENCY, "USD");
eventValues.Add(AFInAppEvents.REVENUE, "0.99");
eventValues.Add("af_quantity", "1");
AppsFlyer.sendEvent(AFInAppEvents.PURCHASE, eventValues);
Nota
No agregues símbolos de divisa al valor de los ingresos.
Validación de compras in-app
Para la validación de recibos de compras in-app, sigue las instrucciones según tu sistema operativo.
Notas
Una llamada a validateReceipt genera automáticamente un evento in-app af_purchase
, por lo que no es necesario que envíes este evento tú mismo.
La respuesta de validación de compra se activa en la clase AppsFlyerTrackerCallbacks.cs
class.
void validateAndSendInAppPurchase(string productIdentifier, string price, string currency, string tranactionId, Dictionary<string, string> additionalParameters, MonoBehaviour gameObject)
//To get the callbacks
//AppsFlyer.createValidateInAppListener ("AppsFlyerTrackerCallbacks", "onInAppBillingSuccess", "onInAppBillingFailure");
AppsFlyer.validateReceipt(string publicKey, string purchaseData, string signature, string price, string currency, Dictionary additionalParametes);
using UnityEngine.Purchasing;
using AppsFlyerSDK;
public class AppsFlyerObject : MonoBehaviour, IStoreListener, IAppsFlyerValidateReceipt
{
public static string kProductIDConsumable = "com.test.cons";
void Start()
{
AppsFlyer.initSDK("devKey", "devKey");
AppsFlyer.startSDK();
}
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
string prodID = args.purchasedProduct.definition.id;
string price = args.purchasedProduct.metadata.localizedPrice.ToString();
string currency = args.purchasedProduct.metadata.isoCurrencyCode;
string receipt = args.purchasedProduct.receipt;
var recptToJSON = (Dictionary<string, object>)AFMiniJSON.Json.Deserialize(product.receipt);
var receiptPayload = (Dictionary<string, object>)AFMiniJSON.Json.Deserialize((string)recptToJSON["Payload"]);
var transactionID = product.transactionID;
if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable, StringComparison.Ordinal))
{
#if UNITY_IOS
if(isSandbox)
{
AppsFlyeriOS.setUseReceiptValidationSandbox(true);
}
AppsFlyeriOS.validateAndSendInAppPurchase(prodID, price, currency, transactionID, null, this);
#elif UNITY_ANDROID
var purchaseData = (string)receiptPayload["json"];
var signature = (string)receiptPayload["signature"];
AppsFlyerAndroid.validateAndSendInAppPurchase(
"<google_public_key>",
signature,
purchaseData,
price,
currency,
null,
this);
#endif
}
return PurchaseProcessingResult.Complete;
}
public void didFinishValidateReceipt(string result)
{
AppsFlyer.AFLog("didFinishValidateReceipt", result);
}
public void didFinishValidateReceiptWithError(string error)
{
AppsFlyer.AFLog("didFinishValidateReceiptWithError", error);
}
}
Actualizado hace 5 meses