Giter Club home page Giter Club logo

react-native-zapp-bridge's Introduction

React Native Zapp Bridge

npm version CircleCI

A React Native package that includes bridging from React Native to Applicaster Zapp Platform native framework.

Please Read before you contribute

Commit messages are strictly enforced in this pattern:

type(scope?): subject
body?
footer?

Types can be one of the following: [build, chore, ci, docs, feat, fix, perf, refactor, revert, style, test][type-enum]

Continuous deployment

Deployment is automated by Semantic Release. When PRs are merged to master Semantic Release will analyse the commit log, increment version, tag a release and publish directly to public NPM.

Features

React-Native-Zapp-Bridge is a util package that enable you to:

  1. Analytics - use sendAnalyticEvent to send an analytics event throw Zapp Morpheus (Zapp Analytics Manager).

  2. Video Player - use APVideoPlayer to add a video player to your React-Native screen, this will add the chosen pluggable player on the Zapp Platform.

  3. Zapp login - methods for logging in users and checking their login status

  4. Data source plugin - This class helps you to interact with the DS plugin. Use DataSourceService to make http request from DS plugin (DS plugin returns Atom model as result).

  5. Zapp player - methods for playing videos fullscreen

  6. reminders - An API for adding, removing & checking status of program reminders.

  7. navigation - An API for navigating within Zapp apps.

  8. withZapp - A React Native HoC for parsing plugin properties making them consistent across platforms.

  9. Zapp Plugin - An API for getting information about plugin

Installation

$ npm install --save applicaster/react-native-zapp-bridge

Usage

Analytics

  1. import:
import { sendAnalyticEvent } from 'react-native-zapp-bridge';
  1. send event:
sendAnalyticEvent(`Your Screen Name`, {
    param: value,
  })
    .then(console.log)
    .catch(console.warn);
}

Video Player

  1. import:
import { APVideoPlayer } from 'react-native-zapp-bridge';
  1. create your video view:
  const streamUrl = `your_stream_url`
  const style = {
    backgroundColor: '#ffffff'
  }
  const maxWidth = 200;
  const src = {
    type: Platform.OS === 'android' ? 'vod' : 'url',
    object: {
      id: `your_item_id`,
      name: `your_item_title`,
      thumbnail_url: `your_item_image_url`
      stream_url: streamUrl,
    },
    player_configuration: {
      inline_player_should_auto_mute: true,
    },
  };

  // Example
  const onChange = event => {
    event.persist();

    if (event.nativeEvent.eventName === 'onVideoEnd') {
      this.playNextVideo()
    }
  };

  /*
  List of events you can receive from onChange

  onVideoEnd
  playerRemoved

  */


  return <APVideoPlayer {...{ src, maxwidth, style }} onChange={onChange}/>;
  1. onChange callback prop

The onchange callback occurs when a native event of the video has been changed, it returns an object with the event information.

Support events

Native Event Description
onVideoEnd The ended event occurs when the video has reached the end.
playerRemoved The playerRemoved occurs when the player is unmounted.

Data Source Plugin

  1. import:
import { ZappPipesService } from 'react-native-zapp-bridge';
  1. make a request:
ZappPipesService.getDataSourceData(`Url To Load From DS Plugin`)
    .then(content)
    .catch(error);
}

Zapp login

  1. import:
import { NativeModules } from 'react-native';
  1. check if user is logged in
NativeModules.ZappLogin.isUserLoggedIn();

Returns: Promise - resolves: { isUserLoggedIn: bool }

  1. login user
NativeModules.ZappLogin.login(additionalParams);

parameters: additionalParams: Object - can be empty. This parameter is being delieved as the additionalParams to the native login method. So any values in this object will be available to the receiver login plugin.

Returns: Promise - resolves: { isUserLoggedIn: bool }

  1. get user token
NativeModules.ZappLogin.getUserToken();

Returns: Promise - resolves: { token: string }

  1. check if user is authorized.

Unlike the login check - this can be used to check if user is authorized to play some content or check entitlements beyond just the login itself.

NativeModules.ZappLogin.isUserAuthorized(additionalParams);

parameters: additionalParams: Object - can be empty. This parameter is being delieved as the additionalParams to the native authorization check method. So any values in this object will be available to the receiver login plugin.

Returns: Promise - resolves: { authorized: bool }

Zapp player

  1. import:
import { NativeModules } from 'react-native';
  1. call player
NativeModules.ZappPlayer.playFullScreen(type, playable, configuration);

