Flutter firebase 动态链接未监听
我正在尝试在 flutter 应用程序中实现 Firebase 动态链接。当我单击链接时,它会打开应用程序,但不会调用监听函数。
我根据 FlutterFire 一步步重新配置,所以我认为问题不在于配置,但可能在于我使用插件的方式,因为没有关于该插件最新版本的文档。
当我使用其他服务时,Firebase 在我的应用程序中正确初始化。
我正在 android 模拟器上进行测试
我正在尝试使用以下代码监听来自有状态小部件的动态链接
我首先导航到包含此小部件的页面,然后我将应用程序设置为后台,我单击链接,应用程序在同一个地方打开,但没有任何反应。
@override
void initState() {
super.initState();
initLink();
}
void initLink() {
FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) {
print('dynamic link');
print(dynamicLinkData.toString());
// Navigator.pushNamed(context, dynamicLinkData.link.path);
}).onError((error) {
// Handle errors
});
}
I am trying to implement Firebase Dynamic links in a flutter app. When I click on the link it opens the app but doesn't call the listen functions.
I reconfigured step by step according to FlutterFire, so I don't think the issue is in configuration, but maybe in the way I'm using the plugin as there is no documentation on the last version of the plugin.
Firebase is correctly initialised in my app as I'm using other services.
I'm doing tests on android simulator
I'm trying to listen the dynamic link from a stateful widget with the following code
I'm first navigating to the page containing this widget, then I background the app, I click on the link, the app opens at the same place and nothing happens.
@override
void initState() {
super.initState();
initLink();
}
void initLink() {
FirebaseDynamicLinks.instance.onLink.listen((dynamicLinkData) {
print('dynamic link');
print(dynamicLinkData.toString());
// Navigator.pushNamed(context, dynamicLinkData.link.path);
}).onError((error) {
// Handle errors
});
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有一个未解决的问题 https://github.com/FirebaseExtended/flutterfire/issues/8261< /a> 其他一些人也有同样的问题,包括我自己。
目前看来,odlund 发布了至少能让事情再次正常运行的临时解决方案。如果您进行这些更改,监听器应该会再次工作,直到我们有更多的官方修复:
https://github.com/FirebaseExtended/flutterfire/commit/8bb4bee7e678241e75ab37a2bcfa0831426b91fa
There is an open issue here https://github.com/FirebaseExtended/flutterfire/issues/8261 where a few others are having the same problem including myself.
It seems for now the temporary solution to at least getting things working again is posted by odlund. If you make these changes the listener should work again until we have more of an official fix:
https://github.com/FirebaseExtended/flutterfire/commit/8bb4bee7e678241e75ab37a2bcfa0831426b91fa
请将 firebase_dynamic_links 更新至 4.1.1。似乎是 4.1.0 或更早版本的问题,其中 FirebaseDynamicLinks.instance.onLink.listen 不起作用
您无需检查应用程序是否正常在后台或恢复以使其正常工作。
Please update firebase_dynamic_links to 4.1.1. Seems to be an issue with the version 4.1.0 or earlier where FirebaseDynamicLinks.instance.onLink.listen doesn't work
You don't need to check if the app is in the background or resumed for this to work.
这非常有效!
This Works Perfectly!