Skip to main content

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.

UserEventType#

Event TypeTrigger Case
FIRST_LAUNCHEvery time the app is launched.This type should be triggered automatically every time the app is launced. 1
VIEWThis event should be sent when the product is displayed. Manually via code implementation by the developer. 2
PURCHASEThis 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#

Request#

Parameter NameType
appmateEventAppmateEvent (productId, userEvent )
listenerReceivedDataListener<Boolean, GenericError>

Response#

Parameter NameType
onSucceededBoolean
onFailedGenericError
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 Product#

The setAppmateEvent api should be called just before the purchase api is called.

note

This event must be sent for A/B Testing.

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 Product#

The setAppmateEvent api should be called after success returns from the purchase api.

note

This event must be sent for A/B Testing.

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>) {    }})