In an iOS project, I have implemented the following delegate method to handle Notifications when app is in foregorund:
func userNotificationCenter (_ pNotificationCenter : UNUserNotificationCenter, willPresent pNotification : UNNotification, withCompletionHandler pCompletionHandler : @escaping (UNNotificationPresentationOptions) -> Void) -> Void
{
// When app is in foreground, notification is directly sent to
// the app by invoking this delegate method.
}
When building, I'm getting the warning. But my implementation is correct according to documentation.
Why is this method not recognized as the implementation of the UNUserNotificationCenterDelegate protocol?
This is the warning in text format:
Showing All Issues
<file path & line number>: Instance method 'userNotificationCenter(_:willPresent:withCompletionHandler:)' nearly matches optional requirement 'userNotificationCenter(_:willPresent:withCompletionHandler:)' of protocol 'UNUserNotificationCenterDelegate'
This is the image of the warning:
Am I missing some flag in a compiler setting?
My env: Xcode 15.2, Swift 5.0, Deployment target - iOS 14.0+.