EddyVerbruggen / SocialSharing-PhoneGap-Plugin

👨‍❤️‍💋‍👨 Cordova plugin to share text, a file (image/PDF/..), or a URL (or all three) via the native sharing widget
MIT License
1.78k stars 910 forks source link

canShareVia('whatsapp') says no, but shareViaWhatsApp works? #575

Open arielweinberger opened 8 years ago

arielweinberger commented 8 years ago

Hello. I am using the plugin on Ionic. So I used the default code provided to check if sharing is possible within certain platforms.

<button onclick="window.plugins.socialsharing.canShareVia('com.tencent.mm/com.tencent.mm.ui.tools.ShareToTimeLineUI', 'msg', null, img, null, function(e){alert(e)}, function(e){alert(e)})">is WeChat available on Android?</button>
<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>
// this one requires whitelisting of whatsapp:// on iOS9 in your .plist file
<button onclick="window.plugins.socialsharing.canShareVia('whatsapp', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is WhatsApp available?</button>
<button onclick="window.plugins.socialsharing.canShareVia('sms', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is SMS available?</button>
<button onclick="window.plugins.socialsharing.canShareVia('instagram', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is Instagram available?</button>
<!-- Email is a different beast, so I added a specific method for it -->
<button onclick="window.plugins.socialsharing.canShareViaEmail(function(e){alert(e)}, function(e){alert(e)})">is Email available?</button>

For apps like Instagram and WhatsApp I get "not available", but Instagram and WhatsApp are installed on the device.

I am running iOS 9.

Any ideas?

arielweinberger commented 8 years ago

Solved by adding 'whatsapp' and 'instagram' to the LSApplicationQuriesSchemes array in info.plist.

Still wondering, is there any way to add values to this array via Cordova's config.xml?

erperejildo commented 8 years ago

I'm facing the same issue. Where is LSApplicationQuriesSchemes to add that info?

natronite commented 7 years ago

To add entries to LSApplicationQueriesSchemes in the plist file use the cordova-custom-config plugin. According to the documentation you would add whatsapp and instagram like so:

<platform name="ios">
   ...
   <config-file parent="LSApplicationQueriesSchemes" target="*-Info.plist">
      <array>
         <string>whatsapp</string>
         <string>instagram</string>
      </array>
   </config-file>
</platform>

By the way. It is also noted in the social sharing documentation.

sohanpc commented 6 years ago

Yes i got same issue on android canShareVia('whatsapp') says no, but shareViaWhatsApp works . any solution ?