This plugin is used to display toast messages in android device. you can use duration parameter to set how long toast will be display on the device.
var options = [message, duration];
window.plugins.toast.show(successCallback, errorCallback, options);
options should be array and contain following value :-
- message - message which you want to display as toast message.
- duration - It should have the string value either "long" or "short".
cordova plugin add com.shashibadhuk.toast
or
cordova plugin add https://github.com/ShashiBadhuk/shashibadhuk-toast-plugin
- Android
document.addEventListener("deviceready", onDeviceReady, false);
var ToastMessage = {
successCallback: function(response) {
console.log(response);
},
errorCallback : function(error) {
console.error(response);
},
show: function(message, time) {
try {
var options = [message, time];
window.plugins.toast.show(this.successCallback, this.errorCallback, options);
}
catch(err) {
console.log("Toast"+err.message);
}
}
};
function onDeviceReady() {
try {
var message = "Sample Toast Message displayed using shashibadhuk-toast-plugin cordova plugin";
var duration = "long";
ToastMessage.show(message, duration);
}
catch(err) {
console.error(err.message);
}
}
###Output