Giter Site home page Giter Site logo

binsaed / social_share_plugin Goto Github PK

View Code? Open in Web Editor NEW

This project forked from romatroskin/social_share_plugin

0.0 0.0 1.0 132 KB

Social Share to Facebook and Instagram Flutter plugin.

License: BSD 2-Clause "Simplified" License

Ruby 8.31% Objective-C 2.41% Kotlin 30.37% Dart 21.47% Swift 36.92% Java 0.52%

social_share_plugin's Introduction

social_share_plugin

Pub

Social Share to Facebook and Instagram Flutter plugin.

Getting Started

To get things up and running, you'll have to declare a pubspec dependency in your Flutter project. Also some minimal Android & iOS specific configuration must be done, otherise your app will crash.

On your Flutter project

See the installation instructions on pub.

Android

In addition, you need to do the following:

For details on these requirements, see Android - Getting Started.

After you've done that, find out what your Facebook App ID is. You can find your Facebook App ID in your Facebook App's dashboard in the Facebook developer console.

Once you have the Facebook App ID figured out, you'll have to do two things.

First, copy-paste the following to your strings resource file. If you don't have one, just create it.

<your project root>/android/app/src/main/res/values/strings.xml

<?xml version="1.0" encoding="utf-8"?>
<resources>
    <string name="app_name">Your App Name here.</string>

    <!-- Replace "000000000000" with your Facebook App ID here. -->
    <string name="facebook_app_id">000000000000</string>
</resources>

Then you'll just have to copy-paste the following to your Android Manifest and replace 000000000000000 with your Facebook App ID and you also need to set up a ContentProvider in your AndroidManifest.xml where {APP_ID} is your app ID:

<your project root>/android/app/src/main/AndroidManifest.xml

<queries>
    <package android:name="com.twitter.android" />
    <package android:name="com.facebook.katana" />
    <package android:name="com.com.instagram.android" />
</queries>

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

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

<activity android:name="com.facebook.FacebookActivity"
    android:configChanges=
            "keyboard|keyboardHidden|screenLayout|screenSize|orientation"
    android:label="@string/app_name" />

<provider android:authorities="com.facebook.app.FacebookContentProvider{FACEBOOK_APP_ID}"
            android:name="com.facebook.FacebookContentProvider"
            android:exported="true"/>

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

Done!

iOS

Before you add sharing to your app you need to:

  • Add the Facebook SDK for iOS to your mobile development environment
  • Configure and link your Facebook app ID
  • Add your app ID, display name, and human-readable reason for photo access to your app's .plist file.

After you've done that, find out what your Facebook App ID is. You can find your Facebook App ID in your Facebook App's dashboard in the Facebook developer console.

Once you have the Facebook App ID figured out, then you'll just have to copy-paste the following to your Info.plist file, before the ending </dict></plist> tags.

<your project root>/ios/Runner/Info.plist

<key>CFBundleURLTypes</key>
<array>
    <dict>
        <key>CFBundleURLSchemes</key>
        <array>
            <!--
              Replace "000000000000" with your Facebook App ID here.
              **NOTE**: The scheme needs to start with `fb` and then your ID.
            -->
            <string>fb000000000000</string>
        </array>
    </dict>
</array>

<key>FacebookAppID</key>

<!-- Replace "000000000000" with your Facebook App ID here. -->
<string>000000000000</string>
<key>FacebookDisplayName</key>

<!-- Replace "YOUR_APP_NAME" with your Facebook App name. -->
<string>YOUR_APP_NAME</string>

<key>LSApplicationQueriesSchemes</key>
<array>
    <string>instagram</string>
    <string>fbapi</string>
    <string>fb-messenger-share-api</string>
    <string>fbauth2</string>
    <string>fbshareextension</string>
    <string>twitter</string>
</array>

Done!

How do I use it?

Instagram

import 'package:social_share_plugin/social_share_plugin.dart';
File file = await ImagePicker.pickImage(source: ImageSource.gallery);
await SocialSharePlugin.shareToFeedInstagram(path: file.path);

Facebook

import 'package:social_share_plugin/social_share_plugin.dart';
File file = await ImagePicker.pickImage(source: ImageSource.gallery);
await SocialSharePlugin.shareToFeedFacebook(path: file.path);
await SocialSharePlugin.shareToFeedFacebookLink(quote: 'quote', url: 'https://flutter.dev');

Twitter

import 'package:social_share_plugin/social_share_plugin.dart';

await SocialSharePlugin.shareToTwitterLink(text: 'text', url: 'https://flutter.dev');

That's it.

social_share_plugin's People

Contributors

binsaed avatar romatroskin avatar shatha-naami avatar

Forkers

hassanbalousha

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.