본문으로 건너뛰기

(Advanced) Client SDK - iOS

1. 푸시 알림 사전 동의

유저가 푸시 알림을 수신하기 위해서는 푸시 알림 수신 동의를 받아야 합니다. Notifly iOS SDK에서는 따로 사용자에게 푸시 알림 수신 동의를 요청하지 않고 있습니다. 사용자 알림 수신 동의는 Notifly iOS SDK 설치와 무관하게 앱 내에서 직접 구현하셔야 합니다.

다음 코드는 예시입니다. 실제 알림 요청 타이밍, UI, 문구 등은 앱의 특성에 맞게 구현해 주세요.

Example code for notification permission request
UNUserNotificationCenter.current().requestAuthorization(options: [.alert, .badge, .sound]) { granted, error in
if let error = error {
print("Failed to request authorization: \(error)")
return
} else {
guard granted else {
print("Notification permission denied")
return
}
DispatchQueue.main.async {
UIApplication.shared.registerForRemoteNotifications()
}
}
}

2. 인앱 팝업 이벤트 리스너

SDK 버전

해당 기능은 Notifly iOS SDK 1.16.1 이상 버전부터 지원됩니다.

Notifly iOS SDK에서는 인앱 팝업에서 발생하는 이벤트를 감지하고 처리할 수 있는 이벤트 리스너를 제공합니다. 이를 통해 인앱 팝업에서 사용자가 특정 행동을 했을 때, 추가적인 행동을 앱에서 처리할 수 있습니다.

Example code snippet for adding in-app message event listener
import Firebase
import notifly_ios_sdk
import UIKit
import UserNotifications

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
func application(
_: UIApplication,
didFinishLaunchingWithOptions _: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
...
Notifly.initialize(
projectId: TestConstant.projectID, username: TestConstant.username,
password: TestConstant.password)

Notifly.addInAppMessageEventListener { eventName, eventParams in
print("In App Message Event: \(eventName)")
if let params = eventParams {
print("In App Message Event Params: \(params)")
}
}
...
return true
}
}

2-1. 인앱 팝업 이벤트 리스너 인터페이스

addInAppMessageEventListener 메소드를 통해 InAppMessageEventListener를 등록할 수 있습니다.

  • eventName: 발생한 이벤트의 이름입니다.
  • eventParams: 발생한 이벤트와 관련된 추가 정보가 포함된 객체입니다.

2-2. 인앱 팝업 이벤트 목록

addInAppMessageEventListener로 전달되는 eventName 목록입니다.

  • in_app_message_show: 인앱 팝업 노출.
  • main_button_click: 팝업 내 메인 버튼 클릭.
  • hide_in_app_message_button_click: 다시 보지 않기 버튼 클릭.
  • close_button_click: 팝업 내 닫기 버튼 클릭.
  • survey_submit_button_click: 설문 조사 제출 버튼 클릭.