패키지, 저장소 및 앱 카테고리 검색

패키지 상세v1.0.2

flutter_social_content_share

이 플러그인은 인스타그램, 페이스북, 이메일, 문자 메시지, 왓츠앱과 같은 소셜 미디어에서 콘텐츠를 공유할 수 있습니다. iOS 및 Android 플랫폼에서 정상적으로 작동합니다.

AndroidiOS
30일 다운로드
49
좋아요
171
Pub 점수
140

패키지 설치

flutter pub add flutter_social_content_share

패키지 개요

공개 정보를 바탕으로 생성한 선택 가이드입니다.

Instagram, Facebook, 이메일, SMS, WhatsApp와 같은 소셜 미디어 플랫폼 간에 콘텐츠를 원활하게 공유할 수 있는 Flutter 플러그인입니다. Android 및 iOS용으로 설계되어 앱에 공유 기능을 최소한의 설정으로 쉽게 통합할 수 있습니다. 플러그인은 네이티브 플랫폼 기능을 활용하여 신뢰할 수 있는 성능과 일관된 사용자 경험을 보장합니다. 소셜 네트워크로 빠르고 쉽게 콘텐츠를 배포해야 하는 앱에 적합합니다.

사용 사례

  • 소셜 미디어에 이미지와 텍스트 공유하기
  • 이메일 또는 문자 메시지를 통해 콘텐츠 보내기
  • 앱에 WhatsApp 공유 통합하기
  • Facebook 및 인스타그램 콘텐츠 공유 활성화
  • 사용자 생성 콘텐츠 배포를 촉진하는 것

주요 기능

  • 크로스 플랫폼 지원 (iOS 및 Android)
  • 다중 공유 대상 지원
  • 텍스트와 이미지를 공유하기 위한 간단한 API
  • 더 높은 신뢰성을 위한 네이티브 통합
  • 가볍고 구현하기 쉬움

적합한 대상

  • 소셜 미디어 앱
  • 콘텐츠 게시 도구
  • 사용자 참여 기능
  • 공유가 필요한 모바일 앱
  • 광범위한 청중에 도달하는 앱

고려 사항

  • Android에서 적절한 권한이 필요합니다
  • 지원되는 플랫폼에 제한됨
  • 딥 링크를 위해 추가 구성이 필요할 수 있습니다
  • 외부 앱의 가용성에 따라 다름
  • 웹 플랫폼 지원 없음

원본 README

연결된 소스 저장소의 README 원문 스냅샷입니다. 최신 내용은 저장소에서 확인하세요.

flutter_social_content_share

Flutter Plugin for sharing contents to social media.

Introduction

It supports both the platforms Android and iOS

It provides you with most of the popular sharing options. With this plugin you can share on instagram stories and facebook stories.

Usage

Android Configuration
Paste the following attribute in the manifest tag in the android/app/src/main/AndroidManifest.xml:
         `xmlns:tools="http://schemas.android.com/tools"`
For example
        <manifest xmlns:android="http://schemas.android.com/apk/res/android"
                xmlns:tools="http://schemas.android.com/tools"
                package="your package...">
Add this piece of code in the manifest/application in the android/app/src/main/AndroidManifest.xml:
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
    <uses-permission android:name="android.permission.SEND_SMS" />

    <meta-data
            android:name="com.facebook.sdk.ApplicationId"
            android:value="@string/facebook_app_id" />

        <provider
            android:name="com.facebook.FacebookContentProvider"
            android:authorities="com.facebook.app.FacebookContentProvider[facebook_app_id]"
            android:exported="false" />
Create a xml file named styles.xml in the app/src/main/res/values/styles.xml folder and paste this code in the file :
<string name="facebook_app_id">xxxxxxxxxx</string>
When targeting Android 11 (API level 30)

When an app targets Android 11 (API level 30) or higher and queries for information about the other apps that are installed on a device, the system filters this information by default. The limited package visibility reduces the number of apps that appear to be installed on a device, from your app's perspective. This Plugin checks if Instagram installed. Because of the above, even with Instagram installed, you will end up with "Instagram app is not installed on your device"-errors as your app is not allowed to see Instagram.

Read this for more background information: https://developer.android.com/training/package-visibility

If you are using Android Gradle plugin 4.1+, your tools should work with the new <queries> declaration. However, older versions of the Android Gradle plugin are not aware of this new element.

How to solve this

In your android/build.gradle file, apply the correct Android Gradle plugin fix, as described on https://android-developers.googleblog.com/2020/07/preparing-your-build-for-package-visibility-in-android-11.html: Change the classpath 'com.android.tools.build:gradle dependency to a dot release version that is compatible with <queries>. E.g.:

