Displaying a stock iOS notification banner when your app is open and in the foreground?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
Yes, you can ask iOS to show the standard notification presentation even while your app is in the foreground. The key is that foreground notifications are not shown automatically the same way background notifications are; your app must opt in by implementing the notification center delegate and returning the presentation options you want.
Use UNUserNotificationCenterDelegate
The main hook is:
When a notification arrives while the app is active, iOS calls this delegate method and lets your app decide how to present it.
That tells the system to use the stock foreground presentation instead of silently delivering the notification to the app with no visible banner.
If you omit those presentation options, the notification is still delivered to the app, but no standard banner is shown while the app is active.
Understand the Version-Specific Options
On newer iOS versions, .banner and .list are the standard presentation choices. In older APIs, .alert was the familiar option.
The important conceptual point is the same across versions:
- foreground delivery happens
- the app delegate or notification delegate decides presentation
- the stock UI can still be used if you opt in
So if you are seeing no banner while the app is open, the likely issue is not the payload itself. It is usually that the delegate was not set or the completion handler did not request presentation.
Keep the User Experience in Mind
Just because you can show the stock banner in the foreground does not mean every notification should be shown that way. When the user is already using the app, a banner can be redundant or distracting if the same information is already visible in the current screen.
That means the best foreground policy is often selective:
- show banners for urgent or cross-screen information
- suppress them for content the user is already actively viewing
- pair them with sounds or badges only when the app experience justifies it
The stock banner is available, but your app still owns the presentation decision.
That is why foreground presentation should be treated as part of notification UX design, not just as a technical checkbox.
The API makes the banner possible, but the product decision still belongs to the app.
Common Pitfalls
- Registering notification permissions but forgetting to assign
UNUserNotificationCenter.current().delegate. - Implementing the delegate method but not calling the completion handler with presentation options.
- Expecting foreground notifications to show exactly like background notifications without extra code.
- Showing banners for every in-app event and creating a noisy foreground experience.
- Testing only the permission flow and not the separate code path that controls foreground presentation.
Summary
- iOS can show the stock notification banner while your app is in the foreground.
- You enable that behavior through
UNUserNotificationCenterDelegate. - In
willPresent, return presentation options such as.banner,.list, and.sound. - Foreground banners are opt-in, not automatic.
- Use them deliberately so the active in-app experience stays coherent.
Related reading
- Do fragments really need an empty constructor?
- Do I need all three constructors for an Android custom view?
- Do I need to disable NSLog before release Application?
- Do I set properties to nil in dealloc when using ARC?
- Do remote push notifications require to add UIBackgroundModes in Info.plist?
- Do sealed classes really offer performance benefits?
- Do something every x minutes in Swift
- Do something every x minutes in Swift
.png&w=3840&q=75)
Tackling System Design Interview Problems
A short course that equips you with the skills to approach system design interviews methodically.
Start the free courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.