SDK 초기화 | 초기화 및 화면 | 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가 됩니다.
www.naver.com
QR 코드를 촬영하면 입력하신 주소의
앱 예시 화면을 테스트할 수 있습니다.
* 스캔 후 바로 앱 다운로드 이동합니다.