Copy to Clipboard with javascript for phonegap

前端 未结 2 655
臣服心动
臣服心动 2021-01-02 09:50

i am developing an app using javascript/mobile-jquery interface for the phonegap platform. Now I have seen so many examples on the web trying to copy to clipboard and unfor

相关标签:
2条回答
  • 2021-01-02 10:16

    e-sushi's instructions didn’t quite work for me.

    To get the plugin running I used the following command:

    phonegap local plugin add https://github.com/VersoSolutions/CordovaClipboard
    

    and then adding the following command in JS:

    cordova.plugins.clipboard.copy(text);
    
    0 讨论(0)
  • 2021-01-02 10:17

    First up: that IE option will not work on Android as PhoneGap uses Webkit (think: Safari and/or Chrome).

    Anyway...

    That file you're looking for (in the "/res/xml/" subdirectory of your project's directory) is called

    config.xml
    

    In there, you have to tell phonegap to load the plugin at compile time like this...

    <gap:plugin name="whatever" value="com.example.whatever" />
    

    If you don't do that, phonegap will simply not include the plugin at compile time, resulting in the fact that your plugin won't work (since it doesn't exist in the compiled apk).

    I haven't used the ClipboardManagerPlugin yet, but according to the docs it should go somewhat like this:

    <gap:plugin name="clipboardmanager" value="com.saatcioglu.phonegap.clipboardmanager.ClipboardManagerPlugin.ClipboardManagerPlugin" />
    

    Please note that you should check the PhoneGap version you're using and if the plugin is compatible with it. Just in case you're not aware of it: not all plugins have been updated to work with PhoneGap 3.x yet. To quote the readme at Github (https://build.phonegap.com/docs/plugins-using): "Unless explicitly stated, most of these plugins will not work with Cordova/PhoneGap 3.x.x out of the box. They will need updating before they can be used via the plugin add interface."

    0 讨论(0)
提交回复
热议问题