Flutter, Having some issues in Firebase notification receiving in iOS 17 versions.
While the app is opened Notification is received properly.
But when I put the app in the background or terminate it means the Notification is not received.
But In iOS 15.8.1 receiving the notifications properly.
Is there any issue with iOS 17?
Does anyone face this issue?
I’ve tried adding these functions in Appdelegate.swift, but still faced the issue…
func function(application: UIApplication,
didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
Messaging.messaging().apnsToken = deviceToken
}
Following this thread, I’ve come to know that there was an issue with iOS 17 beta versions. Is this the actual problem or something else? Kindly guide me through…
Thanks in advance
2
Answers
Used the Push Message method for conversion of date time based on the user's timezone. I have fixed this issue by changing the Push Message to the Push Notification method. While using the Push message method it's hard to show the notification while the app is in a Background or Killed state. So Using the Push Notification method is the best way for notification. After that, I faced the issue of notification issue in iOS. For that, in info.plist file change the FirebaseAppDelegateProxyEnabled = NO into FirebaseAppDelegateProxyEnabled = YES.
In iOS, when an app is terminated (i.e., not running in the background), it cannot receive notifications directly. However, you can still handle notifications that were delivered while the app was running in the background or terminated by using the userNotificationCenter(_:didReceive:withCompletionHandler:) method of the UNUserNotificationCenterDelegate.
Here’s how you can handle notifications in Flutter when the app is terminated in iOS:
Set up the UNUserNotificationCenterDelegate in your AppDelegate.swift file:
2.Implement the handle method in your main.dart file to handle notifications received when the app is in the background or terminated:
With this setup, you can handle notifications received while the app is running in the background or terminated. When the app is terminated, the userNotificationCenter(_:didReceive:withCompletionHandler:) method of the UNUserNotificationCenterDelegate will be called, and you can handle the notification accordingly.