Bridge API

As explained in the introduction 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's console object, and the log, warn and error methods
  • throwError(reason<String>): will return a 500 response, with an Error object initialized with the reason message
  • sendResponse(response<Object>, code<Number> = 200): will return a response to the router with the given HTTP code (the default is 200)
  • appData() -> <Object>: a function which returns data from the native app. It returns an object with the following properties:

    • uuid: device uuid
    • accountId: Zapp account Id
    • broadcasterId: Applicaster broadcaster Id
    • bundleIdentifier: bundle identifier of the app
    • platform: android or ios
    • apiSecretKey: API private key
    • languageLocale: language locale as configured in the device
    • countryLocale: country locale as configured in the device
    • advertisingIdentifier: this returns the idfa for iOS and the aaid for Android (if advertising is disabled this field is empty)
    • deviceType: phone or tablet
    • deviceWidth: width of the device
    • deviceHeight: height of the device
    • ver: version number of the app (Android only)
    • os_type: operating system of the app. The value is always android (Android only)
    • pluginConfigurations: object with the plugin configurations (Android only)
    • broadcasterExtensions: extensions object for the Applicaster broadcaster (iOS only)
  • fetch(url<String>[, options<Object>]) -> <Promise: Any>: allows the provider to perform HTTP get requests through the bridge. The options object is optional. It allows to define headers and other options. Returns a promise with the body of the response. It responds automatically with the throwError method if an exception is caught when making the request. Errors are thrown for all responses with status codes 4XX or 5XX

  • 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 details about the options object.

results matching ""

    No results matching ""