Firebase 消息传递的衍生隔离和主要应用程序 - 如何传递数据(Web)?
Firebase messaging's spawned isolate and main app - how to pass data(Web)?
根据https://firebase.flutter.dev/docs/messaging/usage/
onBackgroundMessage(...) 运行 独立存在。
如何在不使用持久存储的情况下将数据从该隔离(它自动生成并运行顶级函数)传递到主应用程序(sqlite/files)网络平台不支持?
Flutter Web 不支持隔离。您可能查看了错误的文档选项卡。不过,您正在寻找的可能还不受支持。
Web requires you to register a JavaScript Service Worker which runs in the background.
Unfortunately we haven't yet been able to establish a proper way of communicating with the Service Worker and Flutter applications. Right now, all web background code must be executed in the JavaScript Service Worker file.
编辑:
为了在 WebWorkers 和应用程序之间共享数据,您可以尝试使用很棒的 Drift 库(以前称为 Moor)。
You can offload the database to a background thread by using Web Workers. Drift also supports shared workers, which allows you to seamlessly synchronize query-streams and updates across multiple tabs!
您应该能够与后台数据库网络工作者通信并保存您的数据。如果设置正确,这将依次更新您的前端。
也许看看这个例子:https://github.com/simolus3/moor/tree/develop/extras/web_worker_example
根据https://firebase.flutter.dev/docs/messaging/usage/ onBackgroundMessage(...) 运行 独立存在。
如何在不使用持久存储的情况下将数据从该隔离(它自动生成并运行顶级函数)传递到主应用程序(sqlite/files)网络平台不支持?
Flutter Web 不支持隔离。您可能查看了错误的文档选项卡。不过,您正在寻找的可能还不受支持。
Web requires you to register a JavaScript Service Worker which runs in the background.
Unfortunately we haven't yet been able to establish a proper way of communicating with the Service Worker and Flutter applications. Right now, all web background code must be executed in the JavaScript Service Worker file.
编辑:
为了在 WebWorkers 和应用程序之间共享数据,您可以尝试使用很棒的 Drift 库(以前称为 Moor)。
You can offload the database to a background thread by using Web Workers. Drift also supports shared workers, which allows you to seamlessly synchronize query-streams and updates across multiple tabs!
您应该能够与后台数据库网络工作者通信并保存您的数据。如果设置正确,这将依次更新您的前端。
也许看看这个例子:https://github.com/simolus3/moor/tree/develop/extras/web_worker_example