我将 socialsharing 插件包含到 config.xml 中:
<gap:plugin name="nl.x-services.plugins.socialsharing" />
(使用 cordova v. 3.3.1)
在我的 html 中,我包括:
<script src="phonegap.js"></script>
or
<script src="cordova.js"></script>
现在调用时:
function shareReport() {
window.plugins.socialsharing.share(mytext);
}
通过一个按钮:
onclick="shareReport()"
程序突然停止并关闭。 (“mytext”是一个全局变量,它填充了一个包含 html 标签的文本字符串 - 这个变量此时有一个值)
有什么问题的建议吗?
先谢谢你, 克里斯
最佳答案
Social sharing Plugin 将按您预期的方式工作,所以看起来您错过了什么, 检查您的 XML 中的以下字段,
<!-- for iOS -->
<feature name="SocialSharing">
<param name="ios-package" value="SocialSharing" />
</feature>
<!-- for Android -->
<feature name="SocialSharing">
<param name="android-package" value="nl.xservices.plugins.SocialSharing" />
</feature>
<!-- for Windows Phone -->
<feature name="SocialSharing">
<param name="wp-package" value="SocialSharing"/>
</feature>
AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
检查你的脚本,
<script type="text/javascript" src="js/SocialSharing.js"></script>
这是必须的,
<gap:plugin name="nl.x-services.plugins.socialsharing" version="4.0" />
试驾,
<button onclick="window.plugins.socialsharing.canShareVia('com.apple.social.facebook', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is facebook available on iOS?</button>
希望这对您有所帮助。
关于javascript - Phonegap/ Cordova : socialsharing plugin not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22952918/