buildscript {
    ...
    dependencies {
        // classpath 'com.android.tools.build:gradle:3.5.3'
        classpath 'com.android.tools.build:gradle:3.5.4'
        ...
    }
}
iOS Configuration
Add this to your Info.plist to use share on instagram and facebook story
<key>LSApplicationQueriesSchemes</key>
    <array>
        <string>fbapi</string>
        <string>fbauth</string>
        <string>fbauth2</string>
        <string>fbshareextension</string>
        <string>fbapi20130214</string>
        <string>fbapi20130410</string>
        <string>fbapi20130702</string>
        <string>fbapi20131010</string>
        <string>fbapi20131219</string>
        <string>fbapi20140410</string>
        <string>fbapi20140116</string>
        <string>fbapi20150313</string>
        <string>fbapi20150629</string>
        <string>instagram</string>
        <string>instagram-stories</string>
        <string>whatsapp</string>
    </array>

  <key>NSPhotoLibraryAddUsageDescription</key>
    <string>Allow $(PRODUCT_NAME) access to your photo library to upload your profile picture?</string>
    <key>NSPhotoLibraryUsageDescription</key>
    <string>Allow $(PRODUCT_NAME) access to your photo library to upload your profile picture?</string>

Add this if you are using share on facebook. For this you have to create an app on https://developers.facebook.com/ and get the App ID
<key>FacebookAppID</key>
<string>xxxxxxxxxxxxxxx</string>

<key>FacebookDisplayName</key>
    <string>My App</string>
Add the below code which will help you in opening the facebook on webpage. If your facebook app is not installed in your device."xxxxxxxxxxxxxxx" represents your facebook app id.
<key>CFBundleURLTypes</key>
    <array>
        <dict>
            <key>CFBundleURLSchemes</key>
            <array>
                <string>xxxxxxxxxxxxxxx</string>
            </array>
        </dict>
    </array>

shareOnInstagram
FlutterSocialContentShare.share(
        type: ShareType.instagramWithImageUrl,
        imageUrl:
            "https://post.healthline.com/wp-content/uploads/2020/09/healthy-eating-ingredients-732x549-thumbnail-732x549.jpg");
shareOnFacebook
FlutterSocialContentShare.share(
        type: ShareType.facebookWithoutImage,
        url: "https://www.apple.com",
        quote: "captions");
shareOnSMS
FlutterSocialContentShare.shareOnSMS(
    recipients: ["xxxxxx"], text: "Text appears here");

shareOnEmail
FlutterSocialContentShare.shareOnEmail(
    recipients: ["xxxx.xxx@gmail.com"],
    subject: "Subject appears here",
    body: "Body appears here",
    isHTML: true); //default isHTML: False

shareOnWhatsapp
FlutterSocialContentShare.shareOnWhatsapp(
    number: "xxxxxx", text: "Text appears here");

Example

import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:flutter_social_content_share/flutter_social_content_share.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    try {
      platformVersion = await FlutterSocialContentShare.platformVersion;
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  /// SHARE ON FACEBOOK CALL
  shareOnFacebook() async {
    String result = await FlutterSocialContentShare.share(
        type: ShareType.facebookWithoutImage,
        url: "https://www.apple.com",
        quote: "captions");
    print(result);
  }

  /// SHARE ON INSTAGRAM CALL
  shareOnInstagram() async {
    String result = await FlutterSocialContentShare.share(
        type: ShareType.instagramWithImageUrl,
        imageUrl:
            "https://post.healthline.com/wp-content/uploads/2020/09/healthy-eating-ingredients-732x549-thumbnail-732x549.jpg");
    print(result);
  }

  /// SHARE ON WHATSAPP CALL
  shareWatsapp() async {
    String result = await FlutterSocialContentShare.shareOnWhatsapp(
        number: "xxxxxx", text: "Text appears here");
    print(result);
  }

  /// SHARE ON EMAIL CALL
  shareEmail() async {
    String result = await FlutterSocialContentShare.shareOnEmail(
        recipients: ["xxxx.xxx@gmail.com"],
        subject: "Subject appears here",
        body: "Body appears here",
        isHTML: true); //default isHTML: False
    print(result);
  }

  /// SHARE ON SMS CALL
  shareSMS() async {
    String result = await FlutterSocialContentShare.shareOnSMS(
        recipients: ["xxxxxx"], text: "Text appears here");
    print(result);
  }

  ///Build Context
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Column(
          children: <Widget>[
            Text('Running on: $_platformVersion\n'),
            RaisedButton(
              child: Text("Share to facebook button"),
              color: Colors.red,
              onPressed: () {
                shareOnFacebook();
              },
            ),
            RaisedButton(
              child: Text("Share to instagram button"),
              color: Colors.red,
              onPressed: () {
                shareOnInstagram();
              },
            ),
            RaisedButton(
              child: Text("Share to whatsapp button"),
              color: Colors.red,
              onPressed: () {
                shareWatsapp();
              },
            ),
            RaisedButton(
              child: Text("Share to email button"),
              color: Colors.red,
              onPressed: () {
                shareEmail();
              },
            ),
            RaisedButton(
              child: Text("Share to sms button"),
              color: Colors.red,
              onPressed: () {
                shareSMS();
              },
            ),
          ],
        ),
      ),
    );
  }
}

카테고리

소스 저장소

이 패키지를 사용하는 프로젝트

아직 데이터가 없습니다.