---
sourceDocument: 호주 API 참조
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/ko-KR/api-reference

 Release :

    - australia

ft:locale :

    - ko-KR

ft:publication_title :

    - 호주 API 참조

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# 애플리케이션에서 Android 푸시 알림 설정

# 애플리케이션에서 Android 푸시 알림 설정 {#ariaid-title1}

* 릴리스 버전: Australia
* 
* 업데이트 날짜 2026년 03월 12일
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 소요 시간: 6분

푸시 알림을 구성하기 위해 인스턴스에서 ServiceNow® 수행해야 하는 작업 외에도 애플리케이션에 Android 특정 코드를 포함해야 합니다.

## NowSDK NowPushService 작성 {#mobsdk-and-setup-push-app__section_hyb_zxp_prb}

애플리케이션에서 가장 먼저 수행해야 할 작업 중 하나는 NowSDK NowPushService를 검색하는 것입니다. 기본 코드 본문 초기에 다음 코드 조각과 유사한 코드를 추가합니다.

    /**
     * Helper class used to handle different Now service instances.
     */
    @Singleton
    class SdkManager @Inject constructor() {

        private var nowPushService: NowPushService? = null

        /**
         * Create the NowPushService once in the lifetime of the application inside the Application
         * class or another manager class that will be injected into other classes via dagger/hilt.
         * NowPushService should be created after initializing the NowSDK
         */
        suspend fun getNowPushService(): NowPushService? {
            if (nowPushService != null) return nowPushService

            return NowPushSDK.makePushService(URL("https://instance-name.service-now.com")).getOrThrow()
                .also { this.nowPushService = it }
        }
    }

NowPushSDK.makePushService() 메서드에 대한 자세한 내용은 을 참조하십시오[NowPushSDK - makePushService(instanceURL: URL)](https://servicenow-prod.fluidtopics.net/6TkK0RE1Z1Ja1rcmp0t12g#NPushSDK-makePushService_S_O_O "NowPush 서비스를 작성합니다.").

## 푸시 토큰 등록 {#mobsdk-and-setup-push-app__section_kyr_4cq_prb}

Google Firebase 는 푸시 알림을 수신할 장치와 애플리케이션을 식별하는 고유한 푸시 토큰을 제공합니다. 애플리케이션이 푸시 알림을 수신하려면 NowPushService를 사용하여 이 토큰을 등록해야 합니다. 애플리케이션에 Android 다음 코드 스니펫과 유사한 함수를 추가합니다. 애플리케이션의 이름으로 변경 PushAppName 해야 Android 합니다. 이 애플리케이션은 인스턴스 ServiceNow® 에 등록되어 있어야 합니다.

    FirebaseMessaging.getInstance().token.addOnCompleteListener {task ->
      val token = task.result

      if (!task.isSuccessfull || token == null) {
        throw Exception("Unable to fetch token"))
      }

      pushService.registerPushToken(token, "PushAppName", {
          Log.v(TAF, "Successfully registered push token")
      }, { e ->
          Log.e(TAG, "Error registrating push", e)
      })
    }

registerPushToken() 메서드에 대한 자세한 내용은 을 참조하십시오[NowPushService - registerPushToken(pushToken: String, pushApp: String, successCallback: 실행 가능, errorCallback: Consumer\<Throwable\>)](https://servicenow-prod.fluidtopics.net/qQOfWJFOtDKGjHeCLH~QYQ#NPushServ-registerPushToken_S_S_O_O "현재 Android 장치 및 지정된 애플리케이션에 대한 푸시 알림을 식별하는 데 사용되는 인스턴스에 ServiceNow 고유 Firebase 토큰을 등록합니다.").

## 푸시 토큰 등록 취소

사용자가 로그아웃할 때와 같이 사용자가 애플리케이션을 종료할 때마다 푸시 토큰의 등록을 취소해야 합니다. 다음 코드 스니펫과 유사한 코드를 사용하여 밀어넣기 토큰의 등록을 취소합니다. 애플리케이션의 이름으로 변경 PushAppName 해야 Android 합니다.

    pushService.unregisterPushToken(token, "PushAppName", {
          Log.v(TAG, "Successfully unregistered push token")
    }, { e ->
          Log.e(TAG, "Error unregistering push", e)
    })

unregisterPushToken() 메서드에 대한 자세한 내용은 을 참조하십시오[NowPushService - unregisterPushToken(pushToken: String, pushApp: String, successCallback: 실행 가능, errorCallback: Consumer\<Throwable\>)](https://servicenow-prod.fluidtopics.net/qQOfWJFOtDKGjHeCLH~QYQ#NPushServ-unregPushToken_S_S_O_O "연결된 ServiceNow 인스턴스에 지정된 Firebase 푸시 토큰의 등록을 취소합니다.").

## FirebaseMessagingService 구현

애플리케이션 내에서 `FirebaseMessagingService` 를 구현해야 합니다. 이 서비스를 설정하고 구현하려면 [Android Firebase 문서](https://firebase.google.com/docs/cloud-messaging/android/receive)의 안내를 따르세요.

설정이 완료되면 onMessageReceived() 메서드를 재정의하고 스루를 RemoteMessage`NowPushService`에 전달합니다. `NowPushService`가 알림을 인식하면 알림을 처리하고 애플리케이션이 처리할 알림 객체를 반환합니다. 현재 유일하게 구현된 알림은 `NowPushVirtualAgent`입니다. 알 수 없는 알림이 `NotSupportedPushError` 객체를 반환합니다.

    //Custom coroutineScope created in the Firebase service class
    private val serviceCoroutineScope = CoroutineScope(Dispatchers.IO)

    override fun onMessageReceived(remoteMessage: RemoteMessage) {
      serviceCoroutineScope.launch {
        val result = handleNowPush(remoteMessage)

        if (result.isSuccess) {
          when (val push = result.getOrNull()) {
            is NowPushVirtualAgent -> handleVirtualAgentPush(push)
          }
        } else {
          // Not a NowPush. Handle host app push notification message here
        }
      }
    }

    private suspend fun handleNowPush(remoteMessage: RemoteMessage): Result<NowPushPayload> {
      val nowPushService = sdkManager.getNowPushService()

      return suspendCoroutine { cont ->
        nowPushService?.handlePush(remoteMessage,
          { cont.resume(Result.success(it)) }, { cont.resumeWithException(it) })
      }
    }

handlePush() 메서드에 대한 자세한 내용은 을 참조하십시오[NowPushService - handlePush(remoteMessage: RemoteMessage, successCallback: Consumer\<NowPushPayload\>, errorCallback: Consumer\<Throwable\>)](https://servicenow-prod.fluidtopics.net/qQOfWJFOtDKGjHeCLH~QYQ#NPushServ-handlePush_S_O_O "푸시 알림 요청을 처리합니다.").

또한 onNewToken(token: String)을 재정의해야 합니다. "푸시 토큰 등록" 섹션에서 수행한 작업과 유사하게 토큰을 pushService.registerPushToken()으로 전달해야 합니다.

