• Stars
    star
    390
  • Rank 110,242 (Top 3 %)
  • Language
    JavaScript
  • License
    MIT License
  • Created over 6 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

📭 Open an email client from React Native (for 'magic link' type functionality).

React Native Email Link

GitHub release NPM GitHub license


An easy way to open an email app of the user's choice, based on the apps they have installed on their device. Very helpful for magic link logins.

Currently supported apps:

  • Apple Mail
  • Gmail
  • Inbox
  • Spark
  • Airmail
  • Outlook
  • Yahoo Mail
  • Superhuman
  • Yandex
  • ProtonMail
  • Fastmail

Installation

1. Install the package

yarn add react-native-email-link

This package works with autolinking on RN>=0.60. If you're using an earlier version of React Native, please install version 1.4.0 of the library, or check out the legacy rnpm branch.

2. Post-install steps

Based on the platforms your app supports, you also need to:

iOS – Update Info.plist

To allow your app to detect if any of the mailbox apps are installed, an extra step is required on iOS. Your app needs to provide the LSApplicationQueriesSchemes key inside ios/{my-project}/Info.plist to specify the URL schemes with which the app can interact.

Just add this in your Info.plist depending on which apps you'd like to support. Omitting these might mean that the library can't detect some of the maps apps installed by the user.

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>mailto</string>
    <string>message</string>
    <string>readdle-spark</string>
    <string>airmail</string>
    <string>ms-outlook</string>
    <string>googlegmail</string>
    <string>inbox-gmail</string>
    <string>ymail</string>
    <string>superhuman</string>
    <string>yandexmail</string>
    <string>fastmail</string>
    <string>protonmail</string>
    <string>szn-email</string>
</array>
Expo – Enable Config Plugin

To allow the library to work with Expo you need to enable the config plugin. This plugin will automatically configure your Expo application with the correct settings for this library to function.

To enable the config plugin, add it to the plugins array inside your app.config.js/app.config.json. For example:

{
  "name": "my app",
  "plugins": ["react-native-email-link"]
}

Want this library to work on Android too? Because the library uses native code on Android you need to follow Expo's guide for custom native code.

Usage

openInbox

import { openInbox } from "react-native-email-link";

openInbox();

Arguments

title

Text for the top of the ActionSheet or Intent.

Type Required Default
string No 'Open mail app'

message

Subtext under the title on the ActionSheet

Type Required Default Platform
string No 'Which app would you like to open?' iOS

cancelLabel

Text for last button of the ActionSheet.

Type Required Default Platform
string No 'Cancel' iOS

removeText

If true, not text will be show above the ActionSheet or Intent. Default value is false.

Type Required Default
boolean No false

defaultEmailLabel

Text for first button of the ActionSheet.

Type Required Default Platform
string No 'Default email reader' iOS

newTask

If true, the email Intent will be started in a new Android task. Else, the Intent will be launched in the current task.

Read more about Android tasks here.

Type Required Default Platform
boolean No true Android

Example

import { openInbox } from "react-native-email-link";

openInbox({
  message: "Whatcha wanna do?",
  cancelLabel: "Go back!",
});

openComposer

import { openComposer } from "react-native-email-link";

openComposer();

Arguments

title

Text for the top of the ActionSheet or Intent.

Type Required Default
string No 'Open mail app'

message

Subtext under the title on the ActionSheet.

Type Required Default Platform
string No 'Which app would you like to open?' iOS

cancelLabel

Text for last button of the ActionSheet.

Type Required Default Platform
string No 'Cancel' iOS

removeText

If true, not text will be show above the ActionSheet or Intent. Default value is false.

Type Required Default
boolean No false

defaultEmailLabel

Text for first button of the ActionSheet.

Type Required Default Platform
string No 'Default email reader' iOS

to

Recipient's email address.

Type Required Default
string No null

cc

Email's cc (iOS only).

Type Required Default
string No null

bcc

Email's bcc (iOS only).

Type Required Default
string No null

subject

Email's subject.

Type Required Default
string No null

body

Email's body.

Type Required Default
string No null

encodeBody

Apply encodeURIComponent to the email's body.

Type Required Default
boolean No false

Example

import { openComposer } from "react-native-email-link";

openComposer({
  to: "[email protected]",
  subject: "I have a question",
  body: "Hi, can you help me with...",
});

Get professional support for this package →
Custom consulting sessions available for implementation support or feature development.

More Repositories

1

php-pkpass

💳 PHP class for creating passes for Wallet on iOS.
PHP
908
star
2

react-native-map-link

🗺 Open the map app of the user's choice.
TypeScript
651
star
3

react-native-check-version

🥕 Get the latest version of your app.
JavaScript
188
star
4

db.php

🍎 Simple PHP class for doing standard MySQL actions, such as select, insert, update and delete rows.
PHP
103
star
5

lambda-sample-events

⚡️ A library of example event payloads for AWS Lambda.
JavaScript
48
star
6

react-native-keycode

🔢 Show the user a input form for a fixed-length code or password.
JavaScript
43
star
7

macaw

🦜 Scalable email templates for Node.js applications.
JavaScript
26
star
8

mapkit-jwt

🗺 Simple class to create MapKit and MusicKit JWT tokens.
PHP
18
star
9

react-native-confetti-view

JavaScript
9
star
10

things-stats

📊 Stats tool for Things.
JavaScript
6
star
11

csv-hero

🦸‍ The easiest tool to merge, filter and mangle CSV and JSON files.
JavaScript
5
star
12

jsnotebook

📘 Play around with Javascript in your browser and share notebooks.
JavaScript
5
star
13

todo-chrome-extensions

📩 Chrome extension to quickly add Gmail conversations as tasks in Things & OmniFocus.
JavaScript
5
star
14

tschoffelen

🌎 My personal website.
HTML
4
star
15

react-update-popup

🔄 Ask users to refresh when there is a new version of the app available.
TypeScript
4
star
16

things-gmail

📩 A Chrome extension to quickly add Gmail conversations as a task in Things.
JavaScript
3
star
17

serverless-starter

Starter boilerplate for a serverless API.
JavaScript
2
star
18

breakout-team

📹 Video breakout rooms made easy.
JavaScript
1
star
19

mirri

🌿 A little file sharing app.
JavaScript
1
star
20

gatsby-remark-fountain

Plugin to render Fountain screenwriting syntax in `gatsby-transformer-remark`.
JavaScript
1
star
21

advent-2020

🎅 My Advent of Code solutions.
JavaScript
1
star
22

alfred-schof.link

Alfred workflow to copy clipboard to schof.link.
JavaScript
1
star