Я использую Динамическую ссылку Firebase для своего приложения, чтобы делиться контентом. Динамическая ссылка Firebase работает, если использовать ее стандарт. Но если я конвертирую его в ShortDynamicLink
, я получаю ошибку на своем logcat, как показано ниже:
E/flutter (12337): [ERROR:flutter/lib/ui/ui_dart_state.cc(148)] Unhandled Exception: PlatformException(short_link_error, 400: Cannot shorten a short Dynamic Link: https://alif123.page.link/RtQw/?amv=0&apn=com.valleryatv.vallery&link=https%3A%2F%2Falif123.page.link%2FRtQw%2F [https://firebase.google.com/docs/dynamic-links/rest#create_a_short_link_from_parameters], null)
E/flutter (12337): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:569:7)
E/flutter (12337): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:316:33)
E/flutter (12337): <asynchronous suspension>
E/flutter (12337): #2 MethodChannel.invokeMapMethod (package:flutter/src/services/platform_channel.dart:344:48)
E/flutter (12337): <asynchronous suspension>
E/flutter (12337): #3 DynamicLinkParameters.buildShortLink (package:firebase_dynamic_links/src/dynamic_link_parameters.dart:101:10)
E/flutter (12337): <asynchronous suspension>
E/flutter (12337): #4 ShareContent.shortDynamicLink (package:vallery/src/common/share_dynamic_link.dart:29:64)
E/flutter (12337): <asynchronous suspension>
E/flutter (12337): #5 ShareContent.share (package:vallery/src/common/share_dynamic_link.dart:9:24)
E/flutter (12337): <asynchronous suspension>
E/flutter (12337): #6 _ArticleDetailPageState.build.<anonymous closure> (package:vallery/src/ui/program/detail_program_page.dart:54:30)
E/flutter (12337): #7 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:654:14)
E/flutter (12337): #8 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:729:32)
E/flutter (12337): #9 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:182:24)
E/flutter (12337): #10 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:365:11)
E/flutter (12337): #11 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:275:7)
E/flutter (12337): #12 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:455:9)
E/flutter (12337): #13 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:75:13)
E/flutter (12337): #14 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:102:11)
E/flutter (12337): #15 GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:218:19)
E/flutter (12337): #16 GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:198:22)
E/flutter (12337): #17 GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:156:7)
E/flutter (12337): #18 GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:102:7)
E/flutter (12337): #19 GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:86:7)
E/flutter (12337): #20 _rootRunUnary (dart:async/zone.dart:1136:13)
E/flutter (12337): #21 _CustomZone.runUnary (dart:async/zone.dart:1029:19)
E/flutter (12337): #22 _CustomZone.runUnaryGuarded (dart:async/zone.dart:931:7)
E/flutter (12337): #23 _invoke1 (dart:ui/hooks.dart:263:10)
E/flutter (12337): #24 _dispatchPointerDataPacket (dart:ui/hooks.dart:172:5)
И это мой код:
static shortDynamicLink(String id) async {
// LONG DYNAMIC LINK
final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: Config.dynamicLink,
link: Uri.parse(Config.dynamicLink),
androidParameters: AndroidParameters(
packageName: Config.packageName,
minimumVersion: 0,
),
dynamicLinkParametersOptions: DynamicLinkParametersOptions(
shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short,
),
);
// final Uri url = await parameters.buildUrl();
// CONVERT FROM LONG LINK TO SHORT LINK
final ShortDynamicLink shortDynamicLink = await parameters.buildShortLink();
final Uri url = shortDynamicLink.shortUrl;
//SHORT DYNAMIC LINK
// final ShortDynamicLink shortenedLink =
// await DynamicLinkParameters.shortenUrl(
// Uri.parse(Config.dynamicLink +
// '?link=' + Config.urlShareContent + id +
// '&apn=' + Config.packageName +
// '&amv=0' +
// '&afl=' + Config.urlShareContent + id),
// DynamicLinkParametersOptions(
// shortDynamicLinkPathLength: ShortDynamicLinkPathLength.unguessable),
// );
//
// final Uri url = shortenedLink.shortUrl;
return url.toString();
}
Если я использую только ShortDynamicLink
по-прежнему возникает та же ошибка, что и при конвертации длинной ссылки в ShortDynamicLink
. Но если я использую только длинную ссылку, это работает. Кто-нибудь может мне помочь с этой проблемой?