#35 Close toast when app is suspended or closed: documentation

This commit is contained in:
EddyVerbruggen 2015-05-21 21:31:18 +02:00
parent 5eb202fd54
commit 9c269fc9ba

View File

@ -118,16 +118,18 @@ Toast works with PhoneGap build too, but only with PhoneGap 3.0 and up.
Just add the following xml to your `config.xml` to always use the latest version of this plugin: Just add the following xml to your `config.xml` to always use the latest version of this plugin:
```xml ```xml
<gap:plugin name="nl.x-services.plugins.toast" /> <gap:plugin name="nl.x-services.plugins.toast" source="plugins.cordova.io" />
``` ```
or to use this exact version: or to use a specific version:
```xml ```xml
<gap:plugin name="nl.x-services.plugins.toast" version="1.0" /> <gap:plugin name="nl.x-services.plugins.toast" source="plugins.cordova.io" version="2.0.6" />
``` ```
Toast.js is brought in automatically. There is no need to change or add anything in your html. Toast.js is brought in automatically. There is no need to change or add anything in your html.
## 4. Usage ## 4. Usage
### Showing a Toast
You have two choices to make when showing a Toast: where to show it and for how long. You have two choices to make when showing a Toast: where to show it and for how long.
* show(message, duration, position) * show(message, duration, position)
* duration: 'short', 'long' * duration: 'short', 'long'
@ -148,6 +150,15 @@ You can copy-paste these lines of code for a quick test:
<button onclick="window.plugins.toast.show('Hello there!', 'long', 'center', function(a){console.log('toast success: ' + a)}, function(b){alert('toast error: ' + b)})">Toast show long center</button> <button onclick="window.plugins.toast.show('Hello there!', 'long', 'center', function(a){console.log('toast success: ' + a)}, function(b){alert('toast error: ' + b)})">Toast show long center</button>
``` ```
### Hiding a Toast
In case you want to hide a Toast manually, call this:
```js
function hide() {
// this function takes an optional success callback, but you can do without just as well
window.plugins.toast.hide();
}
```
### WP8 quircks ### WP8 quircks
The WP8 implementation needs a little more work, but it's perfectly useable when you keep this in mind: The WP8 implementation needs a little more work, but it's perfectly useable when you keep this in mind:
* You can't show two Toasts simultaneously. * You can't show two Toasts simultaneously.