facebook_deeplinks 0.1.0 copy "facebook_deeplinks: ^0.1.0" to clipboard
facebook_deeplinks: ^0.1.0 copied to clipboard

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

example/lib/main.dart

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:facebook_deeplinks/facebook_deeplinks.dart';

// Example deeplink: fb1900783610066589://test
// Android command: $ANDROID_HOME/platform-tools/adb shell 'am start' -a android.intent.action.VIEW -c android.intent.category.BROWSABLE -d "fb1900783610066589://test"
// iOS command: /usr/bin/xcrun simctl openurl booted "fb1900783610066589://test"

void main() => runApp(MyApp());

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

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

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

  Future<void> initPlatformState() async {
    String deeplinkUrl;

    var facebookDeeplinks = FacebookDeeplinks();
    facebookDeeplinks.onDeeplinkReceived.listen(_onRedirected);
    deeplinkUrl = await facebookDeeplinks.getInitialUrl();

    if (!mounted) return;

    _onRedirected(deeplinkUrl);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: <Widget>[
              Text('Deeplink URL: $_deeplinkUrl'),
              RaisedButton(
                child: Text('GET INITIAL URL'),
                onPressed: () async {
                  var deeplinkUrl = await FacebookDeeplinks().getInitialUrl();
                  _onRedirected(deeplinkUrl);
                },
              ),
            ],
          ),
        ),
      ),
    );
  }

  void _onRedirected(String uri) {
    setState(() {
      _deeplinkUrl = uri;
    });
  }
}
6
likes
40
pub points
0%
popularity

Publisher

verified publisherproteye.ru

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

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter

More

Packages that depend on facebook_deeplinks