Skip to content

Commit

Permalink
Composing an email with attachments and file-not-found. #13
Browse files Browse the repository at this point in the history
  • Loading branch information
EddyVerbruggen committed Jan 18, 2017
1 parent f024e18 commit d09bb9f
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 14 deletions.
25 changes: 15 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,43 +13,43 @@ The run the following command from the root of your project:
tns plugin add nativescript-email
```

## Usage
## API

To use this plugin you must first require/import it:

#### typescript
#### TypeScript

```js
import * as email from "nativescript-email";
```

#### javascript
#### JavaScript

```js
var email = require("nativescript-email");
```

### available
### `available`

#### typescript
#### TypeScript

```js
email.available((avail) => {
console.log("Email available? " + avail);
})
```

#### javascript
#### JavaScript

```js
email.available().then(function(avail) {
console.log("Email available? " + avail);
})
```

### compose
### `compose`

#### javascript
#### JavaScript

```js

Expand All @@ -76,13 +76,18 @@ var email = require("nativescript-email");
mimeType: 'image/png'
}],
appPickerTitle: 'Compose with..' // for Android, default: 'Open with..'
}).then(function() {
}).then(
function() {
console.log("Email composer closed");
});
}, function(err) {
console.log("Error: " + err);
});
```

Full attachment support has been added to 1.3.0 per the example above.

Since 1.4.0 the promise will be rejected in case a file can't be found.

## 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 sim.
4 changes: 2 additions & 2 deletions email.android.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ exports.compose = function (arg) {
var uri = _getUriForPath(path, fileName, application.android.context);

if (!uri) {
console.log("File not found for path: " + path);
continue;
reject("File not found for path: " + path);
return;
}
uris.add(uri);
}
Expand Down
3 changes: 2 additions & 1 deletion email.ios.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ exports.compose = function (arg) {
var path = attachment.path;
var data = _getDataForAttachmentPath(path);
if (data === null) {
console.log("File not found for path: " + path);
reject("File not found for path: " + path);
return;
} else if (!attachment.fileName) {
console.log("attachment.fileName is mandatory");
} else if (!attachment.mimeType) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "nativescript-email",
"version": "1.3.4",
"version": "1.4.0",
"description": "Email plugin for your NativeScript app",
"main": "email",
"typings": "email.d.ts",
Expand Down

0 comments on commit d09bb9f

Please sign in to comment.