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'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 (default is 200)
  • appData() -> <Object> : function which returns data from the native app. 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 configured in the device
    • countryLocale: country locale configured in the device
    • advertisingIdentifier: this returns the idfa for iOS and 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 (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. the options object is optional and allows to define headers, and other options. Returns a promise with the body of the response, and automatically responds with the throwError method if an exception is caught when making the request. Errors are thrown for all responses with a status code of 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 specific documentation about the options object.

results matching ""

    No results matching ""