Closed bau720123 closed 11 years ago
From phonegap build 3.1.0 , you dont need to write-
$.getScript("js/plugins/com.verso.cordova.clipboard/www/clipboard.js");
Use the code in the following way -
var text="Sample Text"; cordova.plugins.clipboard.copy(text);
when I just use http://www.littlebau.com/copy.html but nothing happened too
Make sure the plugin has been properly configured in your project.You can confirm this by checking in the YourProject/res/xml/config.xml , the plugin should be registered in this way:
<feature name="Clipboard">
<param name="android-package" value="com.verso.cordova.clipboard.Clipboard" />
</feature>
Or by running this command from CLI interface:
$ phonegap local plugin list
If properly configured, the plugin should be listed there.
From Phonegap 3.1.0, you dont need to import any specific js files of plugins. Just register them by CLI Interface.
As @gouravkakkar pointed out, it seems that the plugin hasn't been installed properly. You should try reinstalling it.
OK I will try later,really thanks
I tried many many times,it still not work by "phonegap build" 3.1
in phonegap build just like that way https://build.phonegap.com/plugins/67
is it real work by "phonegap build"?
PS,I am very sure that the Clipboard plugin has been install http://www.littlebau.com/clipboard.jpg
Using Phonegap 3.1 in iOS 7, it works just fine for me.
Example:
cordova.plugins.clipboard.copy('some text');
thanks for jprichardson reply did you use "phonegap build" 3.1 or just phonegap 3.1(Eclipse or xcode) ?
phonegap build ios
ok Could you help me to check out your cordova_plugins.js There are some code written by... http://www.littlebau.com/abc.html
is it as same as yours?
Are you building locally or remotely with PhoneGap Build, and for what platform?
remotely
Android,4.03,HTC Sensationa XL iOS,7.0.4,iPad mini
I will try in locally building If I have any problem then ask your again,tks~
I just test the Android 4.1.1 and iOS 7.0.4
this is my "local" index.html code,and I am very sure that my phonegap.js is loaded success and the plugin is install success too http://www.littlebau.com/local.gif
<script src="phonegap.js" type="text/javascript"></script>
<script type="text/javascript">
function local1()
{
var text = "Hello World!";
window.plugins.copy(text);
window.plugins.paste(function (text) { alert(text); });
}
function local2()
{
var text = "Hello World!";
cordova.plugins.copy(text);
cordova.plugins.paste(function (text) { alert(text); });
}
function local3()
{
cordova.plugins.copy('Hello World!');
cordova.plugins.paste(function (text) { alert(text); });
}
</script>
<body>
<a onClick="local1();">local1</a></br></br>
<a onClick="local2();">local2</a></br></br>
<a onClick="local3();">local3</a></br></br>
</body>
no mater I click the local1 or local2 or local3,the alert message never appear
You have to change your commands to cordova.plugins.clipboard.copy
and cordova.plugins.clipboard.paste
.
thanks to @ctrevisan but not work too by phonegap build 3.1....no "alert" message appear I am not lying,this is the apk file,you can extract the apk file by winzip or winrar to see the index.html http://www.littlebau.com/clipboard.apk
by the way my config.xml "android-minSdkVersion" is 11
The sources for the plugin are missing from your project. You should have Clipboard.java under platforms/android/src/com/verso/cordova/clipboard
. This might happen if the platform was added (e.g. compiled for using phonegap) before the plugin was added. Try creating a blank project from the CLI, add the plugin, copy your basic example, and compile.
I don't know how to use the CLI I am just only use "phonegap build" and use you plugin by this address https://build.phonegap.com/plugins/67 anyway...tks~
well~ I finally find a way to solve my problem in phonegap build 3.1
is to use...window,not cordova
window.plugins.clipboard.copy(text);
window.plugins.clipboard.paste(function (text) { alert(text); });
Strange... Anyway, I'm glad it solved your problem :-)
For cordova CLI use cordova.plugins.clipboard.copy and cordova.plugins.clipboard.paste
@bau720123 : hi can you give me a link of your example?
i am getting the same problem with ionic ngCordova i have opened a new issue here https://github.com/VersoSolutions/CordovaClipboard/issues/14
I am using phonegap build 3.1,and very sure that my phonegap.js and clipboard.js are all loaded successfully
but when I use your code and run it...nothing happened and I use Chrome to debug,it said "Cannot call method 'copy' of undefined"
here is my code
http://www.littlebau.com/copy.html