The custom event is used to create tailored notifications between the eCommerce and Connectif. It sends, via the Mobile SDK, events for Custom Integration to Receive Data in Connectif using the functions Connectif.sendCustomEventById() and Connectif.sendCustomEventByAlias(), depending on whether we want to identify the events by alias or id.
How to Use
The custom integration event notification is made by setting the field type to the literal value "custom" and identifying the event using the eventAlias parameter (unique in your Store). The CustomEvent parameter will contain, if applicable, the fields of the integration event.
To build the CustomEvent parameter, we can use the classes that inherit from CustomEventValue, which correspond to the field types that can be created in Custom Events from the Connectif Dashboard.
CustomEventValue.Text
CustomEventValue.Phone
CustomEventValue.Email
CustomEventValue.Integer
CustomEventValue.Decimal
CustomEventValue.DateTime
CustomEventValue.Boolean
CustomEventValue.MultipleChoice
CustomEventValue.SingleOption
This type of event automatically collects the following information:
- Operating system: Android or iOS.
- App version.
- Operating system version.
- Connectif SDK version.
Example Using Event Alias
Given a custom integration to receive data, which is sent when a contact gives a Like to a product, which includes the fields email and productId.
The notification will look like this using CustomEventValue:
Connectif.sendCustomEventByAlias("product-like", CustomEvent( mapOf( "email" to CustomEventValue.Email("test@example.org"), "product-id" to CustomEventValue.Text("1234") ) ) )
We can opt to send the event fields as an anonymous object as follows:
Connectif.sendCustomEventByAlias("product-like", object { val `email` = "test@example.org" val `product-id` = "1234" } )
Example Using Event ID
As an alternative to using the alias, it is possible to identify the event by its eventId. The example below shows how to do this (also compatible with sending fields as an anonymous object):
Connectif.sendCustomEventById("635feb9a4168beeaf0ae6a46", CustomEvent( mapOf( "email" to CustomEventValue.Email("test@example.org"), "product-id" to CustomEventValue.Text("1234") ) ) )
Callbacks (Optional)
If you want feedback on potential errors when sending events, you can add an EventCallbacks when using our method.
object : EventCallbacks { override fun onSuccess() { //Handle success } override fun onError(message: String?) { //Handle error } }
Keep learning!
To fully leverage the potential of your Connectif account, we recommend continuing with the following articles:
- Android SDK Get Started, to add Connectif Mobile SDK to your Android project.
- Firebase Cloud Messaging Configuration, to enable push sending and receiving via the Android Mobile SDK.
- iOS SDK Get Started, to add Connectif Mobile SDK to your iOS project.
- Apple Push Notifications Service Configuration, to enable push sending and receiving via the iOS Mobile SDK.