Check facebook app installed or not in "SocialSharing" plugin for phone call

I used the "SocialSharing" plugin in the phonegap app for facebook sharing. It works great if facebook app is installed on android device. But if the app is not installed it gives me an error like "Share via Twiiter error: com.android.bluetooth, com.android.mms".

How to check if facebook app is installed or not on android device?

I 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)});

Thank you in advance

+3


source to share


1 answer


If you are using this plugin, then it already has an option to check if the Facebook app is installed or different or not:

<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 with the canShareVia function if Facebook is installed and then use the shareVia function.

Learn more about the plugin file .

+4


source







All Articles