[英]Phonegap / Cordova: socialsharing plugin not working
I included the socialsharing plugin into config.xml as: 我将社交共享插件包含在config.xml中,如下所示:
<gap:plugin name="nl.x-services.plugins.socialsharing" />
(using cordova v. 3.3.1) (使用cordova v。3.3.1)
In my html I include: 在我的html中,我包括:
<script src="phonegap.js"></script>
or
<script src="cordova.js"></script>
Now when calling: 现在调用时:
function shareReport() {
window.plugins.socialsharing.share(mytext);
}
by a button: 通过一个按钮:
onclick="shareReport()"
the program stops suddenly and closes down. 程序突然停止并关闭。 ("mytext" is a global variable that is populated with a text string containing html tags - this variable has a value at this point)
(“ mytext”是一个全局变量,其中填充了包含html标签的文本字符串-此变量此时具有一个值)
Any suggestions what is going wrong ? 有什么建议出什么问题吗?
Thank you in advance, Chris 克里斯,谢谢你
Social sharing Plugin will work as you expected so it looks like you missed something, Check your XML for below fields, 社交共享插件将按预期工作,因此您似乎错过了一些东西,请检查以下字段的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: AndroidManifest.xml:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
Check your Script, 检查您的脚本,
<script type="text/javascript" src="js/SocialSharing.js"></script>
This is must, 这是必须的
<gap:plugin name="nl.x-services.plugins.socialsharing" version="4.0" />
Try a test drive, 试驾,
<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>
Hope this helps. 希望这可以帮助。
OK, I figured it out. 好,我知道了。 You were right, the SocialSharing plugin works simply by including the line
没错,SocialSharing插件的工作原理如下:
<gap:plugin name="nl.x-services.plugins.socialsharing" />
into config.xml. 进入config.xml。 My problem came from unaccepted characters in the text that I sent for sharing which caused the program crash.
我的问题出在我发送用于共享的文本中不可接受的字符,导致程序崩溃。 Thanks for every help !
多谢您的协助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.