Flutter IOS Duplicate plugin key: SocialSharePlugin

1.6k views Asked by At

I am using two different share plugins in my flutter project. One plugin social_share_plugin and other is social_share . Both are used to share content on social media. Due to limitation of one plugin i have to use both. But i am getting 'Duplicate plugin key: SocialSharePlugin'error when i run the project on IOS device. it is working fine on android device.

 var s = await SocialSharePlugin.shareToFeedFacebookLink(
                    quote: 'Meeting',
                    url: shareLink,
                  );

and other plugin is used like

await SocialShare.shareTwitter(
                      shareText,
                      hashtags: ["meetup"],
                      url: shareLink,
                      trailingText: '#meeting',
                    );
              
2

There are 2 answers

1
Karen On

The issue is social_share uses the same class name as social_share_plugin (they both have SocialSharePlugin). To resolve this, I forked the social_share package and changed every instance of SocialSharePlugin to SocialShare, including the file names.

Here's my forked repo if you would like to use or view: https://github.com/kaarens93/social_share (I have a lot of 'unresolved reference' errors that I'm still in the process of fixing but unless you want to build the package, you shouldn't run into any issues implementing into your project)

0
us_david On

I ended up remove SocialShare completely from the project, and use flutter_share_me and SocialSharePlugin. I found Social_Share_plugin is the only one that works with Ins (and Facebook). None of the other packages worked in this aspect. However, with version 0.4 of SocialSharePlugin you need add Facebook api token to your info.plist file since the FBSDK used by SocialSharePlugin requires this token since version 13+. This change was not documented by 0.4 SocialSharePlugin.