푸시 알림을 위한 모바일 앱 설정(FCM V1 및 APNs)
푸시 알림을 위한 모바일 앱 설정(FCM V1 및 APNs)
이 가이드는 SMSBAT 푸시 알림을 iOS 및 Android 앱에 연동하는 방법을 다룹니다.
1단계. Firebase 프로젝트와 서비스 계정(FCM V1)
SMSBAT은 Android와 iOS 모두에서 FCM V1을 통해 푸시를 보냅니다. 따라서 SMSBAT에 업로드하는 파일은 딱 하나, Firebase 서비스 계정뿐입니다. APNs 키는 SMSBAT에 절대 업로드하지 않습니다 — Firebase에는 필요하지만 저희는 필요하지 않습니다(3단계 참조).
1. Firebase에서 서비스 계정 가져오기
- Firebase 콘솔 → 프로젝트 설정 → 서비스 계정 탭.
- 새 비공개 키 생성 → 확인 →
.json파일이 다운로드됩니다.
google-services.json과 같은 파일이 아닙니다
google-services.json과 GoogleService-Info.plist는 앱 안에 포함됩니다.
서비스 계정은 비공개 서버 키이며 SMSBAT에만 있어야 합니다.
앱 코드, 저장소, 채팅 메시지에는 절대 넣지 마세요.
2. SMSBAT Omni에서 통합 만들기
- 통합을 열고 왼쪽 목록에서 Firebase를 선택합니다.
- 생성을 클릭합니다.
- 두 필드를 입력합니다:
- 이름 — 목록에서 앱을 알아볼 수 있는 아무 레이블
(for example,
Omnichannel Contact Center). - 서비스 계정 JSON — 선택을 클릭하고 다운로드한 파일을 선택합니다.
- 이름 — 목록에서 앱을 알아볼 수 있는 아무 레이블
(for example,
- 생성을 클릭합니다.
여기에는 패키지 이름이나 번들 ID 필드가 없습니다 — SMSBAT이 파일 자체에서 프로젝트 ID를 읽어 표에 표시합니다.
3. 통합이 생성되었는지 확인
이름, 프로젝트 ID, 상태, 생성일이 있는 행이 나타납니다. 정상 상태는 활성입니다.
행 끝에 있는 버튼:
| 버튼 | 동작 |
|---|---|
| 연필(파란색) | 이름을 변경하거나 서비스 계정 파일을 교체합니다 |
| 새로고침(녹색) | 키를 다시 읽고 FCM 접근 권한을 다시 확인합니다 |
| 휴지통(빨간색) | 통합을 삭제합니다 |
프로젝트 ID는 앱의 것과 일치해야 합니다
표의 프로젝트 ID를 google-services.json(Android) 및
GoogleService-Info.plist(iOS)의 project_id와 비교하세요. 서로
다르다면 앱은 하나의 Firebase 프로젝트에 등록되어 있는데 SMSBAT은
다른 프로젝트로 보내고 있는 것입니다. 토큰은 유효해 보이고, 아무것도 도착하지 않으며, 오류도
반환되지 않습니다. 이것이 «모든 것이 설정되어 있는데
아무것도 오지 않는다»는 상황의 가장 흔한 원인입니다.
Firebase에서 키를 교체했다면 연필 버튼으로 새 파일을 업로드하고 녹색 버튼을 누르세요. 취소된 키는 아무 표시 없이 작동을 멈춥니다.
4. 애플리케이션 키
앱에서 SMSBAT Push API로 보내는 요청은 Omni 패널에서 앱에 발급된 애플리케이션 키로 인증되며, 헤더로 전달됩니다:
X-Push-App-Key: <application key>
전체 요청 레퍼런스는 Push API 개요를 참조하세요.
2단계. Android (Kotlin / Java)
1. 의존성
모듈의 build.gradle에서:
dependencies {
implementation 'com.google.firebase:firebase-messaging-ktx:23.4.0'
implementation 'com.google.firebase:firebase-installations-ktx:17.2.0'
}
2. Firebase Installation ID(FID) 등록
사용자가 로그인하거나 앱이 시작될 때 FID를 읽어 SMSBAT으로 보냅니다:
FirebaseInstallations.getInstance().id.addOnCompleteListener { task ->
if (task.isSuccessful) {
val fid = task.result
registerInstallationOnSmsbat(fid, currentUserId)
}
}
fun registerInstallationOnSmsbat(fid: String, userId: String) {
val json = JSONObject().apply {
put("externalUserId", userId)
put("firebaseInstallationId", fid)
put("platform", "android")
put("notificationsEnabled", true)
}
// HTTP POST to https://restapi.smsbat.com/api/push/registerInstallation
// Header: X-Push-App-Key = YOUR_PUSH_APP_KEY
}
3. 푸시를 처리하고 delivered 보고
FirebaseMessagingService에서:
class MyFirebaseMessagingService : FirebaseMessagingService() {
override fun onMessageReceived(remoteMessage: RemoteMessage) {
val data = remoteMessage.data
val notificationGuid = data["guid"]
if (!notificationGuid.isNullOrEmpty()) {
// 1. Confirm delivery so SMSBAT stops the cascade
sendDeliveryStatus(notificationGuid, "delivered")
}
// 2. Draw the local notification yourself (NotificationManager)
showNotification(data["title"], data["body"], data)
}
private fun sendDeliveryStatus(guid: String, status: String) {
// HTTP POST to https://restapi.smsbat.com/api/push/notifications/$guid/status
// Header: X-Push-App-Key = YOUR_PUSH_APP_KEY
// Body: { "status": "delivered", "occurredAt": "2026-08-07T12:00:00Z" }
}
}
배너를 직접 그려야 하는 이유
SMSBAT은 사용자가 아무것도 열기 전에 앱이 delivered를 보고할 수 있도록
데이터 전용 메시지를 보냅니다. 시스템은 데이터 전용
메시지에 대해 배너를 렌더링하지 않으므로 앱이 직접 해야 합니다.
3단계. iOS (Swift / APNs)
iOS에서는 APNs 키를 SMSBAT이 아닌 Firebase에 업로드합니다: Firebase 콘솔 → Cloud Messaging → APNs 인증 키. 그러면 FCM V1이 사용자를 대신하여 Apple에 전달합니다.
1. Notification Service Extension 추가
전달을 확인하고 리치 콘텐츠(이미지, 소리, 버튼)를 처리하려면 Xcode에서 Notification Service Extension 타깃을 추가합니다:
import UserNotifications
class NotificationService: UNNotificationServiceExtension {
var contentHandler: ((UNNotificationContent) -> Void)?
var bestAttemptContent: UNMutableNotificationContent?
override func didReceive(_ request: UNNotificationRequest, withContentHandler contentHandler: @escaping (UNNotificationContent) -> Void) {
self.contentHandler = contentHandler
bestAttemptContent = (request.content.mutableCopy() as? UNMutableNotificationContent)
if let bestAttemptContent = bestAttemptContent {
let userInfo = bestAttemptContent.userInfo
if let guid = userInfo["guid"] as? String {
// Report delivered to SMSBAT
sendPushStatus(guid: guid, status: "delivered")
}
contentHandler(bestAttemptContent)
}
}
}
2. 탭 처리(seen)
AppDelegate 또는 SceneDelegate에서:
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void) {
let userInfo = response.notification.request.content.userInfo
if let guid = userInfo["guid"] as? String {
// Report seen to SMSBAT
sendPushStatus(guid: guid, status: "seen")
}
completionHandler()
}
결과
연동이 완료되면 앱이 알림을 즉시 수신하고, 푸시가 전달되는 즉시 캐스케이드가 멈춰 유료 채널에는 요금이 청구되지 않으며, 정확한 전달 및 읽음 통계를 얻을 수 있습니다.
무언가 도착하지 않는다면 푸시 문제 해결을 따라가 보세요 — 오류가 전혀 발생하지 않는 실패 사례를 다룹니다.