초기화 및 화면 | Appbox iOS SDK 가이드

초기화 및 화면

SDK 초기화

SDK Core와 설정에 포함된 기능 모듈을 초기화합니다. 앱 시작 시 한 번 호출합니다.

SDK 초기화

AppBox.initialize(_ config: AppBoxInitConfig, completion: @escaping (AppBoxInitResult) -> Void)

Swift
1 let config = AppBoxInitConfig(
2 common: AppBoxCommonConfig(
3 projectId: "<PROJECT_ID>",
4 debugMode: false
5 ),
6 webView: AppBoxWebViewConfig(baseURL: "<SERVICE_URL>"),
7 push: AppBoxPushConfig()
8 )
9
10 AppBox.initialize(config) { result in
11 guard result.core.status == .INITIALIZED else {
12 print(result.core.error?.localizedDescription ?? result.core.message)
13 return
14 }
15
16 print(result.webView.status)
17 print(result.push.status)
18 }
1 AppBoxCommonConfig *common =
2 [[AppBoxCommonConfig alloc] initWithProjectId:@"<PROJECT_ID>" debugMode:NO];
3 AppBoxWebViewConfig *webView =
4 [[AppBoxWebViewConfig alloc] initWithBaseURL:@"<SERVICE_URL>"
5 webConfig:[[AppBoxWebConfig alloc] init]];
6 AppBoxInitConfig *config =
7 [[AppBoxInitConfig alloc] initWithCommon:common
8 webView:webView
9 push:[[AppBoxPushConfig alloc] init]
10 inApp:[[AppBoxInAppConfig alloc] init]
11 auth:nil
12 appsFlyer:nil
13 initializationTimeout:30];
14
15 [AppBox initializeWithConfig:config completion:^(AppBoxInitResult *result) {
16 if (result.core.status != AppBoxInitStatusINITIALIZED) {
17 NSLog(@"%@", result.core.error.localizedDescription ?: result.core.message);
18 return;
19 }
20
21 NSLog(@"webView=%ld, push=%ld",
22 (long)result.webView.status,
23 (long)result.push.status);
24 }];

Request 항목 정의

Request 항목필수여부설명기본값
config필수공통 설정과 기능별 설정을 담은 AppBoxInitConfig-
config.common필수projectId, debugMode를 담은 공통 설정-
config.webView선택AppBox 화면과 WebView 설정nil
config.push선택Push 설정nil
config.inApp선택Native In-App 설정활성 config
config.auth선택SNS 로그인 설정nil
config.appsFlyer선택AppsFlyer 설정nil
config.initializationTimeout선택기능 모듈 초기화 제한 시간30초, 최소 1초
completion필수기능별 초기화 결과를 받는 callback-

Response 항목 정의

Response 결과값
AppBoxInitResult비동기로 전달되는 초기화 결과
.core, .webView, .push, .inApp, .auth, .health, .appsFlyer기능별 AppBoxModuleInitResult
.{기능}.status.INITIALIZED, .SKIPPED, .FAILED 중 하나
.{기능}.message상태 설명
.{기능}.error실패 원인. 성공 또는 건너뜀 상태에서는 nil일 수 있음


앱 시작 지점 한 곳에서 한 번 호출합니다.

  • 같은 설정으로 초기화가 진행 중이면 작업을 공유하고 각 completion을 한 번씩 호출합니다. 완료 후 같은 설정으로 호출하면 저장된 결과를 반환합니다.
  • 다른 설정으로 다시 호출하면 .conflictingInitialization 오류가 발생합니다.
  • core 성공이 다른 모듈의 성공을 의미하지 않습니다. 사용할 기능의 결과를 각각 확인합니다.
  • .SKIPPED는 해당 Product 또는 config를 사용하지 않은 상태입니다.
  • config.webView는 선택 인자입니다. AppBox 관리 화면을 쓰지 않는 앱은 생략하며, 이때 webView의 status는 .SKIPPED가 됩니다.

AppBox 화면 시작

AppBox 관리 화면을 지정한 UIViewController에서 시작합니다.

AppBox 화면 시작

AppBox.start(from: UIViewController, completion: ((Bool, NSError?) -> Void)?)

