Bridge API
As explained in the intro section of this documentation, Zapp-pipes bundles are evaluated inside a JS bridge which provides specific features to the Zapp-pipes bundles. For simplicity's sake, the bridge features are wrapped in a javascript toolbelt object which is injected in each provider's handler function.
The nativeBridge
object provides the following methods :
log(...msg<[Any]>)
: logs a message. You can also use the browser'sconsole
object, and thelog
,warn
, anderror
methods.throwError(reason<String>)
: will return a 500 response, with anError
object initialized with thereason
messagesendResponse(response<Object>, code<Number> = 200)
: will return a response to the router, with the given http code (default is 200)appData() -> <Object>
: function which returns data from the native app. returns an object with the following properties:uuid
: device uuidaccountId
: Zapp account IdbroadcasterId
: Applicaster broadcaster IdbundleIdentifier
: bundle identifier of the appplatform
: android or iosapiSecretKey
: api private keylanguageLocale
: language locale configured in the devicecountryLocale
: country locale configured in the deviceadvertisingIdentifier
: this returns the idfa for iOS and aaid for Android (if advertising is disabled this field is empty)deviceType
: phone or tabletdeviceWidth
: width of the devicedeviceHeight
: height of the devicever
: version number of the app (just Android)os_type
: operative system of the app. The value is always android (just Android)pluginConfigurations
: object with the plugin configurations (just Android)broadcasterExtensions
: extensions object for the Applicaster broadcaster (just iOS)
fetch(url<String>[, options<Object>]) -> <Promise: Any>
: allows the provider to perform http get requests through the bridge. theoptions
object is optional and allows to define headers, and other options. Returns a promise with the body of the response, and automatically responds with thethrowError
method if an exception is caught when making the request. Errors are thrown for all responses with a status code of4XX
or5XX
.postData(url<String>, body<Any>[, options<Object>]) -> <Promise: Any>
: allows the provider to send data through a post request. Returns a promise with the body or the server response.
The fetch
and postData
methods use the axios library. See axios documentation for specific documentation about the options object.