Search code examples
facebookcordovacordova-pluginsphonegapsocialshare

canShareVia invokes the success callback when it should not - iOS 11.2


Description

When the Facebook app is not installed, canShareVia method should invoke the error callback, which is working perfectly with my iPhone5s running iOS 10.

When I test it on iPhone5s running iOS 11.2, it is always invoking the success callback in both the cases where the Facebook app is installed and Not installed.

App

A Cordova mobile app

Plugin: https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin

Device information

  • iPhone 5s
  • iOS 11.2
  • Facebook app: Not installed

Sample code

window.plugins.socialsharing.canShareVia('com.apple.social.facebook', 'msg', null, null, null, 
function(success) {
   do some stuff....
}, function(error) {
   alert(error); 
});

Please let me know if any work around has been found.


Updated

Found the cause:

This plugin always returns true since iOS11. So we might need another way to detect if there is an app installed and available.


Solution

  • Get it to work with cordova-plugin-appavailability.

    You can implement this way (Appavailability plugin to check Facebook app availability and social sharing plugin to do the actual sharing).

    appAvailability.check(
        'fb://',
        function() {  // Success callback
            window.plugins.socialsharing.shareViaFacebook(...)
        },
        function() {  // Error callback
            console.log('Facebook App is not available');
        }
    );
    

    Though this is a work around but not a fix, this is the only way for now until the fix gets merged to cordova-plugin-x-socialsharing.