gpt4 book ai didi

firebase - 为什么 Firebase 动态链接总是空的?

转载 作者:行者123 更新时间:2023-12-05 08:10:40 24 4
gpt4 key购买 nike

我通过 class DynamicLinkService 中的 createDynamicLink 创建了一个动态链接,之后我使用 retrieveDynamicLink 读取链接从android浏览器打开的,但是它打印它是空的,因此它不进入if并且不推送到if内的另一个路由

class DynamicLinkService {
Future<void> retrieveDynamicLink(BuildContext context) async {
try {
final PendingDynamicLinkData? data =
await FirebaseDynamicLinks.instance.getInitialLink();
final Uri? deepLink = data?.link;
print("deepLink: $deepLink");

if (deepLink != null) {
print("deepLink If: $deepLink");
String deepLinks = deepLink.toString();
Navigator.of(context).push(MaterialPageRoute(
builder: (context) => linkInvitacionScreen(deepLinks)));
}
} catch (e) {
print(e.toString());
}
}

Future<String> createDynamicLink(String groupID) async {
final DynamicLinkParameters parameters = DynamicLinkParameters(
uriPrefix: 'https://notforget.page.link/',
link: Uri.parse(
'https://notforget.com/groupid?$groupID'),
androidParameters: const AndroidParameters(
packageName: 'com.example.not_forget_flutter',
minimumVersion: 1,
),
);

final ShortDynamicLink shortDynamicLink =
await FirebaseDynamicLinks.instance.buildShortLink(parameters);
final Uri shortUrl = shortDynamicLink.shortUrl;

print(shortUrl);
return shortUrl.toString();
}
}

AndroidManifest 的意图过滤器

<activity
android:name=".MainActivity"
android:exported="true"
android:launchMode="singleTop"
android:theme="@style/LaunchTheme"
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode"
android:hardwareAccelerated="true"
android:windowSoftInputMode="adjustResize">
<meta-data
android:name="io.flutter.embedding.android.NormalTheme"
android:resource="@style/NormalTheme"
/>
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
<!-- Deep linking -->
<meta-data android:name="flutter_deeplinking_enabled" android:value="true" />
<intent-filter android:autoVerify="true">
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="http" android:host="notforget.page.link" />
<data android:scheme="https" />
</intent-filter>

</activity>

我尝试了各种解决方案,但没有一个让我在 deeplink 中获得值(value),我做错了什么?,谢谢。

最佳答案

将您的主机从 android:host="notforget.page.link"替换为 android:host="notforget.page.link"

关于firebase - 为什么 Firebase 动态链接总是空的?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71443090/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com