ios - Flutter IOS BackgroundHandler不工作
问题描述
当数据推送消息到达时,我想要做一个后台处理程序(保存在我的 firebase DB 上)。它在 Android 的后台和前台都可以正常工作,但在 IOS 中,当推送通知接收前台工作正常(当应用程序打开时)但在后台(应用程序关闭)不工作时。
void main() async {
await Firebase.initializeApp();
FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
FirebaseMessaging.onMessage.listen((RemoteMessage message) {
print('Got a message whilst in the foreground!');
print('Message data: ${message.data}');
if (message.notification != null) {
print('Message also contained a notification: ${message.notification}');
}
});
runApp(MyApp());
}
Future _firebaseMessagingBackgroundHandler(RemoteMessage message) async {
print('trigger........');
}
解决方案
推荐阅读
- python-3.x - 按列名拼接 Pandas 数据框
- javascript - 为什么两个 if 语句在一个函数中不起作用?
- javascript - Javascript - 原始字符串隐式转换为对象
- php - PHP/Symfony 3:使用完全限定的类名(字符串)来调用实例化的类方法
- html - 我正在尝试在图像中间对齐文本。我不确定我在这里做错了什么
- swift - 当前用户未找到
- python - 如何在 Python 中使用 Matplotlib 绘制直方图以获取概率?
- mysql - 在mysql中获取两个日期之间的数据
- amazon-web-services - S3 签名的 url 在操作期间是否过期?
- sql - 如何使用 SQL Server 合并具有相同 ID 的多行