React Native SDK
블럭스 React Native 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", "0.6.19"
end
이후 pod install을 실행합니다.
블럭스 SDK 연동
AppDelegate 메서드 추가
application(:didRegisterForRemoteNotificationsWithDeviceToken:) 대응 메서드 추가
@import BluxClient;
// AppDelegate.mm
@implementation AppDelegate
// ...
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
[[BluxAppDelegate shared] application:application
didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
// ...
@end
UNUserNotificationCenterDelegate 메서드 추가
-
AppDelegate에 UNUserNotificationCenterDelegate 지정
-
userNotificationCenter(:willPresent:withCompletionHandler:) 대응 메서드 추가
-
대응 메서드 추가
AppDelegate.h#import <UserNotifications/UserNotifications.h>
@interface AppDelegate : RCTAppDelegate <UNUserNotificationCenterDelegate>
@endAppDelegate.mm@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{
// 1. AppDelegate에 UNUserNotificationCenterDelegate 지정
[[UNUserNotificationCenter currentNotificationCenter] setDelegate: self];
}
// 2. userNotificationCenter(:willPresent:withCompletionHandler:) 대응 메서드 추가
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
willPresentNotification:(UNNotification *)notification
withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
{
[[BluxNotificationCenter shared] userNotificationCenter:center
willPresentNotification:notification
withCompletionHandler:completionHandler];
}
// 3. 대응 메서드 추가
- (void)userNotificationCenter:(UNUserNotificationCenter *)center
didReceiveNotificationResponse:(UNNotificationResponse *)response
withCompletionHandler:(void(^)(void))completionHandler
{
[[BluxNotificationCenter shared] userNotificationCenter:center
didReceiveNotificationResponse:response
withCompletionHandler:completionHandler];
}
@end
UNNotificationServiceExtension 메서드 추가
-
didReceive(:withContentHandler:) 대응 메서드 추가
-
serviceExtensionTimeWillExpire() 대응 메서드 추가
NotificationService.swift
import 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()
}
}
SDK 설치
아래 명령어로 블럭스 React Native SDK를 설치합니다.
npm install @blux.ai/react-native
yarn add @blux.ai/react-native
pnpm install @blux.ai/react-native