Set Appmate Events
User events are tracked by Appmate BE for specific features and purposes. This capability is already available in the Android SDK. It is critical that the logic stay the same for every SDK platform.
#
UserEventTypeEvent Type | Trigger Case |
---|---|
FIRST_LAUNCH | Every time the app is launched.This type should be triggered automatically every time the app is launced. 1 |
VIEW | This event should be sent when the product is displayed. Manually via code implementation by the developer. 2 |
PURCHASE | This event should be sent when the product is purchased successfully. Manually via code implementation by the developer. 3 |
- All events should be available for trigger via saveAppUserEvents (Check name from Android project) method.
#
Setting Up AppMate Events#
RequestParameter Name | Type |
---|---|
appmateEvent | AppmateEvent (productId, userEvent ) |
listener | ReceivedDataListener<Boolean, GenericError> |
#
ResponseParameter Name | Type |
---|---|
onSucceeded | Boolean |
onFailed | GenericError |
- Kotlin
- Java
import com.huawei.appmate.model.AppmateEvent;import com.huawei.appmate.model.UserEventType;
String productId = "TestProduct";UserEventType userEvent = *userEventType*;
PurchaseClient.getInstance().setAppmateEvent(new AppmateEvent(productId, userEvent), new ReceivedDataListener<Boolean, GenericError>() { @Override public void onSucceeded(Boolean data) { }
@Override public void onError(GenericError error) { }});
import com.huawei.appmate.model.UserEventTypeimport com.huawei.appmate.model.AppmateEvent
val userEvent: UserEventType = *userEventType*val productId: String = "TestProduct"
PurchaseClient.instance.setAppmateEvent(AppmateEvent(productId, userEvent),object : ReceivedDataListener<Boolean, GenericError> { override fun onSucceeded(data: Boolean) { }
override fun onError(error: GenericError) { }})
#
View ProductThe setAppmateEvent api should be called just before the purchase api is called.
note
This event must be sent for A/B Testing.
- Kotlin
- Java
import com.huawei.appmate.model.AppmateEvent;import com.huawei.appmate.model.UserEventType;
//Call setAppmateEvent
String productId = "TestProduct";UserEventType userEvent = UserEventType.VIEW;
PurchaseClient.getInstance().setAppmateEvent(new AppmateEvent(productId, userEvent), new ReceivedDataListener<Boolean, GenericError>() { @Override public void onSucceeded(Boolean data) { }
@Override public void onError(GenericError error) { }});
//Call purchase api
PurchaseClient.getInstance().purchase(this,purchaseRequest,new PurchaseResultListener<PurchaseResultInfo, GenericError>() { @Override public void onSuccess(PurchaseResultInfo purchaseResultInfo) { }
@Override public void onError(GenericError genericError) { }
@Override public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, @NonNull List<Purchase> list) { }});
import com.huawei.appmate.model.UserEventTypeimport com.huawei.appmate.model.AppmateEvent
//Call setAppmateEvent
val userEvent: UserEventType = UserEventType.VIEWval productId: String = "TestProduct"
PurchaseClient.instance.setAppmateEvent(AppmateEvent(productId, userEvent),object : ReceivedDataListener<Boolean, GenericError> { override fun onSucceeded(data: Boolean) { }
override fun onError(error: GenericError) { }})
//Call purchase api
PurchaseClient.instance.purchase(this,purchaseRequest,object : PurchaseResultListener<PurchaseResultInfo, GenericError> { override fun onSuccess(data: PurchaseResultInfo) { }
override fun onError(error: GenericError) { }
override fun onQueryPurchasesResponse( p0: BillingResult, p1: MutableList<Purchase> ) { }})
#
Purchase ProductThe setAppmateEvent api should be called after success returns from the purchase api.
note
This event must be sent for A/B Testing.
- Kotlin
- Java
import com.huawei.appmate.model.AppmateEvent;import com.huawei.appmate.model.UserEventType;
//Call purchase api
PurchaseClient.getInstance().purchase(this,purchaseRequest,new PurchaseResultListener<PurchaseResultInfo, GenericError>() { @Override public void onSuccess(PurchaseResultInfo purchaseResultInfo) {
//Call setAppmateEvent
String productId = "TestProduct"; UserEventType userEvent = UserEventType.PURCHASE;
PurchaseClient.getInstance().setAppmateEvent(new AppmateEvent(productId, userEvent), new ReceivedDataListener<Boolean, GenericError>() { @Override public void onSucceeded(Boolean data) { }
@Override public void onError(GenericError error) { } });
}
@Override public void onError(GenericError genericError) { }
@Override public void onQueryPurchasesResponse(@NonNull BillingResult billingResult, @NonNull List<Purchase> list) { }});
import com.huawei.appmate.model.UserEventTypeimport com.huawei.appmate.model.AppmateEvent
//Call purchase api
PurchaseClient.instance.purchase(this,purchaseRequest,object : PurchaseResultListener<PurchaseResultInfo, GenericError> { override fun onSuccess(data: PurchaseResultInfo) {
//Call setAppmateEvent
val userEvent: UserEventType = UserEventType.PURCHASE val productId: String = "TestProduct"
PurchaseClient.instance.setAppmateEvent( AppmateEvent(productId, userEvent), object : ReceivedDataListener<Boolean, GenericError> { override fun onSucceeded(data: Boolean) { }
override fun onError(error: GenericError) { } })
}
override fun onError(error: GenericError) { }
override fun onQueryPurchasesResponse( p0: BillingResult, p1: MutableList<Purchase>) { }})