Last active
February 1, 2019 15:21
-
-
Save ponnamkarthik/ccb754b7091c1c49be24795b7f38b669 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'dart:async'; | |
import 'package:firebase_dynamic_links/firebase_dynamic_links.dart'; | |
class DynamicLinks { | |
// create a link with params | |
static Future<Uri> createLinkWithParams(String code) => | |
_getLink('mylink', {'code': code}); | |
// create a short link with params | |
static FutureOr<Uri> _getLink( | |
String category, Map<String, String> args) async { | |
final Uri longLink = await _getParams(category, args).buildUrl(); | |
final ShortDynamicLink shortLink = await DynamicLinkParameters.shortenUrl( | |
longLink, | |
new DynamicLinkParametersOptions(shortDynamicLinkPathLength: ShortDynamicLinkPathLength.unguessable), | |
); | |
return shortLink.shortUrl; | |
} | |
// create a link with all our params and retrun DynamucLinkParameters | |
static DynamicLinkParameters _getParams( | |
String category, Map<String, String> args) => | |
DynamicLinkParameters( | |
domain: 'linkholder.page.link', | |
link: Uri.https('tap.style', category, args), | |
androidParameters: AndroidParameters( | |
packageName: 'com.example.app', | |
), | |
iosParameters: IosParameters(bundleId: 'com.example.app'), | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment