未安装应用程序时颤振动态链接打开网页
flutter dynamic links open web page when app is not installed
所以,当用户没有安装移动应用程序时,我想将用户重定向到我在 flutter 中创建的具有特定项目 ID 的网络应用程序
这是我创建动态的代码 link url:
Future createDynamicLink(
BuildContext context,
String title,
String image,
String postId,
) async {
bool short = false;
final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: 'https://helpmechoose.page.link',
link: Uri.parse('https://helpmechoose.page.link/dynamiclink/?id=$postId'),
androidParameters: AndroidParameters(
packageName: 'com.app.helpmechoose',
minimumVersion: 0,
),
socialMetaTagParameters:
SocialMetaTagParameters(title: title, imageUrl: Uri.parse(image)),
dynamicLinkParametersOptions: DynamicLinkParametersOptions(
shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short,
),
iosParameters: IosParameters(
bundleId: 'com.app.ioshelpmechoose',
minimumVersion: '0',
),
);
Uri url;
if (short) {
final ShortDynamicLink shortLink = await parameters.buildShortLink();
url = shortLink.shortUrl;
} else {
Uri longLink = await parameters.buildUrl();
final ShortDynamicLink shortDynamicLink =
await DynamicLinkParameters.shortenUrl(
Uri.parse(longLink.toString() + "&ofl=https://helpmechoose.app/"));
url = shortDynamicLink.shortUrl;
print(url);
}
return url.toString();
}
只需添加 => fallbackUrl: Uri.parse(''),
androidParameters: AndroidParameters(
packageName: 'com.app.helpmechoose',
minimumVersion: 0,
fallbackUrl: Uri.parse('https://helpmechoose.page.link/dynamiclink/?id=$postId'),
),
所以,当用户没有安装移动应用程序时,我想将用户重定向到我在 flutter 中创建的具有特定项目 ID 的网络应用程序
这是我创建动态的代码 link url:
Future createDynamicLink(
BuildContext context,
String title,
String image,
String postId,
) async {
bool short = false;
final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: 'https://helpmechoose.page.link',
link: Uri.parse('https://helpmechoose.page.link/dynamiclink/?id=$postId'),
androidParameters: AndroidParameters(
packageName: 'com.app.helpmechoose',
minimumVersion: 0,
),
socialMetaTagParameters:
SocialMetaTagParameters(title: title, imageUrl: Uri.parse(image)),
dynamicLinkParametersOptions: DynamicLinkParametersOptions(
shortDynamicLinkPathLength: ShortDynamicLinkPathLength.short,
),
iosParameters: IosParameters(
bundleId: 'com.app.ioshelpmechoose',
minimumVersion: '0',
),
);
Uri url;
if (short) {
final ShortDynamicLink shortLink = await parameters.buildShortLink();
url = shortLink.shortUrl;
} else {
Uri longLink = await parameters.buildUrl();
final ShortDynamicLink shortDynamicLink =
await DynamicLinkParameters.shortenUrl(
Uri.parse(longLink.toString() + "&ofl=https://helpmechoose.app/"));
url = shortDynamicLink.shortUrl;
print(url);
}
return url.toString();
}
只需添加 => fallbackUrl: Uri.parse(''),
androidParameters: AndroidParameters(
packageName: 'com.app.helpmechoose',
minimumVersion: 0,
fallbackUrl: Uri.parse('https://helpmechoose.page.link/dynamiclink/?id=$postId'),
),