Skip to content

Cordova plugin dialog and alert-box - Helps to use native alert view and it will support both iOS and Android platforms.

License

Notifications You must be signed in to change notification settings

vigneshuvi/cordova-plugin-nativealert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Cordova - Native Alert(Dialog) - Plugin

Simple "Cordova Native Alert(Dialog) Plugin" is Helps to use native dialog views and it will support both iOS and Android platforms.

Features

  • It won't block the Javascript thread.
  • Will get Native alert look.

Platforms

  • iOS
  • Andriod

Steps to install

Create a new Cordova Project

	$ cordova create uvialert com.uviexample.uvialertapp NativeAlert
	$ cd uvialert

Install the plugin using GitHub URL

	$ cordova plugin add  https://github.com/vigneshuvi/cordova-plugin-nativealert.git

Install the plugin via NPM.

	$ cordova plugin add cordova.plugin.nativealert

Edit www/js/index.js and add the following code inside onDeviceReady and save the file.

        var success = function(message) {
            if (message == "Yes") {
                // Write Logout code.
            } else if (message == "No") {
                // Write your code.
            }
            console.log(message);
        }
        
        var failure = function() {
            console.log("Error calling alert Plugin");
        }

        var alertJson = {}
        alertJson ["title"] = "Native Alert";
        alertJson ["message"] = "Are you sure want to logout the app?";
        alertJson ["okButton"] = "Yes";
        alertJson ["cancelButton"] = "No";
        setTimeout(function() { 
        	nativealert.showAlert(JSON.stringify(alertJson), success, failure); 
        }, 3000);

Add platforms

	$ cordova platform add android
	$ cordova prepare 

	$ cordova platform add ios
	$ cordova prepare ios

Build the code

	$ cordova build     

Run the code

	$ cordova run 

More Info

For more information on setting up Cordova see the documentation

For more info on plugins see the Plugin Development Guide


Do you like it?

Do you like this repo? Share it on Twitter, Facebook, Google+ or anywhere you like so that more of us can use it and help. Thanks!

Created by Vignesh

About

Cordova plugin dialog and alert-box - Helps to use native alert view and it will support both iOS and Android platforms.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published