2

PhoneGap Build で SocialSharing プラグインを使用しようとしています。

以下をconfig.mlファイルに入れました:

<gap:plugin name="nl.x-services.plugins.socialsharing" version="4.0.8" />

これが私の HTML インデックス ページのサンプルです。

<html>
    <head>
        <script type="text/javascript" src="SocialSharing.js"></script>
    </head>
    <body>
        <section id="landmarks" data-role="page">
            <button onclick="window.plugins.socialsharing.share('My message')">share!</button>
            <button onclick="window.plugins.socialsharing.share('Message only')">message only</button>
            <button onclick="window.plugins.socialsharing.shareViaTwitter('Message via Twitter')">message via Twitter</button>
        </section>
    </body>
</html>

ボタンをタップしても (PhoneGapBuild からアプリをダウンロードした後)、何も起こりません。

何か案は?

4

2 に答える 2

3

このアプリを構築するために、PhoneGap/Cordova コマンド ライン インターフェイスに切り替えることにしました。すると、SocialSharing プラグインが完全に機能し始めました。

ソースを PhoneGap Build にアップロードしたときに、ファイルcordova.jsとファイルを index.html ページに正しくインポートしなかったことが問題だったと思います。SocialSharing.js

cordova.js皆さんへの注意:スクリプトを HTML ページにインポートする最初のスクリプトにすることが重要です。これは、Cordova プラットフォームに依存する関数を誤って使用する可能性があり、cordova.js後でファイルをインポートすると機能が動作しなくなる可能性があるためです。 .

于 2014-06-06T16:40:23.737 に答える
1

cordova 3.6.3 などを使用している場合、同じ問題が発生し、window.plugins によるプラグインの呼び出しが非推奨になり、既に機能していないことがわかりました。

プラグインの所有者に問題を提出し、プラグインを自分で変更しました。プラグインjsのフッターを変更するだけです

--deleted window.plugins.socialsharing....
module.exports= new SocialSharing();

window.plugin などを呼び出さないでください...そしてあなたの js socialsharing=cordova.require("nl.x-services.plugins.socialsharing.SocialSharing"); から 次に、socialsharing.share(...) を使用できます。

于 2014-10-08T08:45:34.470 に答える