Reputation: 325
Is there a way to post and show local notifications in the foreground? If not, is there a way to "fake it"? I need to make an iOS appear like an Android app, which does have notifications in the foreground.
Upvotes: 1
Views: 2521
Reputation: 312
For iOS 10 and next you can use UNUserNotificationCenterDelegate and see this post for more information. If you app run on 8 or 9 ios you should use 3d party libs (you can search)
Sample: Add it to your delegate methods in the AppDelegate and conform to this protocol - UNUserNotificationCenterDelegate
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
completionHandler([.alert,.badge])
}
Upvotes: 3