@angoralabs/angora-react-native

0.4.1 • Public • Published

Angora

React Native SDK

Installation

npm install @angoralabs/angora-react-native

or

yarn add @angoralabs/angora-react-native

Installation Dependencies

Angora's React Native SDK uses react-native-device-info.

After installing Angora's React Native SDK, you should also install react-native-device-info.

Usage

init

At the index.js, import angora from @angoralabs/angora-react-native and call the init function.

import {AppRegistry} from 'react-native';
import App from './App';
import {name as appName} from './app.json';
import {version as appVersion} from './package.json';
import {angora} from '@angoralabs/angora-react-native';

angora.init({
  token:
    'OGIyZTJmNGEtMzc4OS01NGE3LTg4ZTctZGJjMmVkZDU1MjdjOjIxODE4NzhmOGExNWEyM2YxOTI4MzFiMGEwYzRjZmUzZDFhNjIxNDM=',
  appName,
  appVersion,
});

AppRegistry.registerComponent(appName, () => App);

The init function expects and object containing:

  • token: your app key, which can be found on the integration session
  • appName: your app's name
  • appVersion: your app's version

AppState

Angora needs access to the AppState. At your root component, probably the App.js, add the AngoraAppState component, if it's a class component or just call the useAngoraAppState hooks, if it's a function component.

Function Component

import React, {useEffect} from 'react';

import {useAngoraAppState} from '@angoralabs/angora-react-native';

const App = () => {
  useAngoraAppState();

  return (
    // ...
  );
};

export default App;

Class Component

import React, {Component} from 'react';

import {AngoraAppState} from '@angoralabs/angora-react-native';

class App extends Component {

  render() {
    return (
      <AngoraAppState />
      // ...
    );
  }
};

export default App;

Attention

Without AngoraAppState or useAngoraAppState, the Angora React Native SDK won't be able to track sessions events.

Contributing

Not available yet.

License

MIT

Dependencies (1)

Dev Dependencies (8)

Package Sidebar

Install

npm i @angoralabs/angora-react-native

Weekly Downloads

1

Version

0.4.1

License

MIT

Unpacked Size

119 kB

Total Files

67

Last publish

Collaborators

  • jgcmarins