最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - PhonegapCordova: socialsharing plugin not working - Stack Overflow

programmeradmin0浏览0评论

I included the socialsharing plugin into config.xml as:

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

(using cordova v. 3.3.1)

In my html I include:

<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)

Any suggestions what is going wrong ?

Thank you in advance, Chris

I included the socialsharing plugin into config.xml as:

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

(using cordova v. 3.3.1)

In my html I include:

<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)

Any suggestions what is going wrong ?

Thank you in advance, Chris

Share Improve this question asked Apr 9, 2014 at 4:40 ChrisChris 731 silver badge8 bronze badges 2
  • 1 does it give any clues in the console log? – flauntster Commented Apr 9, 2014 at 4:44
  • what platform you currently use? – Nurdin Commented Apr 9, 2014 at 11:17
Add a ment  | 

2 Answers 2

Reset to default 3

Social sharing Plugin will work as you expected so it looks like you missed something, Check your XML for below fields,

<!-- 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" />

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('.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

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

into 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 !

发布评论

评论列表(0)

  1. 暂无评论