# Native 대응
# 1. iOS Native 대응
# 1.1 iOS 프로젝트 생성
- iOS 프로젝트 신규 생성
HBuilderX
-Publish
-Generate
클릭- 로컬의 패키지화된 앱 리소스를 프로젝트 디렉토리에 복사 (
Pandora
->apps
)
# 1.2 iOS 프로젝트 설정
- iOS 프로젝트에 의존 파일 추가
CocoaPods를 이용해 SDK 설치
Podfile 생성 및 수정
Podfile 생성:
동일한 디렉토리의 프로젝트(.xcodeproj)에서 다음 명령어를 실행합니다
pod init
Podfile 편집
pod 'TAGameEngine'
다음 명령어를 실행
pod install
# 2. Android Native 대응
# 2.1 Android 프로젝트 생성
- Android 프로젝트 생성
HBuilderX
-Publish
-Generate
클릭- 앱 소스를
assets
->apps
디렉토리에 복사
# 2.2 Android 프로젝트 설정
- 프로젝트 레벨의
build.gradle
에 다음 의존 코드 추가:
buildscript {
repositories {
jcenter()
mavenCentral()
}
}
- 모듈 레벨의
build.gradle
파일에 다음 의존 코드 추가:
implementation 'cn.thinkingdata.android:TAGameEngine:1.0.0'
implementation 'cn.thinkingdata.android:ThinkingAnalyticsSDK:2.8.3'
# 3. Native 대응
SDK의 초기 설정 시, config
에 enableNative: true
를 추가하여 Native 대응이 가능합니다.
var config = {
appId: "YOUR_APPID",
serverUrl: "YOUR_SERVER_URL",
enableNative: true, // 네이티브 지원 활성화
autoTrack: {
appLaunch: true, // 자동 수집: 앱 기동
appShow: true, // 자동 수집: 앱 활성화
appHide: true, // 자동 수집: 앱 백그라운드 전환
pageShow: true, // 자동 수집: 페이지 표시
pageShare: true, // 자동 수집: 페이지 공유
appInstall: true, // 자동 수집: 앱 설치 (네이티브 전용)
appCrash: true, // 자동 수집: 앱 크래시 (네이티브 전용)
}
};
// TA 인스턴스 생성
var ta = new ThinkingAnalyticsAPI(config);
// 초기화
ta.init();
// 이벤트 트래킹
ta.track("test_event");