사전 확인 사항

Braze 푸시 메세지 클릭시 앱 내에서 랜딩하고자 하는 뷰 목록 정의

유저가 앱을 푸시를 통해 실행했을 때, 홈이 아닌 다른 뷰를 열어둔 상황에서 푸시를 수신했을 때 등의 여러 상황을 고려하여 푸시 수신시 동작을 정의합니다.

프로젝트의 .p8 파일 유무 여부

1. SDK 탑재하기

https://www.braze.com/docs/developer_guide/platform_integration_guides/swift/initial_sdk_setup/overview

Braze는 SPM과 CocoaPods 모두로 탑재할 수 있습니다.

본 서비스의 경우 SPM으로 탑재한 SDK가 존재하지 않아 Braze도 CocoaPods로 탑재하였습니다.

인앱메세지 탑재가 필요한 경우 BrazeUI도 함께 탑재해야 합니다. 본 서비스의 경우 인앱 메세지를 탑재하여 BrazeKit 과 동일한 버전의 BrazeUI 도 pod으로 설치하였습니다.

1-1. AppDelegate에 SDK import

https://www.braze.com/docs/developer_guide/platform_integration_guides/swift/initial_sdk_setup/completing_integration

// AppDelegate

import BrazeKit

class AppDelegate: UIResponder, UIApplicationDelegate {
  static var braze: Braze? = nil
}

// application:didFinishLaunchingWithOptions: method
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
		...
		
		// Braze
		Braze.prepareForDelayedInitialization(pushAutomation: true)
		let brazeConfig = Braze.Configuration(apiKey: Constants.BRAZE_API_KEY, endpoint: Constants.BRAZE_SDK_END_POINT)
		brazeConfig.logger.level = .debug
		
		let braze = Braze(configuration: brazeConfig)
		AppDelegate.braze = braze
		
		// Push integration
		
		// BrazeUI: InAppMessaging
		
		...
}

2. logEvent 기록하기