npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@nativescript/email

v2.1.0

Published

Email plugin for your NativeScript app

Downloads

2,023

Readme

@nativescript/Email

You can use this plugin to compose an e-mail, have the user edit the draft manually, and send it.

Note: This plugin depends on the default mail app. If you want a fallback to a third party client app like Gmail or Outlook, then check for availability, and if not available use a solution like the Social Share plugin.

Installation

npm install @nativescript/email

Usage

Importing

Once you've installed the plugin, the next step is to import it before using it.

import * as email from '@nativescript/email';
// or
import { compose } from '@nativescript/email';
// or even
import { compose as composeEmail } from '@nativescript/email';

Checking the availability

To check if the device has a mail app installed, call the available method.

email.available().then((avail: boolean) => {
	console.log('Email available? ' + avail);
});

Composing an email

To compose an email, use the compose method.

// let's first create a File object
import { knownFolders } from '@nativescript/core';
var appPath = knownFolders.currentApp().path;
var logoPath = appPath + '/res/telerik-logo.png';

email
	.compose({
		subject: 'Yo',
		body: 'Hello <strong>dude</strong> :)',
		to: ['[email protected]', '[email protected]'],
		cc: ['[email protected]'],
		bcc: ['[email protected]', '[email protected]'],
		attachments: [
			{
				fileName: 'arrow1.png',
				path: 'base64://iVBORw0KGgoAAAANSUhEUgAAABYAAAAoCAYAAAD6xArmAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAHGlET1QAAAACAAAAAAAAABQAAAAoAAAAFAAAABQAAAB5EsHiAAAAAEVJREFUSA1iYKAimDhxYjwIU9FIBgaQgZMmTfoPwlOmTJGniuHIhlLNxaOGwiNqNEypkwlGk9RokoIUfaM5ijo5Clh9AAAAAP//ksWFvgAAAEFJREFUY5g4cWL8pEmT/oMwiM1ATTBqONbQHA2W0WDBGgJYBUdTy2iwYA0BrILDI7VMmTJFHqv3yBUEBQsIg/QDAJNpcv6v+k1ZAAAAAElFTkSuQmCC',
				mimeType: 'image/png',
			},
			{
				fileName: 'telerik-logo.png',
				path: logoPath,
				mimeType: 'image/png',
			},
		],
	})
	.then(
		function () {
			console.log('Email composer closed');
		},
		function (err) {
			console.log('Error: ' + err);
		}
	);

API

Method(s)

| Name | Return Type | Description | |------|------|-------------| | available() | Promise<boolean>| Checks for availability of a mail app.| | compose(options: ComposeOptions) | Promise<boolean> | Composes and sends a ComposeOptions email.|

Attachment

| Name | Type | Description | |------|------|-------------| | fileName| string | The name used for the attachment.Example: fileName: 'Cute-Kitten.png'| | path | string | The to the file to be attached. | | mimeType | string | (iOS-only)Used to help the iOS device figure out how to send the file.Example:mimeType: 'image/png'|

ComposeOptions

| Name | Type | Description | |------|------|-------------| | subject| string| Optional: The subject of the email.| | body| string| Optional: The body of the email. The plugin will automatically handle plain and html email content.| | body| string| Optional: The body of the email. The plugin will automatically handle plain and html email content.| | to | string[] | Optional: An array of email addresses of the direct recipients. On Android only the first item in the array is used.| | cc | string[] | Optional: An array of email addresses of the cc recipients.| | bcc | string[] | Optional: An array of email addresses of the bcc recipients.| | attachments| Array<Attachment>| The files to be attached to the email.| | iosViewController | any | Optional: (iOS-only) iOS View Controller to open compose from.|

Usage with Angular

Check out this tutorial (YouTube) to learn how to use this plugin in a NativeScript-Angular app.

Known issues

On iOS you can't use the simulator to test the plugin because of an iOS limitation. To prevent a crash, this plugin returns false when available is invoked on the iOS simulator.

License

Apache License Version 2.0