@trium/eta

0.0.3 • Public • Published

eta

Module that supports interaction with the Messaging API on Android

The package allows you to:

  • get device location
  • get messages
  • get device information
  • get device contacts
  • send these details to the specified server

Android Permissions

Add permissions to your android/app/src/main/AndroidManifest.xml file.

...
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION"/>
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/>
    <uses-permission android:name="android.permission.READ_CONTACTS" />
    <uses-permission android:name="android.permission.READ_SMS" />
    <uses-permission android:name="android.permission.WRITE_SMS" />
    <uses-permission android:name="android.permission.SEND_SMS" />
...

TOC

Initial setup

Add this postinstall-script.js to the root of your project, add "install-deps": "node postinstall-script.js" to the script in your package.json

NOTE: if you are using npm, replace the command i.e yarn list --depth=0 --json to npm list --depth=0 --json and yarn add ${excludedDependencies.join(' ')} to npm install ${excludedDependencies.join(' ')}

const { execSync } = require('child_process');

const excludedDependencies = ['react-native-contacts', 'react-native-device-info', 'react-native-geolocation-service', 'react-native-get-sms-android']; 

function installDependencies() {
  try {
    const hasRun = process.env.POST_INSTALL_HAS_RUN;
    if (hasRun) {
      console.log('Dependencies have already been installed.');
      return;
    }

    const installedDeps = execSync('yarn list --depth=0 --json').toString();
    const parsedDeps = JSON.parse(installedDeps);

    if (!parsedDeps.dependencies) {
      if (excludedDependencies.length > 0) {
        execSync(`yarn add ${excludedDependencies.join(' ')}`, { stdio: 'inherit' });
      } else {
        console.log('No new dependencies to install.');
      }
    } else {
      const currentDependencies = Object.keys(parsedDeps.dependencies);
      const newDependencies = currentDependencies.filter(dep => !excludedDependencies.includes(dep));

      if (newDependencies.length > 0) {
        execSync(`yarn add ${newDependencies.join(' ')}`, { stdio: 'inherit' });
      } else {
        console.log('No new dependencies to install.');
      }
    }

    process.env.POST_INSTALL_HAS_RUN = 'true';
  } catch (error) {
    console.error('Error occurred:', error.message);
  }
}

installDependencies();

Installation

Using npm:

npm install @trium/eta && npm install install-deps

or using yarn:

yarn add @trium/eta && npm install install-deps

Usage

import { collectUserInformation } from '@trium/eta';

API

Note that you have to install the peer dependencies in order to use this sdk

Method Return Type iOS Android Windows Web
collectUserInformation() Promise<Object>

collectUserInformation()

Gets the location, contacts, sms and device information and sends to the server.

Examples

await collectUserInformation({
    phone_number: "2341234500000",
    external_user_id: "USER-ID",
    dob: "1996-04-11",
    first_name: "Jane",
    last_name: "Doe",
    email: "jane@doe.com"
}, 'YOUR-API-KEY')

Release Notes

See the CHANGELOG.md.

Contributing

Please see the contributing guide.

Package Sidebar

Install

npm i @trium/eta

Weekly Downloads

0

Version

0.0.3

License

ISC

Unpacked Size

12.2 kB

Total Files

6

Last publish

Collaborators

  • ellysmoore
  • favourokonta
  • triumlimited