简体   繁体   English

在“SocialSharing”插件中检查是否已安装facebook应用程序以获取phonegap

[英]Check facebook application installed or not in “SocialSharing” plugin for phonegap

I have used "SocialSharing" plugin in my phonegap application to share on facebook. 我在我的phonegap应用程序中使用了“SocialSharing”插件在facebook上分享。 It is working fine if facebook application is installed on android device. 如果facebook应用程序安装在Android设备上,它工作正常。 But if application is not installed it gives me error like "Share via Twiiter error: com.android.bluetooth,com.android.mms". 但是如果没有安装应用程序,它会给我一个错误,比如“通过Twiiter共享错误:com.android.bluetooth,com.android.mms”。

How to check is there facebook application installed or not on android device? 如何检查Android设备上是否安装了facebook应用程序?

I have used below code to share on facebook via "SocialSharing" plugin: 我使用下面的代码通过“SocialSharing”插件在Facebook上分享:

window.plugins.socialsharing.shareViaFacebook("Sample text", null, null, function() {console.log('Share via Facebook success')}, function(errormsg){console.log('Share via Facebook error: '+errormsg)}); window.plugins.socialsharing.shareViaFacebook(“示例文本”,null,null,function(){console.log('通过Facebook成功共享')},function(errormsg){console.log('通过Facebook分享错误:' + ERRORMSG)});

Thanks in advance 提前致谢

If you are using this plugin than it already has option for checking whether Facebook or Other application is installed or not using this: 如果您使用插件,那么它已经有用于检查是否安装了Facebook或其他应用程序的选项:

<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.. 首先使用canShareVia函数检查是否安装了Facebook然后使用shareVia函数..

Check plugin doc for more detail.. 检查插件文档以获取更多详细信息..

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM