Skip to content

chejdj/social_share

Repository files navigation

social_share

A plugin supports variety of sharing contents and sharing platforms.Maybe it is the simplest share tools.

Features

Platforms Content OS
wechat Text/Image/Music/Video/WebPage/File Android/iOS
Facebook Text/Image/WebView/File Android/iOS
Line Text/Image/File Android/iOS
Twiter Text/Image/File Android/iOS
WhatsApp Text/Image/File Andorid/iOS
SystemShare --- ---

Usage

iOS

config in Info.plist file

<array>
		<string>fb</string>
		<string>fbauth</string>
		<string>weixin</string>
		<string>weixinULAPI</string>
		<string>fbapi20150629</string>
		<string>fbapi20160328</string>
		<string>fbapi20130214</string>
		<string>fbapi</string>
		<string>fb-messenger-share-api</string>
		<string>fbauth2</string>
		<string>fbshareextension</string>
		<string>twitter</string>
		<string>whatsapp</string>
		<string>line</string>
</array>

reigster

only should config wechat platform. The appId and secretKey is from WechatOpenPlatform. Other platform no need.

 LaShareRegister register = LaShareRegister();
    register.setupWechat(appId, secretKey, universalLink); //only need wechat 
    LaSharePlugin.registerPlatforms(register);

start share

  • construct share data
LaShareParamsBean generateBean() {
        return LaShareParamsBean(
              contentType: LaShareContentTypes.webpage,
              platform: LaSharePlatforms.whatsApp,
              webUrl: webUrl,
              title: title,
              text: desc,
              imageFilePath: imgFilePath,
            );
    }
  • start share
 LaSharePlugin.share(
          generateBean(),
          notInstallCallBack,
          successCallBack,
          errorCallBack,
        );
  • check App whether install
LaSharePlugin.isClientInstalled(LaSharePlatforms.whatsApp);

Preview

all.png

Attention

  1. iOS wechat image share use the SystemShare because wechat forbidden the image share for foreign company.
  2. You should add some scheme config for accessing outer apps. Refer to example configuration.