Toast
$ ionic plugin add cordova-plugin-x-toast
Repo: https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin
This plugin allows you to show a native Toast (a little text popup) on iOS, Android and WP8. It's great for showing a non intrusive native notification which is guaranteed always in the viewport of the browser.
Requires Cordova plugin: cordova-plugin-x-toast
. For more info, please see the Toast plugin docs.
Usage
import {Toast} from 'ionic-native';
Toast.show("I'm a toast", 5000, "center").subscribe(
toast => {
console.log(toast);
}
);
Static Methods
show(message, duration, position)
Show a native toast for the given duration at the specified position.
Param | Type | Details |
---|---|---|
message |
string
|
The message to display. |
duration |
string
|
Duration to show the toast, either 'short', 'long' or any number of milliseconds: '1500'. |
position |
string
|
Where to position the toast, either 'top', 'center', or 'bottom'. |
Returns:
Observable
Returns an Observable that notifies first on success and then when tapped, rejects on error.
hide()
Manually hide any currently visible toast.
Returns:
Promise
Returns a Promise that resolves on success.
showWithOptions(options)
Show a native toast with the given options.
Param | Type | Details |
---|---|---|
options |
Object
|
Options for showing a toast. Available options: message The message to display. duration Duration to show the toast, either 'short', 'long' or any number of milliseconds: '1500'. position Where to position the toast, either 'top', 'center', or 'bottom'. addPixelsY Offset in pixels to move the toast up or down from its specified position. |
Returns:
Observable
Returns an Observable that notifies first on success and then when tapped, rejects on error.
showShortTop()
Shorthand for show(message, 'short', 'top')
.
Returns:
Observable
Returns an Observable that notifies first on success and then when tapped, rejects on error.
showShortCenter()
Shorthand for show(message, 'short', 'center')
.
Returns:
Observable
Returns an Observable that notifies first on success and then when tapped, rejects on error.
showShortBottom()
Shorthand for show(message, 'short', 'bottom')
.
Returns:
Observable
Returns an Observable that notifies first on success and then when tapped, rejects on error.
showLongTop()
Shorthand for show(message, 'long', 'top')
.
Returns:
Observable
Returns an Observable that notifies first on success and then when tapped, rejects on error.
showLongCenter()
Shorthand for show(message, 'long', 'center')
.
Returns:
Observable
Returns an Observable that notifies first on success and then when tapped, rejects on error.
showLongBottom()
Shorthand for show(message, 'long', 'bottom')
.
Returns:
Observable
Returns an Observable that notifies first on success and then when tapped, rejects on error.