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"
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
BluxClient 초기화
initialize()
블럭스 React Native SDK의 모든 메서드는 BluxClient 객체의 static 메서드입니다. initialize()를 호출해서 SDK를 초기화하세요. 내 서비스의 애플리케이션 아이디와 API 키 정보는 연동 키 확인하기 에서 자세히 확인하세요.
* 모든 메서드는 SDK가 초기화 된 이후에 호출해야 합니다.
BluxClient.initialize(
bluxApplicationId: "BLUX_APPLICATION_ID",
bluxAPIKey: "BLUX_API_KEY",
requestPermissionOnLaunch: true,
);
파라미터
bluxApplicationId필수String
고객님의 서비스를 식별하는 고유 아이디입니다.
bluxAPIKey필수String
블럭스에서 발급하는 API 키입니다.
requestPermissionOnLaunch필수boolean
true라면, 앱 실행 시 필요한 권한을 자동으로 요청합니다.
응답
Promise<void>유저
signIn()
유저 로그인을 요청합니다. signIn()을 호출하지 않으면 블럭스 SDK는 유저를 식별할 수 없어요. 아래의 경우에 반드시 호출하세요.
① 회원 유저가 자동 로그인 한 시점
② 비회원 유저가 로그인하여 회원 유저로 식별되는 시점
BluxClient.signIn({ userId: 'USER_ID' });
// 자동 로그인이 구현된 경우
await BluxClient.initialize(
bluxApplicationId: "BLUX_APPLICATION_ID",
bluxAPIKey: "BLUX_API_KEY"
);
BluxClient.signIn({ userId: "USER_ID" });
파라미터
userId필수string
유저를 식별하는 고유 아이디입니다.
응답
Promise<void>signOut()
유저 로그아웃을 요청합니다. 회원 유저가 로그아웃하는 시점에 호출하세요.
BluxClient.signOut();
응답
Promise<void>setUserProperties()
유저의 전화번호, 이메일 주소, 광고 수신 동의 여부 등을 설정합니다.
BluxClient.setUserProperties({
userProperties: {
phone_number: "01012345678",
email_address: "test@blux.ai",
marketing_notification_consent: true,
}
});
파라미터
userProperties필수Record<string, any>
유저의 기본 정보입니다.
phone_numberstring
유저의 전화번호입니다. 블럭스의 문자/카카오톡 발송에 사용되고 있어요.
-없이 숫자로만 구성된 문자열입니다.email_addressstring
유저의 이메일 주소입니다. 블럭스의 이메일 발송에 사용되고 있어요.
agenumber
유저의 나이입니다.
genderstring
유저의 성별입니다.
male,female중 하나를 입력하세요.marketing_notification_consentboolean
광고 수신 전역 동의 설정입니다. 전역 동의 또는 채널별 동의 둘 중 하나라도
false면 해당 채널의 광고 수신은 거부됩니다. 둘 다 미설정이어도 해당 채널은 거부됩니다.marketing_notification_sms_consentboolean
광고 문자 수신 동의 여부입니다.
marketing_notification_email_consentboolean
광고 이메일 수신 동의 여부입니다.
marketing_notification_push_consentboolean
광고 푸시 알림 수신 동의 여부입니다.
marketing_notification_kakao_consentboolean
광고 카카오톡 수신 동의 여부입니다.
응답
Promise<void>setCustomUserProperties()
setUserProperties()로 설정하는 기본 정보 이외의 추가 정보를 설정합니다.
BluxClient.setCustomUserProperties({
customUserProperties: {
"membership_level": "GOLD",
"available_points": 12000,
"is_active": true,
"last_login_date": "2025-06-17T11:15:00.123+09:00",
}
});
파라미터
customUserProperties필수Record<string, any>
유저의 추가 정보입니다. 예를 들어, 회원 등급, 잔여 포인트, 활성 여부, 최근 로그인 일시 등을 설정할 수 있습니다. 블럭스의 유저 세그멘테이션에 사용되고 있어요.
응답
Promise<void>이벤트
Event 객체
유저의 행동 데이터를 담고 있는 객체입니다. 행동의 종류, 정보, 발생 시간 등을 자세히 알 수 있습니다.
기본 이벤트
기본 이벤트는 블럭스가 미리 정의해 둔 이벤트 객체입니다. 자주 쓰이는 장바구니 담기, 좋아요 누르기, 상세페이지 진입하기 등의 이벤트 를 포함합니다.
AddProductDetailViewEvent
유저가 상품의 상세 정보를 탐색한 순간이에요. 예를 들어, 유저가 상품의 상세페이지에 진입한 순간을 의미해요.
const addProductDetailViewEvent = new AddProductDetailViewEvent({
item_id: "ITEM_ID",
custom_event_properties: {
brandName: "Nike",
categoryName: "Shoes",
},
});
객체 상세
item_id필수string
상품을 식별하는 고유 아이디입니다. 연동 시 사용한 상품 아이디를 입력하세요.
custom_event_propertiesMap<String, Object>
이벤트 추가 속성입니다. 위 속성 이외의 속성을 추가하고 싶다면 이 필드를 사용하세요.
AddCartaddEvent
유저가 상품에 대한 강한 선호를 표현한 순간이에요. 예를 들어, 유저가 상품을 장바구니에 담은 순간을 의미해요.
const addCartaddEvent = new AddCartaddEvent({
item_id: "ITEM_ID",
custom_event_properties: {
brandName: "Nike",
addedFrom: "product_detail",
},
});
객체 상세
item_id필수string
상품을 식별하는 고유 아이디입니다. 연동 시 사용한 상품 아이디를 입력하세요.
custom_event_propertiesMap<String, Object>
이벤트 추가 속성입니다. 위 속성 이외의 속성을 추가하고 싶다면 이 필드를 사용하세요.
AddPurchaseEvent
유저가 상품을 구매하여 비용을 지불한 순간이에요.
const addPurchaseEvent = new AddPurchaseEvent({
item_id: "ITEM_ID",
price: 15000.0,
});