Swift
1 AppBox.start(from: self) { success, error in
2 if !success {
3 print(error?.localizedDescription ?? "AppBox 화면 시작 실패")
4 }
5 }
1 [AppBox startFrom:self completion:^(BOOL success, NSError *error) {
2 if (!success) {
3 NSLog(@"%@", error.localizedDescription ?: @"AppBox 화면 시작 실패");
4 }
5 }];

Request 항목 정의

Request 항목필수여부설명기본값
viewController필수AppBox 화면을 표시할 UIViewController-
completion선택화면 시작 요청 처리 결과nil

Response 항목 정의

Response 결과값
success화면 시작 요청이 SDK에 전달되면 true
error시작 요청 실패 원인


webView 초기화 결과가 .INITIALIZED인지 먼저 확인합니다. UI를 표시할 수 있는 시점에 현재 화면 계층의 view controller를 전달합니다. success == true는 웹 페이지 로딩 완료를 의미하지 않습니다.

WebView 미리 로드

AppBox 관리 화면에서 사용할 WebView를 미리 준비합니다.

WebView 미리 로드

AppBox.preloadWebView(completion: ((Bool) -> Void)?)

Swift
1 AppBox.preloadWebView { loaded in
2 if loaded {
3 // AppBox 화면을 시작할 수 있습니다.
4 }
5 }
1 [AppBox preloadWebViewWithCompletion:^(BOOL loaded) {
2 if (loaded) {
3 // AppBox 화면을 시작할 수 있습니다.
4 }
5 }];

Request 항목 정의

Request 항목필수여부설명기본값
completion선택미리 로드 결과 callbacknil

Response 항목 정의

Response 결과값
loadedWebView 준비 성공 여부


webView 초기화가 완료된 뒤 호출합니다. 이 completion에는 별도 NSError가 없습니다. 상세 원인은 초기화 결과와 SDK 진단 로그를 함께 확인합니다. 미리 로드는 선택 사항이며 start 호출의 필수 조건이 아닙니다.

기본 URL 설정

AppBox 관리 WebView에서 사용할 서비스 기본 URL을 변경합니다.

기본 URL 설정

AppBox.setBaseURL(_ baseURL: String)

Swift
1 AppBox.setBaseURL("<SERVICE_URL>")
1 [AppBox setBaseURL:@"<SERVICE_URL>"];

Request 항목 정의

Request 항목필수여부설명기본값
baseURL필수host가 있는 http 또는 https URL 문자열-

Response 항목 정의

Response 결과값
없음반환값과 callback이 모두 없습니다


입력 타입은 URL이 아니라 String입니다. 새 앱에서는 가능하면 AppBoxWebViewConfig(baseURL:)로 초기화 시점에 설정합니다. 잘못된 URL은 화면 시작 또는 로딩 실패 원인이 됩니다.

로딩 indicator 설정

AppBox 관리 WebView의 기본 로딩 indicator 표시 여부를 설정합니다.

로딩 indicator 설정

AppBox.setIndicatorEnabled(_ enabled: Bool)

Swift
1 AppBox.setIndicatorEnabled(true)
1 [AppBox setIndicatorEnabled:YES];

Request 항목 정의

Request 항목필수여부설명기본값
enabled필수indicator 표시 여부-

Response 항목 정의

Response 결과값
없음반환값과 callback이 모두 없습니다


AppBox 관리 화면의 로딩 UI에만 적용됩니다. indicator 모양과 색상은 setLoadingData(_:)로 설정합니다.

로딩 화면 설정

로딩 indicator의 크기와 전경, 배경색을 설정합니다.

로딩 화면 설정

AppBox.setLoadingData(_ config: AppBoxLoadingConfig)

Swift
1 let loadingConfig = AppBoxLoadingConfig(
2 sizePercentage: 10,
3 iconColor: "#999999",
4 backColor: "#1A000000"
5 )
6 AppBox.setLoadingData(loadingConfig)
1 AppBoxLoadingConfig *loadingConfig =
2 [[AppBoxLoadingConfig alloc] initWithSizePercentage:10
3 iconColor:@"#999999"
4 backColor:@"#1A000000"];
5 [AppBox setLoadingData:loadingConfig];

