iOS Mobile SDK: Notify Custom Event

The custom event allows creating tailored notifications between the eCommerce and Connectif. It notifies, via the Mobile SDK, events of Custom Integration for receiving 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 it

The custom integration event notification is made by setting the type field to the literal value "custom" and identifying the event using the eventAlias parameter (unique to your Store). In the CustomEvent parameter, if applicable, you will find 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

 

Example using event alias

Given a custom integration for receiving data, which is sent when a contact gives a Like to a product, including the fields email and productId.

The notification will look like this using CustomEventValue:

Connectif.sendCustomEventByAlias("product-like", CustomEvent(values: [
    "email": .email("test@example.org"),
    "product-id": .text("+123456789")
  ]))

 

Example using event identifier

Alternatively to using the alias, it is possible to identify the event by its eventId. The following example shows how to use this method (also compatible with sending fields as an anonymous object):

Connectif.sendCustomEventById("635feb9a4168beeaf0ae6a46", CustomEvent(values: [
    "email": .email("test@example.org"),
    "product-id": .text("+123456789")
  ]))

 

Callbacks (Opcional)

Si queremos tener feedback de posibles errores al enviar eventos, podremos añadir un EventCallbacks cuando usemos nuestro método.

EventCallbacks(
    onSuccess: {
        // Manejo en caso de éxito
    },
    onError: { error in
        // Manejo en caso de error
    })
 

Congratulations!
You've reached the end of the lesson.

 

Do you still have unresolved questions?
Remember that our Connectif specialists are available to assist you. To contact them, simply open a support ticket by clicking on the blue "Help" button in your dashboard.


Keep Learning!

To fully unlock the potential of your Connectif account, we recommend continuing with the following articles:

Was this article helpful?
0 out of 0 found this helpful