Coder Social home page Coder Social logo

stef0296 / facebook_deeplinks Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rbcprolabs/facebook_deeplinks

0.0 1.0 0.0 88 KB

A flutter plugin to get facebook deeplinks and transferring them to the flutter application.

License: MIT License

Java 28.98% Ruby 19.92% Swift 13.64% Objective-C 18.38% Dart 19.08%

facebook_deeplinks's Introduction

Facebook deeplinks

A flutter plugin to get facebook deeplinks and transferring them to the flutter application.

Install

dependencies:
  facebook_deeplinks: ^0.1.0

Permission

For Android

Open your android/app/src/main/res/values/strings.xml file and add the following lines (remember to replace [APP_ID] with your actual app ID):

<string name="facebook_app_id">[APP_ID]</string>
<string name="fb_login_protocol_scheme">fb[APP_ID]</string>

You need to declare at least one of the two intent filters in android/app/src/main/AndroidManifest.xml:

<manifest ...>
  <!-- ... other tags -->
  <application ...>
    <activity ...>
      <!-- ... other tags -->

      <!-- Deep Links -->
      <intent-filter>
        <action android:name="android.intent.action.VIEW" />
        <category android:name="android.intent.category.DEFAULT" />
        <category android:name="android.intent.category.BROWSABLE" />
        <!-- Accepts URIs that begin with YOUR_SCHEME://YOUR_HOST -->
        <data
          android:scheme="@string/fb_login_protocol_scheme"
          android:host="[YOUR_HOST]" />
      </intent-filter>
    </activity>
    <!-- Facebook ID -->
    <meta-data
      android:name="com.facebook.sdk.ApplicationId"
      android:value="@string/facebook_app_id" />
    
    <!-- ... other tags -->
  </application>
</manifest>

The android:host attribute is optional for Deep Links.

For iOS

For Custom URL schemes you need to declare the scheme in ios/Runner/Info.plist (or through Xcode's Target Info editor, under URL Types):

<!-- ... other tags -->
<plist>
<dict>
  <!-- ... other tags -->
  <key>CFBundleURLTypes</key>
  <array>
    <dict>
      <key>CFBundleURLSchemes</key>
      <array>
        <string>fb[APP_ID]</string>
      </array>
    </dict>
  </array>
  <key>FacebookAppID</key>
  <string>[APP_ID]</string>
  <key>FacebookDisplayName</key>
  <string>[APP_NAME]</string>
  <!-- ... other tags -->
</dict>
</plist>

This allows for your app to be started from YOUR_SCHEME://ANYTHING links.

Usage

FacebookDeeplinks is singleton class.

Example the code:

import 'dart:async';
import 'dart:io';

import 'package:facebook_deeplinks/facebook_deeplinks.dart';

// ...

  String _deeplinkUrl = 'Unknown';

  Future<void> initPlatformState() async {
    FacebookDeeplinks().onDeeplinkReceived.listen(_onRedirected);
    String initialUrl = await FacebookDeeplinks().getInitialUrl();

    if (!mounted) return;

    _onRedirected(initialUrl);
  }

  void _onRedirected(String url) {
    setState(() {
      _deeplinkUrl = url;
    });
  }

// ...

facebook_deeplinks's People

Contributors

proteye avatar

Watchers

James Cloos avatar

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.