Cordova Campaign API reference

Below are the methods that you can use to manage the Campaign library for Cordova.

Methods

(static) error(message)

Console error reporting

ParameterTypeDefinition
messagestringError message

(static) getAppKey(callback)

Returns the current appKey.

ParameterTypeDefinition
callbackappKeyCallbackThe callback that handles the response

(static) getBadge(callback)

ParameterTypeDefinition
callbackgetBadgeCallbackThe callback that handles the response

(static) getPluginVersion(callback)

ParameterTypeDefinition
callbacksdkVersionCallbackThe callback that handles the response

(static) getRegistrationDetails(callback)

ParameterTypeDefinition
callbackregistrationDetailsCallbackThe callback that handles the response

(static) getSdkVersion(callback)

Returns the current native SDK version in use.

ParameterTypeDefinition
callbacksdkVersionCallbackThe callback that handles the response

(static) manualInitialization()

Manually initialize the library. It waits until an event occurs before beginning to interact with the Acoustic servers. For example, you might not want to create a userid/channelid until after a user logs into your system.

Requires the autoInitialize setting in CampaignConfig.json to be set to false.

(static) phoneHome()

Executes phone home request which may update the userId and channelId to match changes made on the server. Typically used after contact merge on Engage during user identification. This allows the inbox to be synchronized between multiple installations of the application on different devices for the same user. Note, phone home will execute once every 24 hours automatically without calling this API.

(static) queueAddEvent(event, flush)

Sends an event to the Acoustic infrastructure. The status will be reported to method registered via setEventQueueCallbacks.

ParameterTypeDefinition
eventEventThe event to send to the server
flushBoolean. Default value - true.When this is true, the event is sent immediately and flushes the queue of events to be sent. When it is false, the event is queued and will be automatically sent when the queue is automatically flushed at a later date. This parameter is optional.

(static) queueDeleteUserAttributes(attributes)

Removes specific user attributes .This method also includes automatic retrying of failures. This method has no callbacks, but the status of the request will be sent to the JavaScript callback that was registered with setAttributeQueueCallbacks or if none were registered, it will be queued.

ParameterTypeDefinition
attributesArrayThe list of attribute keys to be removed

(static) queueUpdateUserAttributes(attributes)

Updates any user attributes while leaving the existing attributes alone. This method also includes automatic retrying of failures. This method has no callbacks, but the status of the request will be sent to the JavaScript callback that was registered with setAttributeQueueCallbacks or if none were registered, it will be queued.

ParameterTypeDefinition
attributesObjectThe list of attributes in key/value format

(static) safeAreaInsets(callback)

ParameterTypeDefinition
callbackFunctionRetrieves a safe area for device

(static) setActionNotRegisteredCallback()

Allow Cordova developer to detect when a push action is not handled.

(static) setActionNotYetRegisteredCallback()

Lets you detect when a push action is not handled, but was previously registered.

(static) setAttributeQueueCallbacks(callback, callback)

Lets you check when attributes are sent to the server. If an attribute is sent while the application is not active, the callback will be queued until the next time this method is called to register a callback handler.

ParameterTypeDefinition
callbackattributeQueueSuccessCallbackThe callback that handles the response
callbackattributeQueueFailureCallbackThe callback that handles the response

(static) setBadge(badge)

Sets the badge count for the iOS home screen.

ParameterTypeDefinition
badgeIntegerA new number of badges

(static) setCategoryCallbacks(callback, categoryName, actions)

Lets you register and respond to iOS static categories.

ParameterTypeDefinition
callbackcategoryCallbackThe callback that handles the response
categoryNameStringName of category to respond to in iOS payload
actionsArrayAn array of actions

(static) setEventQueueCallbacks(successCallback, errorCallback)

Lets you check when events are sent to the server. If the event is sent while the application is not active, the callback will be queued until the next time this method is called to register a callback handler.

ParameterTypeDefinition
successCallbackeventQueueSuccessCallbackThe callback that handles the response
errorCallbackeventQueueFailureCallbackThe callback that handles the response

(static) setIcon(drawableName)

Lets you change the Android icon.

ParameterTypeDefinition
drawableNameStringName of a drawable image in app bundle

(static) setRegisteredActionCallback(callback, type)

Lets you handle custom actions.

ParameterTypeDefinition
callbackregisteredActionCallbackThe callback that handles the response
typeStringCustom Action type from the "notification-action" or the "category-actions" section of the payload

(static) setRegistrationCallback(callback)

Notifies you when a registration occurs. This will only be called once when the application registers with the Acoustic servers. If the application is not active when this happens, the callback will be queued until the next time this method is called to register a callback handler.