parameters: type: String playable: Object configuration: Object - can be empty

Supported values for configuration keys:

  • configuration['custom_configuration'] - This value is being delivered to the player plug as the player configuration dictionary.

Returns: Promise - resolves: true

Reminders

  1. import:
import { reminders } from 'react-native-zapp-bridge';
  1. methods:
reminders.addReminder({
  id: PROGRAM_ID_STR,
  channel_id: CHANNEL_ID_STR,
  starts_at: '2016-12-20T14:00:00+00:00',
  ends_at: '2016-12-20T15:00:00+00:00',
  name: PROGRAM_NAME_STR
}).then(PROGRAM_ID_STR => {
  // success
});
reminders.removeReminder(PROGRAM_ID_STR).then(PROGRAM_ID_STR => {
  // success
});
reminders.hasReminder(PROGRAM_ID_STR).then(RESULT_BOOL => {
  // success
});
reminders.checkReminders(PROGRAM_ID_STR_ARR).then(RESULT_OBJ => {
  // success
  // result object should look like:
  // { PROGRAM_ID: REMINDER_SET_BOOL, ... }
});

Navigation

  1. import:
import { navigation } from 'react-native-zapp-bridge';
  1. methods:

closeModalScreen

extraParams available in iOS only

  • @type {('push' string)} animation_type - Allowed animation types**
  • @param {object} [extraParams = {} ] - An extra params.
  • @param {bool*} [extraParams.animated = 1] - If close action should be animated.
  • @param {string} [extraParams.animation_type = undefined] - Close animation typr.

* bool in this scope represents 0 or 1;
** `push` present push close animation, any other string uses modal animation.

navigation.closeModalScreen(extraParams);

openInternalURL

  • @param {string} urlscheme - UrlScheme for your app
  • @param {Object} params - configuration params this will be appended to the url as an arguments;
  • @param {('present'|'push'|'presentNoNavigation'|'pushNoNavigation'|'asAChild')} params.presentation - How screen should be presented.
  • @param {string} params.plugin - Plugin name (name fild from the manifest)
  • @param {string} params.bundle - s3 folder name /react-native-bundles/yourName/Rn_version.
  • @param {any} reactProps[nameofTheProp] - this will be injected to the RN instance inside props.extra_props ...
navigation.openInternalURL(urlscheme, params);

withZapp

  1. import:
import { withZapp } from 'react-native-zapp-bridge';
  1. usage:
// in the entry point to the plugin import the root of your app
import App from './src/App';

// Augment your app with Zapp for consistent props to be passed cross platform
const AppWithZapp = withZapp(App);

const RNRoot = props => <AppWithZapp {...props} />;

// Module name
AppRegistry.registerComponent('RNRoot', () => RNRoot);

Zapp Plugin

  1. import:
import { NativeModules } from 'react-native';
const { ZappPlugin } = NativeModules;
  1. methods:
ZappPlugin.getConfiguration(PLUGIN_IDENTIFIER).then(PLUGIN_CONFIGURATION => {
    // success
});

react-native-zapp-bridge's People

Contributors

budaa avatar dickie81 avatar eladkariti2 avatar liviur avatar lomudi avatar lukehaas avatar pintocarlos avatar pretzi avatar saracodes avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Forkers

budaa

react-native-zapp-bridge's Issues

The automated release is failing 🚨

🚨 The automated release from the master branch failed. 🚨

I recommend you give this issue a high priority, so other packages depending on you could benefit from your bug fixes and new features.

You can find below the list of errors reported by semantic-release. Each one of them has to be resolved in order to automatically publish your package. I’m sure you can resolve this πŸ’ͺ.

Errors are usually caused by a misconfiguration or an authentication problem. With each error reported below you will find explanation and guidance to help you to resolve it.

Once all the errors are resolved, semantic-release will release your package the next time you push a commit the master branch. You can also manually restart the failed CI job that runs semantic-release.

If you are not sure how to resolve this, here is some links that can help you:

If those don’t help, or if this issue is reporting something you think isn’t right, you can always ask the humans behind semantic-release.


Invalid npm token.

The npm token configured in the NPM_TOKEN environment variable must be a valid token allowing to publish to the registry https://registry.npmjs.org/.

If you are using Two-Factor Authentication, make configure the auth-only level is supported. semantic-release cannot publish with the default auth-and-writes level.

Please make sure to set the NPM_TOKEN environment variable in your CI with the exact value of the npm token.


Good luck with your project ✨

Your semantic-release bot πŸ“¦πŸš€

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.