List of methods available in the API
Method | Parameters | Description |
---|---|---|
startSession | (Object configuration) | Initialization EMMA SDK |
startPush | (Object pushOptions) | Register the app to receive push notifications |
trackLocation | - | Start tracking location |
trackEvent | (Object eventRequest) | Event tracking |
trackUserExtraInfo
|
(Object extras) | Sending tags (key-value) associated with the user |
loginUser | (Object loginRequest) | Track login event |
registerUser | (Object registerRequest) | Track register event |
startOrder | (Object order) | Start a order |
addProduct | (Object product) | Add products to purchase |
trackOrder | - | Send the purchase added in startOrder with the products added with addProduct |
cancelOrder | (String orderId) | Cancel the order added in startOrder with specific orderId |
inAppMessage | (Object messageRequest) | Check if in-app communications are available |
enableUserTracking
|
- | Enable the data record referring to the user |
disableUserTracking
|
(Boolean deleteUser) | Disable the record of data referring to the user |
isUserTrackingEnabled
|
- | Returns if the user's data record is active or not |
getSyncDeviceId
|
- | returns device Id or null |
startSession(configuration): void
Initialization EMMA SDK.
Parameter | Type | Description |
---|---|---|
configuration | Object | SDK configuration |
configuration
Name | Type | Default | Description |
---|---|---|---|
sessionkey | string | There is no default, it is mandatory | Session Key of the app in EMMA |
debug | boolean | false | Debug enable or disable |
queueTime | int | 10 | Interval between requests in the request queue (It is not recommended to touch this value) |
trackScreenEvents
|
boolean | true | Enable or disable track screen events |
powlinkDomains | Array<string> | ["powlink.io"] | Add powlink custom domains (Only applies to apps with EMMA on-premise) |
customShortPowlinkDomains
|
Array<string> | ["pwlnk.io"] | Add STU domains for short powlink (Only applies to apps with EMMA on-premise) |
apiUrl | string | "https://api.emma.io" | Add url to API (Only applies to clients that have a proxy configured) |
startPush(options): void
Register Push for the app. When this method is invoked, a push token is obtained and sent to EMMA.
Parameter | Type | Description |
---|---|---|
options | Object | This parameter is only used for push settings on Android. In iOS the configuration goes by default, it will be ignored. |
options
Name | Type | Default | Description |
---|---|---|---|
classToOpen
|
string | There is no default, it is mandatory | This is a parameter inherited from the native SDK, although when use Cordova there is only one activity (MainActivity) it is necessary to pass the absolute path of this ${config_id}.MainActivity, where config_id is the id of config.xml |
iconResource
|
string | There is no default, it is mandatory | Name of the png added to the app as a notification icon |
notificationColor
|
string | - | Color for the notification background. It has to be a string with a hexadecimal value, for example#ffff" |
trackScreenEvents
|
boolean | true | Track screen events |
notificationChannelName
|
string | App name |
Name visible in settings to disable notifications Only applies to Android O |
notificationChannelId
|
string | - |
In the case of already using a channelId for another notification you can switch to EMMA to use the same Only applies to Android O |
trackLocation(): void
Track user location. Only location is sent when app is booted or user moves a long distance. It is not intrusive.
trackEvent(eventRequest): void
Track a specific event.
Parameter | Type | Description |
---|---|---|
eventRequest | Object | Request parameters |
eventRequest
Name | Type | Default | Description |
---|---|---|---|
token
|
string | There is no default, it is mandatory |
The token that references the sent event. The tokens are obtained in the EMMA dashboard. You can add aliases. |
attributes | object | - | Key-value properties to add to the event (Partially supported). |
trackUserExtraInfo(extras): void
Send tags associated to the user/device that has logged in. These tags are saved as properties to perform, for example, filters.
Parameter | Type | Description |
---|---|---|
extras | Object | Key-value properties (string - string) |
loginUser(loginRequest): void
Track a login event. Associate a user to the session.
Parameter | Type | Description |
---|---|---|
loginRequest | Object | Request parameters |
loginRequest
Name | Type | Default | Description |
---|---|---|---|
userId
|
string | There is no default, it is mandatory | User Id in client database to associate it with EMMA |
string | - | User email to associate it with EMMA | |
extras | object (key-value) | - | Associate tags to login event |
registerUser(registerRequest): void
Track a register event. Associate a user to the session.
Parameter | Type | Description |
---|---|---|
registerRequest | Object | Request Parameters |
registerRequest
Name | Type | Default | Description |
---|---|---|---|
userId
|
string | There is no default, it is mandatory | User Id in client database to associate it with EMMA |
string | - | User email to associate it with EMMA | |
extras | object (key-value) | - | Associate tags to the register event |
startOrder(order): void
Start a order
Parameter | Type | Description |
---|---|---|
order | Object | Request parameters |
order
Name | Type | Default | Description |
---|---|---|---|
orderId | string | There is no default, it is mandatory | Order Id established by the customer for order |
double | There is no default, it is mandatory | Total price associated with the order | |
customerId | string | There is no default, it is mandatory in some cases | User Id of the client's DDBB. This parameter is not necessary if you have previously identified the session with a user doing a register or login event |
currencyCode | string | EUR | Currency used in the code (ISO 4217 - code alpha) |
coupon | string | - | Discount coupon used in the purchase |
extras | object (key-value) | - | Tags associated with the order to use in filters |
addProduct(product): void
Add a product to the started order. Several products can be added to order.
Parameter | Type | Description |
---|---|---|
product | Object |
Product associated with the started order |
product
Name | Type | Default | Description |
---|---|---|---|
productId | string | There is no default, it is mandatory | Product Id of the product |
string | There is no default, it is mandatory | Name of the product | |
quantity | int | There is no default, it is mandatory | Amount of products of this order |
double | There is no default, it is mandatory | Price of each product | |
extras | object (key-value) | - | Tags associated with the product to use in filters |
trackOrder(): void
Send to EMMA the order and previously added products.
cancelOrder(orderId): void
Cancels a previously order associated with the orderId
Parameter | Type | Description |
---|---|---|
orderId | String | Id associated with the order that want to cancel |
inAppMessage(messageRequest): void
Check if there are active communications and in case there is a sample.
Parameter | Type | Description |
---|---|---|
messageRequest | Object | Request parameters |
messageRequest
Name | Type | Default | Description |
---|---|---|---|
type | string | There is no default, it is mandatory |
Type of communication to be checked. This parameter can have several types defined in the JS plugin, to use them for example: EMMA.inAppType.STARTVIEW Defined types: STARTVIEW:'startview'
ADBALL:'adball'
STRIP:'strip'
BANNER:'banner' //only Android
NATIVEAD:'nativeAd'
|
templateId | string | - | Template Id to consult for type Native Ad Only applies to this type. |
batch | boolean | false | Returns several available in-app elements. At the moment it only applies to the type Native Ad. |
inAppResponse
|
(inAppResponse) => void | - | Callback that returns inApp responses in raw JSON. At the moment it only applies to the type Native Ad |
enableUserTracking(): void
Activates the sending data referring to the user. By default it is active.
disableUserTracking(deleteUser): void
Disables the sending of data referring to the user with the possibility of deleting it permanently
Parameter | Type | Description |
---|---|---|
deleteUser | Boolean | Borrar el usuario asociado a la sesión |
isUserTrackingEnabled(callback): void
Allows to know the status of the user data sending
Parameters | Type | Description |
---|---|---|
callback | (active) => void | true or false |
getSyncDeviceId(): string
Returns the id associated with the device or null. The device id is obtained asynchronously by the SDK, therefore this method can return null if the id isn't still associated with the device. To obtain the device asynchronously use the event "onDeviceId"
0 Comments