Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

react-native-communications

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-native-communications

Open a web address or call, email, text or iMessage (iOS only) someone in React Native

  • 1.0.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
51K
increased by10.28%
Maintainers
1
Weekly downloads
 
Created
Source

react-native-communications

Release Notes

Open a web address, easily call, email, text, iMessage (iOS only) someone in React Native

Installation

If you are on React Native >= 0.20 just

npm install react-native-communications

Note: Do not use version 1.0.0 of this module as it contained a bug with the phonecall method.


Versions 0.15 through to and including 0.19 of React Native are also supported by running the following installation command

npm install react-native-communications@0.2.3

Methods

phonecall(phoneNumber, prompt)

phoneNumber - String
prompt - Boolean

Both arguments are required and need to be of the correct type.

iOS

If prompt is true it uses the undocumented telprompt: url scheme. This triggers an alert asking user to confirm if they want to dial the number. There are conflicting reports around the internet about whether Apple will allow apps using this scheme to be submitted to the App store (some have had success and others have had rejections).

If you face any problems having apps approved because of this raise an issue in this repo and I will look at removing it.

Android

telprompt: is not supported on Android. The prompt argument is ignored when run on Android devices.


email(to, cc, bcc, subject, body)

to - String Array
cc - String Array
bcc - String Array
subject - String
body - String

You must supply either 0 arguments or the full set (5).

If 0 arguments are supplied the new email view will be launched with no prefilled details.

If 5 are supplied they will be checked against their expected type and ignored if the type is incorrect.

If there are any arguments you don't want to provide a value for set them as null or undefined.

e.g.

email(['emailAddress'], null, null, null, 'my body text') would open the new email view with a recipient and body text prefilled.

email(null, ['emailAddress1', 'emailAddress2'], null, 'my subject', null) would open the new email view with two recipients in the cc field and a subject prefilled.

email([123, 'emailAddress'], null, null, 789, ['my body text']) would open the new email view with one recipient prefilled and no other values.


text(phoneNumber)

phoneNumber - String

phoneNumber is an optional argument. If it is not provided then the new message view will be launched with no recipient specified.

If it is provided but is the wrong type then again the new message view will be launched with no recipient specified.


web(address)

address - String

Current requirements for address are that it is provided and is a String. There is no validation on whether it is a valid address.

Usage

Note:

This will only work fully when run on actual devices. The iOS simulator only supports the web method and does not have the required device components installed to run any of the other methods. The Android emulator can run all the methods apart from email.

Assuming you have npm install -g react-native-cli, first generate an app:

react-native init RNCommunications
cd RNCommunications
npm install react-native-communications --save

Then paste the following into RNCommunications/index.ios.js and/or RNCommunications/index.android.js:

'use strict';

var React = require('react-native');
var {
  AppRegistry,
  StyleSheet,
  Text,
  TouchableOpacity,
  View,
} = React;

var Communications = require('react-native-communications');

var RNCommunications = React.createClass({

  render: function() {
    return (
      <View style={styles.container}>
      <TouchableOpacity onPress={() => Communications.phonecall('0123456789', true)}>
        <View style={styles.holder}>
          <Text style={styles.text}>Make phonecall</Text>
        </View>
      </TouchableOpacity>
      <TouchableOpacity onPress={() => Communications.email(['emailAddress1', 'emailAddress2'],null,null,'My Subject','My body text')}>
        <View style={styles.holder}>
          <Text style={styles.text}>Send an email</Text>
        </View>
      </TouchableOpacity>
      <TouchableOpacity onPress={() => Communications.text('0123456789')}>
        <View style={styles.holder}>
          <Text style={styles.text}>Send a text/iMessage</Text>
        </View>
      </TouchableOpacity>
      <TouchableOpacity onPress={() => Communications.web('https://github.com/facebook/react-native')}>
        <View style={styles.holder}>
          <Text style={styles.text}>Open react-native repo on Github</Text>
        </View>
      </TouchableOpacity>
      </View>
    );
  }
});

var styles = StyleSheet.create({
  container: {
    flex: 1,
    alignItems: 'center',
    backgroundColor: 'rgb(253,253,253)',
  },
  holder: {
    flex: 0.25,
    justifyContent: 'center',
  },
  text: {
    fontSize: 32,
  },
});

AppRegistry.registerComponent('RNCommunications', () => RNCommunications);

TODO

  • Refactor how arguments are passed in to the methods (change from multiple parameters to an args object)

Keywords

FAQs

Package last updated on 12 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc