javascript - Phonegap/ Cordova : socialsharing plugin not working

标签 javascript cordova

我将 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/

相关文章:

iOS 自定义方向配置

javascript - Angular RxJS : conditional operator (if else)

javascript - 根据javascript中选定的单选按钮打开弹出框

cordova 构建 ios 但在 'Cannot read property ' toLowerCase' of undefined' 中出错

android - 在 Android 的 Phonegap 应用上播放声音

javascript - 使用 localStorage 在 SenchaTouch/PhoneGap -App 中保存/加载设置并以表单形式显示

javascript - Not 运算符无法处理我的 javascript 代码

javascript - Selenium IDE - 如何创建与今天日期相关的 JavaScript 函数?

javascript - 用于从 html page1 到 page2 存储/传递值的脚本

javascript - 在 Matlab 生产服务器上启用 CORS 时出错