Skip to content

ShashiBadhuk/shashibadhuk-toast-plugin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

shashibadhuk-toast-plugin

If this helps you, don't forget to donate us.

Description

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".

Installation

cordova plugin add com.shashibadhuk.toast
or
cordova plugin add https://github.com/ShashiBadhuk/shashibadhuk-toast-plugin

Supported Platforms

  • Android

Quick Example

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

toast-output