Question

I am new to phonegap. I wish to implement cop to clipboard functionality in iPhone and android. For this I am using the following clipboard plugin: https://github.com/VersoSolutions/CordovaClipboard

I did the following:

1) in cli i fired: cordova plugin add https://github.com/VersoSolutions/CordovaClipboard

2) added js file in project : <script type="text/javascript" src="js/clipboard.js"></script>

3) on button click:

`case "btnCopy":

                                                        var text = "Hello World!";
                                                        alert(text);
                                                        try{
                                                        window.plugins.clipboard.copy(text);

//                                                        cordova.plugins.clipboard.paste(function (text) { alert(text); });
                                                        }catch(e)
                                                        {
                                                        alert(e);
                                                        }
`

When i run the app, and click on copy button, i get the following alert error:

typeerror 'undefined' is not an object (evaluating 'window.plugins.clipboard')

typeerror 'undefined' is not an object (evaluating 'cordova.plugins.clipboard') // if i use cordova.

I also went through the following link:

https://github.com/VersoSolutions/CordovaClipboard/issues/1

but of no help.

How do i get to get clipboard plugin work? Please help.

Was it helpful?

Solution

I deleted the ios folder(after taking its backup). Then added the plugin, and then recreated the ios platform again cordova platform add ios.

Then in Plugins folder, i added the .h and .m file of the plugin(here it was clipBoard plugin). That's it. It works now.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top