Request 항목 정의

Request 항목필수여부설명기본값
config필수로딩 화면 설정-
config.sizePercentage선택indicator 크기 비율10
config.iconColor선택indicator hex 색상#999999
config.backColor선택배경 hex 색상#1a000000

Response 항목 정의

Response 결과값
없음반환값과 callback이 모두 없습니다


색상은 SDK가 지원하는 hex 문자열로 전달합니다. 앱 디자인과 명도 대비를 확인합니다. indicator 표시 자체는 setIndicatorEnabled(_:)로 제어합니다.

시스템 바 외관 설정

상태바 영역의 배경색과 글자, 아이콘 스타일을 설정합니다.

시스템 바 외관 설정

AppBox.setSystemBarAppearance(backgroundHex: String? = nil, style: AppBoxSystemBarStyle = .auto)

Swift
1 AppBox.setSystemBarAppearance(
2 backgroundHex: "#FFFFFF",
3 style: .dark
4 )
1 [AppBox setSystemBarAppearanceWithBackgroundHex:@"#FFFFFF"
2 style:AppBoxSystemBarStyleDark];

Request 항목 정의

Request 항목필수여부설명기본값
backgroundHex선택6자리 또는 8자리 hex 배경색nil
style선택.auto, .light, .dark.auto

Response 항목 정의

Response 결과값
없음반환값과 callback이 모두 없습니다


.light와 .dark는 배경이 아니라 상태바 글자, 아이콘의 밝기입니다. 잘못된 hex를 전달하면 배경과 style을 모두 변경하지 않습니다. Objective-C에서는 기본 인자가 없으므로 두 인자를 모두 전달합니다.

당겨서 새로고침 설정

AppBox 관리 WebView의 pull-to-refresh 사용 여부를 설정합니다.

당겨서 새로고침 설정

AppBox.setPullDownRefresh(_ used: Bool)

Swift
1 AppBox.setPullDownRefresh(false)
1 [AppBox setPullDownRefreshUsed:NO];

Request 항목 정의

Request 항목필수여부설명기본값
used필수pull-to-refresh 사용 여부-

Response 항목 정의

Response 결과값
없음반환값과 callback이 모두 없습니다


AppBox 관리 화면에만 적용됩니다. 페이지 자체의 스크롤, 새로고침 정책과 충돌하지 않는지 확인합니다.

Intro 설정

AppBox 관리 화면에서 사용할 Intro 이미지 목록과 표시 색상을 설정합니다.

Intro 설정

AppBox.setIntro(_ items: AppBoxIntro)

Swift
1 if let item = AppBoxIntroItems(imageUrl: "<IMAGE_URL>") {
2 let intro = AppBoxIntro(item: [item])
3 AppBox.setIntro(intro)
4 }
1 AppBoxIntroItems *item =
2 [[AppBoxIntroItems alloc] initWithImageUrl:@"<IMAGE_URL>"];
3 if (item != nil) {
4 AppBoxIntro *intro = [[AppBoxIntro alloc] initWithItem:@[item]];
5 [AppBox setIntro:intro];
6 }

Request 항목 정의

Request 항목필수여부설명기본값
items필수Intro 색상과 이미지 목록을 담은 AppBoxIntro-
items.item필수유효한 이미지 URL을 가진 AppBoxIntroItems 배열-
items.indicatorDefColor선택비선택 indicator 색상#a7abab
items.indicatorSelColor선택선택 indicator 색상#000000
items.fontColor선택글자 색상#000000

Response 항목 정의

Response 결과값
없음반환값과 callback이 모두 없습니다


AppBoxIntroItems(imageUrl:)는 imageUrl이 빈 문자열일 때만 nil을 반환합니다. URL 형식은 검증하지 않으므로, 비어 있지 않은 문자열은 잘못된 URL이어도 통과합니다. 원격 이미지 로딩 실패를 고려해 서비스 화면의 대체 동작을 확인합니다. 이미지 URL과 색상값을 로그에 반복 출력하지 않습니다.

www.naver.com
QR 코드를 촬영하면 입력하신 주소의
앱 예시 화면을 테스트할 수 있습니다.
* 스캔 후 바로 앱 다운로드 이동합니다.