firebase_dynamic_links 0.0.4 firebase_dynamic_links: ^0.0.4 copied to clipboard
Flutter plugin for Google Dynamic Links for Firebase, an app solution for creating and handling links across multiple platforms.
Google Dynamic Links for Firebase #
A Flutter plugin to use the Google Dynamic Links for Firebase API.
For Flutter plugins for other Firebase products, see FlutterFire.md.
Note: This plugin is still under development, and some APIs might not be available yet. Feedback and Pull Requests are most welcome!
Usage #
To use this plugin, add firebase_dynamic_links
as a dependency in your pubspec.yaml file. You must also configure firebase dynamic links for each platform project: Android and iOS (see the example folder or https://codelabs.developers.google.com/codelabs/flutter-firebase/#4 for step by step details).
Create Dynamic Links #
You can create short or long Dynamic Links with the Firebase Dynamic Links Builder API. This API accepts either a long Dynamic Link or an object containing Dynamic Link parameters, and returns a URL like the following example:
https://abc123.app.goo.gl/WXYZ
You can create a Dynamic Link programmatically by setting the following parameters and getting the DynamicLinkParameters.url parameter.
final DynamicLinkParameters components = new DynamicLinkParameters(
domain: 'abc123.app.goo.gl',
link: Uri.parse('https://example.com/'),
androidParameters: new AndroidParameters(
packageName: 'com.example.android',
minimumVersion: 125,
),
iosParameters: new IosParameters(
bundleId: 'com.example.ios',
minimumVersion: '1.0.1',
appStoreId: '123456789',
),
googleAnalyticsParameters: new GoogleAnalyticsParameters(
campaign: 'example-promo',
medium: 'social',
source: 'orkut',
),
itunesConnectAnalyticsParameters: new ItunesConnectAnalyticsParameters(
providerToken: '123456',
campaignToken: 'example-promo',
),
socialMetaTagParameters: new SocialMetaTagParameters(
title: 'Example of a Dynamic Link',
description: 'This link works whether app is installed or not!',
),
);
final Uri dynamicLink = await components.buildUrl();
To create a short Dynamic Link, build DynamicLinkParameters the same way, but use the DynamicLinkParameters.shortUrl parameter.
final ShortDynamicLink shortDynamicLink = await components.buildShortLink();
final Uri shortUrl = shortDynamicLink.shortUrl;
To shorten a long Dynamic Link, use the DynamicLinkParameters.shortenUrl method.
final ShortDynamicLink shortenedLink = await DynamicLinkParameters.shortenUrl(
Uri.parse('https://abc123.app.goo.gl/?link=https://example.com/&apn=com.example.android&ibn=com.example.ios'),
new DynamicLinkParametersOptions(ShortDynamicLinkPathLength.short),
);
final Uri shortUrl = shortenedLink.shortUrl;
Getting Started #
See the example
directory for a complete sample app using Google Dynamic Links for Firebase.