Reputation: 23
I have used "SocialSharing" plugin in my phonegap application to share on facebook. It is working fine if facebook application is installed on android device. But if application is not installed it gives me error like "Share via Twiiter error: com.android.bluetooth,com.android.mms".
How to check is there facebook application installed or not on android device?
I have used below code to share on facebook via "SocialSharing" plugin:
window.plugins.socialsharing.shareViaFacebook("Sample text", null, null, function() {console.log('Share via Facebook success')}, function(errormsg){console.log('Share via Facebook error: '+errormsg)});
Thanks in advance
Upvotes: 2
Views: 1663
Reputation: 8301
If you are using this plugin than it already has option for checking whether Facebook or Other application is installed or not using this:
<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>
<button onclick="window.plugins.socialsharing.canShareVia('com.facebook.katana', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is facebook available on Android?</button>
First check using canShareVia function whether Facebook is installed & then use shareVia function..
Check plugin doc for more detail..
Upvotes: 4