콘텐츠로 건너뛰기

iOS 사용자 지정 포그라운드 푸시 알림

버전 6.10.0부터 PushwooshForegroundPush 모듈을 통합하여 네이티브 iOS 시스템 알림이 비활성화된 경우 포그라운드 푸시 알림을 사용자 지정할 수 있습니다.

1. 네이티브 포그라운드 푸시 알림 비활성화

Anchor link to

Info.plistPushwoosh_SHOW_ALERT = false를 추가합니다.

<key>Pushwoosh_SHOW_ALERT</key>
<false/>

2. PushwooshForegroundPush 모듈 통합하기

Anchor link to

Swift Package Manager

Swift Package Manager에서 PushwooshForegroundPush 추가하기

Cocoapods

Terminal window
# 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. AppDelegate에 PushwooshForegroundPush 구성 추가하기

Anchor link to
import UIKit
import PushwooshFramework
import PushwooshForegroundPush
@main
class 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)
}
}
}

foregroundNotificationWith 메서드 사용하기

foregroundNotificationWith 메서드를 사용하면 구성 가능한 스타일, 지속 시간 및 햅틱 피드백으로 사용자 지정 포그라운드 푸시 알림을 표시할 수 있습니다.

메서드 시그니처 (Swift / Objective-C):

@objc
static func foregroundNotificationWith(
style: PWForegroundPushStyle,
duration: Int,
vibration: PWForegroundPushHapticFeedback,
disappearedPushAnimation: PWForegroundPushDisappearedAnimation
)

매개변수:

  1. style (PWForegroundPushStyle)
  • 현재 style1만 사용할 수 있습니다.
  1. duration (Int)
  • 알림이 사라지기 전에 표시될 시간을 초 단위로 지정합니다.
  1. vibration (PWForegroundPushHapticFeedback)
  • 알림이 표시될 때의 햅틱 피드백을 제어합니다. 사용 가능한 옵션:
case none // 진동 없음
case light // 가벼운 진동
case medium // 중간 진동
case heavy // 강한 진동
case soft // 부드러운 진동
case rigid // 단단한 진동
case notification // 표준 알림 진동
  1. disappearedPushAnimation (PWForegroundPushDisappearedAnimation)
  • 푸시 사라짐 애니메이션
case balls = 0
case regularPush

4. didTapForegroundPush 델리게이트 메서드 구현하기

Anchor link to

사용자 지정 포그라운드 푸시 알림에 대한 사용자 탭을 처리하려면 PWForegroundPushDelegate 프로토콜 메서드를 구현합니다:

// 포그라운드 푸시 탭 처리
func didTapForegroundPush(_ userInfo: [AnyHashable : Any]) {
print("Foreground custom push: \(userInfo)")
// 특정 화면으로 이동하는 등의 작업 수행
// navigateToScreen(for: userInfo)
}

참고:

  • 이 메서드는 사용자가 사용자 지정 포그라운드 푸시를 탭할 때 호출됩니다.
  • userInfo에는 알림의 페이로드가 포함됩니다.
  • 구성 후 Pushwoosh.ForegroundPush.delegate = self를 설정해야 합니다.

5. 포그라운드 푸시 알림 사용자 지정을 위한 선택적 매개변수

Anchor link to

PushwooshForegroundPush 모듈은 포그라운드 푸시 알림의 모양과 동작을 사용자 지정하기 위한 여러 선택적 매개변수를 제공합니다. 이러한 매개변수는 정적 속성을 통해 전역적으로 설정할 수 있습니다.

속성타입설명기본값
useLiquidViewBooliOS 26에서 Liquid Glass 뷰를 사용합니다.false
gradientColors[UIColor]?그라데이션 배경을 위한 색상 배열(선택 사항).nil
backgroundColorUIColor?푸시의 배경색입니다. nil이고 gradientColors가 설정되지 않은 경우 기본 그라데이션이 사용됩니다.기본 시스템 그라데이션
usePushAnimationBool푸시가 표시될 때 애니메이션을 적용할지 여부입니다.true
titlePushColorUIColor?알림 제목 텍스트의 색상입니다. nil인 경우 시스템 흰색이 기본값입니다.white
messagePushColorUIColor?알림 메시지 텍스트의 색상입니다. nil인 경우 시스템 흰색이 기본값입니다.white
titlePushFontUIFont?알림 제목 텍스트의 글꼴입니다. nil인 경우 시스템 글꼴이 기본값입니다.기본 시스템 글꼴
messagePushFontUIFont?알림 메시지 텍스트의 글꼴입니다. nil인 경우 시스템 글꼴이 기본값입니다.기본 시스템 글꼴

요약:

  • Swift 5.13+ + iOS 26 → Liquid Glass
  • Swift 5.13+ + iOS < 26 → 표준 UIView
  • Swift < 5.13 → 항상 흐릿한 뷰 (Liquid Glass 지원 없음)

사용 예시:

Pushwoosh.ForegroundPush.useLiquidView = true
Pushwoosh.ForegroundPush.gradientColors = [.red, .orange, .yellow]
Pushwoosh.ForegroundPush.titlePushColor = .red
Pushwoosh.ForegroundPush.messagePushColor = .green
Pushwoosh.ForegroundPush.backgroundColor = .black
Pushwoosh.ForegroundPush.titlePushFont = .boldSystemFont(ofSize: 22)
Pushwoosh.ForegroundPush.messagePushFont = .italicSystemFont(ofSize: 15)
Pushwoosh.ForegroundPush.usePushAnimation = false

6. 포그라운드 푸시 예시

Anchor link to

이 예시는 title, message, cards, GIF 애니메이션을 사용하여 사용자 지정 포그라운드 푸시 알림을 표시하는 방법을 보여줍니다.

애니메이션 Liquid Glass 뷰가 있는 Pushwoosh 포그라운드 푸시
gif 첨부 파일이 있는 Pushwoosh 포그라운드 푸시
카드 이미지가 있는 Pushwoosh 포그라운드 푸시
사용자 지정 그라데이션, 사용자 지정 제목 및 메시지 색상이 있는 Pushwoosh 포그라운드 푸시
사용자 지정 배경, 제목 및 메시지 글꼴, 애니메이션이 없는 Pushwoosh 포그라운드 푸시

이것으로 끝입니다. Pushwoosh를 사용하여 iOS에서 사용자 지정 포그라운드 푸시 알림을 성공적으로 구성했습니다.