2014-04-09 114 views
1

我包括socialsharing插件安装到config.xml文件为:的PhoneGap /科尔多瓦:socialsharing插件不工作

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

(使用科尔多瓦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标签的文本字符串 - 这个变量在这一点上有一个值)

任何建议发生了什么问题?

谢谢你在前进, 克里斯

+1

它是否在控制台日志中提供任何线索? – flauntster

+0

你目前使用哪个平台? –

回答

3

社会共享如你预期插件会工作,所以它看起来像你错过了什么, 检查你的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> 

希望这有助于。

+0

非常感谢 - 但在文件中提到,为了电话使用,没有必要在HTML中包含任何内容,只需在xml中添加一行()如你所说。奇怪的是,它用于之前为我工作,似乎插件的更新不再工作了?有人有相同的经历? – Chris

+0

感谢您的更新..我们有更新中的各种问题..它很好用最新版本推荐的选项。 – Vinith

1

好的,我想通了。 你是对的,SocialSharing插件通过包括线

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

到config.xml的工作简单。 我的问题来自于我发送给共享的文本中的未接受字符,导致程序崩溃。 感谢您的帮助!