搜尋套件、儲存庫與 APP 分類

套件詳情v1.2.3

social_sharing_plus

一個用於將內容、圖片和影片分享至 Facebook、Twitter、LinkedIn、WhatsApp、Reddit 和 Telegram 等社群媒體平台的 Flutter 插件。

AndroidiOS
近 30 天下載
9300
喜歡數
59
Pub 分數
150

安裝套件

flutter pub add social_sharing_plus

套件介紹

根據套件公開資料產生的選型評估,僅供參考。

一個 Flutter 插件,可實現無縫分享文字、圖片和影片至 Facebook、Twitter、LinkedIn、WhatsApp、Reddit 和 Telegram 等主流社群媒體平台。專為 Android 和 iOS 設計,透過一致的 API 簡化跨平台社交整合。該插件處理平台特定的分享意圖,並提供對原生分享對話方塊的可靠存取。支援簡單分享以及自訂訊息和深度連結等進階設定。

適用情境

  • 分享應用內容到社交網絡
  • 在使用者產生的內容中嵌入社交分享
  • 整合社群或回饋功能
  • 在應用內實現快速內容分發
  • 支援多平台社交推廣

主要特色

  • 對 Android 和 iOS 的跨平台支援
  • 目標平台上的原生共享對話框
  • 支援文字、圖片和影片
  • 輕鬆整合,設定簡單
  • 處理平台特定的共享行為
  • 可擴展以支援未來的社群媒體新增

適合對象

  • 需要社交分享功能的應用
  • 內容驅動的應用程式
  • 使用者參與工具
  • 面向全球受眾的移動應用
  • 尋求輕量級共享解決方案的開發者

使用建議

  • 需要平台特定的設定(例如,Android 清單項目)
  • 僅限支援的平台和應用
  • 某些設備可能需要使用者權限
  • 依賴外部應用程式已安裝
  • 不支援內建的分享事件分析

原始 README

以下為關聯原始碼儲存庫的 README 原文快照,最新內容請造訪原始碼儲存庫。

social_sharing_plus is a Flutter plugin that allows you to share content, images and videos to various social media platforms like Facebook, Twitter, LinkedIn, WhatsApp, Reddit, and Telegram. This package provides a simple and unified interface for sharing across different apps, handling the nuances and differences of each platform.

🚀 Exciting News! You can now share multiple images and videos with text(optional)! 📸🎥

Table of contents

Setup

social_sharing_plus is supported on Android and iOS platforms. On the Android side, queries are made with the package names of the respective apps. This requires the addition of some Android-specific code.

Android (click to expand)

Add queries for app packages

You need to add the following queries to your app's AndroidManifest.xml file to ensure proper redirection to the respective social media apps:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">

    <queries>
        <!-- Query for Facebook -->
        <package android:name="com.facebook.katana" />
        <!-- Query for Twitter -->
        <package android:name="com.twitter.android" />
        <!-- Query for LinkedIn -->
        <package android:name="com.linkedin.android" />
        <!-- Query for Reddit -->
        <package android:name="com.reddit.frontpage" />
        <!-- Query for WhatsApp -->
        <package android:name="com.whatsapp" />
        <!-- Query for Telegram -->
        <package android:name="org.telegram.messenger" />
    </queries>

    <application>
         <!-- ... -->
    </application>
</manifest>

Media Sharing and Media Provider

This provides a specific file provider so that it can share files with other applications. To provide this functionality, you need to create an XML folder under the android>app>src>main>res folder and name it filepaths.xml. Then add the following code to the filepaths.xml file:

<?xml version="1.0" encoding="utf-8"?>
<paths xmlns:android="http://schemas.android.com/apk/res/android">
    <cache-path name="cache" path="." />
    <external-path name="external" path="." />
</paths>

This XML file specifies what types of files your file provider can provide. Then add a <provider> tag in your AndroidManifest.xml file like this:

<provider
    android:name="androidx.core.content.FileProvider"
    android:authorities="${applicationId}.fileprovider"
    android:exported="false"
    android:grantUriPermissions="true">
    <meta-data
        android:name="android.support.FILE_PROVIDER_PATHS"
        android:resource="@xml/filepaths" />
</provider>

This <provider> tag specifies the authorization of your file provider and what file paths it provides. The android:authorities attribute specifies the identity of your file provider, and the ${applicationId}.fileprovider value uses your application's credentials. This ensures the security of your application while allowing other applications to access files.

iOS (click to expand)

No special configuration is needed for iOS.


dependencies:
  social_sharing_plus: ^1.2.3
Usage
import 'package:social_sharing_plus/social_sharing_plus.dart';

static const SocialPlatform platform = SocialPlatform.facebook;
String? _mediaPath; // add image or video path
List<String> _mediaPaths = []; // add image or video paths
bool isMultipleShare = true;

isMultipleShare
    ? await SocialSharingPlus.shareToSocialMediaWithMultipleMedia(
        platform,
        media: _mediaPaths,
        content: content,
        isOpenBrowser: false,
        onAppNotInstalled: () {
          ScaffoldMessenger.of(context)
            ..hideCurrentSnackBar()
            ..showSnackBar(SnackBar(
              content: Text('${platform.name.capitalize} is not installed.'),
            ));
        },
      )
    : await SocialSharingPlus.shareToSocialMedia(
        platform,
        content,
        media: _mediaPath,
        isOpenBrowser: true,
      );

Properties

  • shareToSocialMedia:
Properties Required Default Description
socialPlatform true Platform you want to share on
content true Any text you want to share
media false The image or video you want to share
isOpenBrowser false true If the relevant application is not installed, it redirects to the link (browser) of the relevant application.
onAppNotInstalled false This method works if the application is not installed and the isOpenBrowser value is set to false. (For example: Showing a Snackbar like "The application is not installed on your device."...)
  • shareToSocialMediaWithMultipleMedia:
Properties Required Default Description
socialPlatform true Platform you want to share on
content false Any text you want to share
media true The image or video you want to share
isOpenBrowser false true If the relevant application is not installed, it redirects to the link (browser) of the relevant application.
onAppNotInstalled false This method works if the application is not installed and the isOpenBrowser value is set to false. (For example: Showing a Snackbar like "The application is not installed on your device."...)
Screenshots
Dart Version
  sdk: '>=2.17.0 <4.0.0'
Issues

Please file any issues, bugs, or feature requests as an issue on our GitHub page.

Contribute

If you would like to contribute to the plugin (e.g. by improving the documentation, solving a bug, or adding a cool new feature), please carefully review our contribution guide and send us your pull request.

Author

This social_sharing_plus plugin for Flutter is developed by Bedirhan Sağlam. You can contact me at <bedirhansaglam270@gmail.com>

License

MIT

所屬分類

依賴

依賴清單 1 項

  • plugin_platform_interface^2.0.2

原始碼儲存庫

使用此套件的專案

暫無相關資料。