Skip to main content

설치하기

사전 준비

아래 항목을 eng@fairytech.ai로 전달해 주시면, 프로젝트 설정 후에 Project ID, SDK API Key, Maven Secret Key를 회신드리도록 하겠습니다.
  • 개발용 인증서 SHA-1 키해시 및 앱 패키지명
  • 배포용 인증서 SHA-1 키해시 및 앱 패키지명
  • (FCM 혹은 캐시백 이용시) 푸쉬 알림 설정을 위한 service account key.json

STEP 1) SDK dependency 추가

settings.gradle 또는 build.gradle 에 MomentSDK를 다운로드 받을 maven repository를 추가해주세요.
${MAVEN_SECRET}에는 사전에 전달드린 Maven Secret Key 값을 넣어 주시면 됩니다.
// 1) maven repository 추가
repositories {
    maven {
        url "https://asia-northeast3-maven.pkg.dev/moment-prod-16047/moment-x"
        // TODO: Replace MAVEN_SECRET.
        credentials {
            username = "_json_key_base64"
            password = "${MAVEN_SECRET}"
        }
        authentication {
            basic(BasicAuthentication)
        }
    }
}
build.gradle 에 moment dependency를 추가해주세요. 추가 후 Sync Project with Gradle Files 를 실행해 dependency가 다운로드 되는지 확인해주세요.
dependencies {
    implementation "ai.fairytech:moment-x:${LATEST_VERSION}"
}

STEP 2) Project ID, API Key 설정

AndroidManifest.xmlPROJECT_ID, API_KEY를 추가해주세요.
${PROJECT_ID}, ${SDK_API_KEY}에는 사전에 전달드린 값을 넣어 주시면 됩니다.
<application ...>
    <meta-data
        android:name="ai.fairytech.moment.PROJECT_ID"
        android:value="${PROJECT_ID}" />
    <meta-data
        android:name="ai.fairytech.moment.API_KEY"
        android:value="${SDK_API_KEY}" />
</application>

STEP 3) Proguard rule 적용

-keep class ai.fairytech.moment.** { *; }
-keep interface ai.fairytech.moment.** { *; }

SDK 설정

STEP 1) 초기화

앱 시작 시점에 SDK를 초기화합니다. Application#onCreate 에서 호출합니다.
class MyApp : Application() {
    override fun onCreate() {
        super.onCreate()
        Moment.initialize(this)
    }
}

STEP 2) Config 설정

Moment 서비스를 시작하기 전, 실행에 필요한 config를 설정합니다. (스타터내 예시 코드)
  • notificationChannelId, notificationId, notificationIconResId
    • 인식 푸시알림을 위한 notificationChannel 정보입니다.
    • 사용자에게 실시간 알림을 heads-up 으로 보여주기 위해 notificationChannelId로 넘겨주는 알림 채널을 생성할 때, importance를 IMPORTANCE_HIGH 이상으로 설정해주셔야 합니다.
      • foreground service 를 위한 notificationChannel 정보입니다. 해당 알림의 경우 foreground service 가 실행 중이라는 사실을 유저에게 알리기 위해 제공됩니다.
  • serviceNotificationChannelId, serviceNotificationId, serviceNotificationIconResId, serviceNotificationTitle, serviceNotificationText
// Kotlin
MomentSDK.Config(applicationContext)
	.notificationChannelId(NotificationController.NOTIFICATION_CHANNEL_ID) // 알림 채널 아이디
	.notificationId(NotificationController.NOTIFICATION_ID) // 알림 아이디
	.notificationIconResId(R.drawable.baseline_person_24) // 알림 스몰 아이콘
	.serviceNotificationChannelId(NotificationController.SERVICE_NOTIFICATION_CHANNEL_ID) // 서비스를 위해 필요한 채널아이디
	.serviceNotificationId(NotificationController.SERVICE_NOTIFICATION_ID)
	.serviceNotificationIconResId(R.drawable.baseline_person_24) // 서비스 알림 스몰 아이콘
	.serviceNotificationTitle("인식 서비스")
	.serviceNotificationText("인식 서비스가 동작 중입니다")
	
// Java
new MomentSDK.Config(applicationContext)
	.notificationChannelId(NotificationController.NOTIFICATION_CHANNEL_ID) // 알림 채널 아이디
	.notificationId(NotificationController.NOTIFICATION_ID) // 알림 아이디
	.notificationIconResId(R.drawable.baseline_person_24) // 알림 스몰 아이콘
	.serviceNotificationChannelId(NotificationController.SERVICE_NOTIFICATION_CHANNEL_ID) // 서비스를 위해 필요한 채널아이디
	.serviceNotificationId(NotificationController.SERVICE_NOTIFICATION_ID)
	.serviceNotificationIconResId(R.drawable.baseline_person_24) // 서비스 알림 스몰 아이콘
	.serviceNotificationTitle("인식 서비스")
	.serviceNotificationText("인식 서비스가 동작 중입니다")
notificationChannelId로 넘겨주는 알림 채널을 생성할 때, importance를 IMPORTANCE_HIGH 이상으로 설정해주셔야 합니다.(그래야 사용자에게 heads up 알림으로 알림이 나가게 됩니다.)