ParameterTypeDefinition
callbackregistrationCallbackThe callback that handles the response

(static) translateAttributes(attributes) → {Array.<Object>}

An internal function to translate a dictionary of attributes with dates into integers so they can be processed by the library.

ParameterTypeDefinition
attributesArray of objectsAttributes to be converted

Returns an array of objects.

(static) translateAttributesCallback(attributes) → {Array.<Object>}

An internal function to translate a dictionary of attributes with dates represented as integers back into JavaScript date objects.

ParameterTypeDefinition
attributesArray of objectsAttributes to be converted

Returns an array of objects.

(static) translateEvents(events) → {Array.<Event>}

An internal function to translate timestamps from integers or strings to JavaScript date objects.

ParameterTypeDefinition
eventsArrayList of events to translate

Returns an array of events.

(static) unregisterActionCallback(type)

Stop handling custom actions.

ParameterTypeDefinition
typeStringCustom Action type from the "notification-action" or the "category-actions" section of the payload

(static) userInvalidated(callback)

Queries if a user has been invalidated.

ParameterTypeDefinition
callbackFunctionRetrieves the status of a user.

Type definitions

appKeyCallback(appKey)

ParameterTypeDefinition
appKeyStringA short string for identifying the app in the co.acoustic.mobilepush system

attributeQueueFailureCallback(result)

Properties supported by the result object

PropertyTypeDefinition
attributesObjectKey/value pairs that were updated if the operation was set or update
domainStringEither "channel" or "user" depending on which method was called
errorStringDescription of the error
keysArrayA list of keys that were deleted when the operation is delete
operationStringEither "update" or "delete" depending on which method was called

attributeQueueSuccessCallback(result)

Properties supported by the result object

PropertyTypeDefinition
attributesObjectKey/value pairs that were updated if the operation was set or update
domainStringEither "channel" or "user" depending on which method was called
keysArrayA list of keys that were deleted when the operation is delete
operationStringEither "update" or "delete" depending on which method was called

basicFailureCallback(error)

ParameterTypeDefinition
errorStringDescription of the error

categoryCallback(payload, identifier)

ParameterTypeDefinition
payloadObjectEntire Android or iOS payload for example {"aps":{"alert":"hello world", "category":"example"}}
identifierStringString identifying button to JavaScript processing click of button

Event

PropertyTypeDefinition
attributesObjectDetails about the event, freeform key/value pairs
attributionStringThe campaign name associated with the event (optional)
nameStringEvent name. The library automatically sends events named "sessionStart", "sessionEnd", "urlClicked", "appOpened", "phoneNumberClicked".
timestampDateIndicates when the event occurred.
typeStringEvent type. The library automatically sends events of "simpleNotification" and "application" types.

eventQueueFailureCallback(result)

Properties supported by the result object

PropertyTypeDefinition
eventsArrayList of events that were sent
errorStringDescription of the error

eventQueueSuccessCallback(events)

ParameterTypeDefinition
eventsArrayList of events that were sent

getBadgeCallback(badgeCount)

ParameterTypeDefinition
badgeCountIntegerThe number of badges

registeredActionCallback(actionPayload, payload)

ParameterTypeDefinition
actionPayloadObjectIt is normally in the format { "type": <type>, "value": <value> } but can be anything that is sent in the "notification-action" or the "category-actions" section of the payload.
payloadObjectEntire Android or iOS payload for example {"aps":{"alert":"hello world", "category":"example"}}

registeredCallback(providerRegistered, providerName, callback)

ParameterTypeDefinition
callbackregisteredCallbackThe callback that handles the response
co.acoustic.mobilepushRegisteredBooleanIndicates if the device is registered with the Acoustic infrastructure
providerNameStringThe name of a provider, e.g. "APNS" or "GCM". Lets you determine if the device has registered with the push provider's service and if it has registered with the Acoustic infrastructure.
providerRegisteredBooleanIndicates if the device is registered with a push provider system (APNS or GCM).

Registration

PropertyTypeDefinition
channelIdStringA short string identifying the channel or device
deviceTokenStringA medium string that represents the iOS device on APNS
registrationIdStringA medium string that represents the Android device on GCM
userIdStringA short string identifying the user, possibly multiple devices

registrationCallback(registration)

ParameterTypeDefinition
registrationRegistrationRegistration details

registrationDetailsCallback(Registration)

ParameterTypeDefinition
RegistrationRegistrationRegistration details

sdkVersionCallback(version)

ParameterTypeDefinition
versionStringA short string representing the version of the Campaign library

Related pages

Notification action plugins for Cordova apps