[英]Push Notification not received when app is in foreground ios flutter
I have integrated firebase for push notifications in flutter.我已经集成了 firebase 用于在颤振中推送通知。 If the app is in foreground I have displayed a dialog with notification details.如果应用程序在前台,我会显示一个包含通知详细信息的对话框。 I am receiving notifications properly in android.我在 android 中正确接收通知。 Also in iOS notifications are working fine in background and when device is locked.同样在 iOS 中,通知在后台和设备锁定时都可以正常工作。 I have enabled push notifications and background fetch as well.我也启用了推送通知和后台获取。 Any solution for this?有什么解决办法吗? Has anybody faced such issue?有没有人遇到过这样的问题?
I am using this firebase plugin https://pub.dev/packages/firebase_messaging我正在使用这个 firebase 插件https://pub.dev/packages/firebase_messaging
import UserNotifications in AppDelegate.在 AppDelegate 中导入 UserNotifications。
UNUserNotificationCenter.current().delegate = self in didFinishLaunch UNUserNotificationCenter.current().delegate = self in didFinishLaunch
Implement the below the method in AppDelegate.在 AppDelegate 中实现下面的方法。
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping(UNNotificationPresentationOptions) -> Void) { print("Push notification received in foreground.") completionHandler([.alert, .sound, .badge]) }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.