Flutter SDK
블럭스 Flutter SDK 를 설치하고 메서드를 사용하는 방법을 알아봅니다.
푸시 메시지 연동
[iOS] Xcode 설정
Notification Capability 추가
Xcode 프로젝트 설정의 Signing & Capabilities 탭에서 + Capabilities를 클릭하세요.

Push Notifications와 Background Modes를 추가하세요.


Background Modes에서 Remote notifications를 활성화하세요.

Service Extension 설정
Xcode 프로젝트 상단
File > New > Target을 클릭하고 아래와 같이 Notification Service Extension을 선택하세요.

아래와 같이 알맞는 이름을 입력 후 Finish를 클릭하세요.

표시되는 팝업에서 Don't Activate를 클릭하여 별도의 Scheme을 활성화하지 않도록 합니다.

이후 Notification Service Extension Target의 Minimum Deployments 버전을 현재 사용 중인 메인 앱 Target의 버전과 동일하게 설정합니다.

App Group 설정
Xcode 프로젝트 설정의 Signing & Capabilities 탭에서 + Capability > App Groups 를 선택하여 추가합니다.

group.[Bundle ID].blux이라는 이름의 그룹을 추가합니다. Bundle ID는 메인 앱의 Bundle Identifier와 일치해야 합니다.
추가 후 해당 App Group을 활성화하고, 이전 단계에서 만든 Notification Service Extension에도 동일한 App Group을 추가하고 활성화합니다.

Custom iOS Target Properties 설정
Xcode 프로젝트 설정의 Info 탭에서 Custom iOS Target Properties의 마지막 열을 클릭하고 오른쪽에 표시되는 **+**를 클릭합니다.

Key는
BluxAppGroupName, Type은String, Value는 이전 단계에서 만든 App Group의 ID를 입력합니다.- App Group ID가 변경되는 경우 해당 값도 같이 변경해야 합니다.

Podfile 수정
XCode 종료 후 ios 디렉터리 내의 Podfile을 열고 아래와 같이 target을
추가합니다.
// 앞서 생성한 Extension의 Product Name을 target 이름으로 설정합니다.
target 'NotificationServiceExtension' do
pod 'BluxClient'
end
이후 pod install 를 실행합니다.
블럭스 SDK 연동
AppDelegate 메서드 추가
application(:didRegisterForRemoteNotificationsWithDeviceToken:) 대응 메서드 추가
import BluxClient
class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {
BluxAppDelegate.shared.application(
application,
didRegisterForRemoteNotificationsWithDeviceToken: deviceToken
)
}
}
UNUserNotificationCenterDelegate 메서드 추가
-
AppDelegate에 UNUserNotificationCenterDelegate 지정
-
userNotificationCenter(:willPresent:withCompletionHandler:) 대응 메서드 추가
-
대응 메서드 추가
import BluxClient
@main
@objc class AppDelegate: FlutterAppDelegate {
override func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// 1. AppDelegate에 UNUserNotificationCenterDelegate 지정
UNUserNotificationCenter.current().delegate = self
}
// 2. userNotificationCenter(:willPresent:withCompletionHandler:) 대응 메서드 추가
override func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
BluxNotificationCenter.shared.userNotificationCenter(
center,
willPresent: notification,
withCompletionHandler: completionHandler
)
}
// 3. 대응 메서드 추가
override func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
BluxNotificationCenter.shared.userNotificationCenter(
center,
didReceive: response,
withCompletionHandler: completionHandler
)
}
}
UNNotificationServiceExtension 메서드 추가
-
didReceive(:withContentHandler:) 대응 메서드 추가
-
serviceExtensionTimeWillExpire() 대응 메서드 추가
NotificationService.swiftimport UserNotifications
import BluxClient
class NotificationService: UNNotificationServiceExtension {
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
// 1. didReceive(:withContentHandler:) 대응 메서드 추가
// 블럭스에서 발송한 푸시는 블럭스의 메서드만 동작하도록 분기 처리합니다.
if BluxNotificationServiceExtensionHelper.shared.isBluxNotification(request) {
BluxNotificationServiceExtensionHelper.shared.didReceive(request, withContentHandler: contentHandler)
}
}
override func serviceExtensionTimeWillExpire() {
// ✅ 블럭스 처리 타임아웃 콜백
BluxNotificationServiceExtensionHelper.shared.serviceExtensionTimeWillExpire()
}
}