SDK 초기화 | 초기화 및 화면 | Appbox iOS SDK 가이드
초기화 및 화면
SDK 초기화
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가 됩니다.