Broadcast
About the Broadcast API
Last updated
About the Broadcast API
Last updated
The Broadcast
service is used to send data to and receive data from external Android apps using JavaScript.
The Broadcast service supports Android broadcast categories. Please see the and sections in the Android documentation on for more information on intent resolution.
Use the register
function to receive data:
target
Broadcast.Target
Broadcast registration target.
target.action
string
Unique name used to identify the broadcasting event. This should correspond to the event name in your external application.
target.categories
string[]
Array of categories to register broadcast against.
callback
function
Function to be called as soon as a broadcast event is received. The function takes a single parameter, data
(object)
options
object
Optional object to specify options. Added in v21.2.1 of the JourneyApps Container and v4.78.2 of the JourneyApps Runtime.
options.background
boolean
Should Broadcasts trigger when the container is in the background. Defaults to true
e.g.
Use the trigger
function to send data:
target
Broadcast.Target
Listener target to broadcast to.
target.action
string
Unique name used to identify the broadcasting event. This should correspond to the event name in your external application.
target.categories
string[]
Array of categories for broadcast event.
eventData
object
Data sent to the external application. Note that eventData
should be an object.
e.g.
Use the getCapabilities
function to see whether the active device and JourneyApps Container supports the Broadcast API:
** Returns **: object
with a supported
field. This field will be true
if the active device and JourneyApps Container supports the Broadcast API and false
otherwise.
Here are some other code examples that show how the Broadcast API can be used.
eventData
must be an object):