iOS custom foreground push notification
Этот контент еще не доступен на вашем языке.
Starting from version 6.10.0, you can integrate the PushwooshForegroundPush
module to customize foreground push notifications when native iOS system alerts are disabled.
1. Disable native foreground push alerts
Anchor link toAdding Pushwoosh_SHOW_ALERT = false
to your Info.plist
.
<key>Pushwoosh_SHOW_ALERT</key><false/>
2. Integrating the PushwooshForegroundPush
Module
Anchor link toSwift Package Manager

Cocoapods
# Uncomment the next line to define a global platform for your project# platform :ios, '13.0'
target 'MyApp' do # Comment the next line if you don't want to use dynamic frameworks use_frameworks!
pod 'PushwooshXCFramework' pod 'PushwooshFramework/PushwooshForegroundPush'
end
3. Add PushwooshForegroundPush
Configuration in AppDelegate
Anchor link toimport UIKitimport PushwooshFrameworkimport PushwooshForegroundPush
@mainclass AppDelegate: UIResponder, UIApplicationDelegate, PWMessagingDelegate, PWForegroundPushDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
Pushwoosh.ForegroundPush.foregroundNotificationWith(style: .style1, duration: 5, vibration: .notification, disappearedPushAnimation: .balls)
Pushwoosh.ForegroundPush.delegate = self
return true }
func pushwoosh(_ pushwoosh: Pushwoosh, onMessageReceived message: PWMessage) { if let payload = message.payload { // Pushwoosh method Pushwoosh.ForegroundPush.showForegroundPush(userInfo: payload) } }}
Using foregroundNotificationWith
Method
The foregroundNotificationWith method allows you to display a custom foreground push notification with configurable style, duration, and haptic feedback.
Method Signature (Swift / Objective-C):
@objcstatic func foregroundNotificationWith( style: PWForegroundPushStyle, duration: Int, vibration: PWForegroundPushHapticFeedback, disappearedPushAnimation: PWForegroundPushDisappearedAnimation)
Parameters:
style
(PWForegroundPushStyle
)
- Currently, only style1 is available.
duration
(Int
)
- Specifies how long the notification will be displayed before disappearing (in seconds).
vibration
(PWForegroundPushHapticFeedback
)
- Controls the haptic feedback when the notification is shown. Available options:
case none // No vibrationcase light // Light vibrationcase medium // Medium vibrationcase heavy // Heavy vibrationcase soft // Soft vibrationcase rigid // Rigid vibrationcase notification // Standard notification vibration
disappearedPushAnimation
(PWForegroundPushDisappearedAnimation
)
- Push disappearance animation
case balls = 0case regularPush
4. Implementing didTapForegroundPush
Delegate Method
Anchor link toTo handle user taps on custom foreground push notifications, implement the PWForegroundPushDelegate
protocol method:
// Handle tap on foreground pushfunc didTapForegroundPush(_ userInfo: [AnyHashable : Any]) { print("Foreground custom push: \(userInfo)")
// Perform any action, e.g., navigate to a specific screen // navigateToScreen(for: userInfo)}
Notes:
- This method is called when the user taps on a custom foreground push.
- userInfo contains the payload of the notification.
- Make sure to set
Pushwoosh.ForegroundPush.delegate = self
after configuration.
5. Optional Parameters for Customizing Foreground Push Notifications
Anchor link toThe PushwooshForegroundPush
module provides several optional parameters to customize the appearance and behavior of your foreground push notifications. These can be set globally via static properties.
Property | Type | Description | Default |
---|---|---|---|
useLiquidView | Bool | Use Liquid Glass view on iOS 26. | false |
gradientColors | [UIColor]? | Optional array of colors for a gradient background. | nil |
backgroundColor | UIColor? | Background color for the push. If nil and gradientColors is not set, the default gradient is used. | Default system gradient |
usePushAnimation | Bool | Whether to animate the push when shown. | true |
titlePushColor | UIColor? | Color of the notification title text. Defaults to system white if nil. | white |
messagePushColor | UIColor? | Color of the notification message text. Defaults to system white if nil. | white |
titlePushFont | UIFont? | Font of the notification title text. Defaults to system font if nil. | Default system font |
messagePushFont | UIFont? | Font of the notification message text. Defaults to system font if nil. | Default system font |
Summary:
- Swift 5.13+ + iOS 26 → Liquid Glass
- Swift 5.13+ + iOS < 26 → Standard UIView
- Swift < 5.13 → Always blurred view (no Liquid Glass support)
Example Usage:
Pushwoosh.ForegroundPush.useLiquidView = truePushwoosh.ForegroundPush.gradientColors = [.red, .orange, .yellow]Pushwoosh.ForegroundPush.titlePushColor = .redPushwoosh.ForegroundPush.messagePushColor = .greenPushwoosh.ForegroundPush.backgroundColor = .blackPushwoosh.ForegroundPush.titlePushFont = .boldSystemFont(ofSize: 22)Pushwoosh.ForegroundPush.messagePushFont = .italicSystemFont(ofSize: 15)Pushwoosh.ForegroundPush.usePushAnimation = false
6. Example of Foreground Push
Anchor link toThis example demonstrates how to display a custom foreground push notification with title
, message
, cards
, and GIF animation
.





That’s it. You have successfully configured custom foreground push notifications in iOS with Pushwoosh.