---
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


---

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

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

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

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

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

애플리케이션에서 가장 먼저 수행해야 할 작업 중 하나는 `NowPushService`를 만드는 것입니다. `NowPush` SDK는 이 서비스를 만드는 팩토리 기능을 제공합니다. 기본 코드 본문 초기에 다음 코드 조각과 유사한 코드를 추가합니다.

    func setup(with instanceURL: URL) -> AnyPublisher<NowService, ConfigurationError> {
      NowPush.makePushService(instanceUrl: instanceURL)
        .mapError { .sdkError($0) }
        .map { $0 as NowService }
        .eraseToAnyPublisher()
    }

NowPush.makePushService() 메서드에 대한 자세한 내용은 다음 문서를 [NowPush API - iOS](https://servicenow-prod.fluidtopics.net/Ba6zc0FpaT5siXUY7oDqbQ#NowPushiOSAPI "NowPush API는 사용자가 NowPush 서비스 인스턴스를 인스턴스화할 수 있는 최상위 전역 API입니다.")참조하십시오.

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

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

    func registerForPushNotifications(deviceToken: Data) {
      pushService.registerPushToken(deviceToken,
          pushAppName: "TestPushApp", // Modify this to be your iOS application name
          environment: environment) { [weak self] result in
        guard let self = self else { return }
        switch result {
        case .success:
          UserDefaults.standard.set(true, forKey: "pushNotificationsRegistered")
          self.pushRegistrationState = .registrationSuccess
        case .failure:
          UserDefaults.standard.set(false, forKey: "pushNotificationsRegistered")
          self.pushRegistrationState = .registrationFailed
        }
      }
    }

registerPushToken() 메서드에 대한 자세한 내용은 을 참조하십시오[NowPushService - registerPushToken(_token: 데이터, pushAppName: 문자열, 환경: NowPushEnvironment, 완료: @escaping(결과\<데이터, NowPushError\>) -\> 무효)](https://servicenow-prod.fluidtopics.net/m40RHsyjLxVTGIfAaYwO0g#NPushServ-registerPushToken_O_S_O_O "현재 iOS 장치 및 지정된 애플리케이션에 대한 푸시 알림을 식별하는 데 사용되는 인스턴스에 ServiceNow 고유 토큰을 등록합니다.").

## 푸시 토큰 등록 취소

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

    func unregisterFromPushNotifications(deviceToken: Data) {
      pushService.unregisterPushToken(deviceToken, pushAppName: "TestPushApp", environment: environment) { [weak self] result in
        guard let self = self else { return }
        switch result {
        case .success:
          UserDefaults.standard.set(false, forKey: "pushNotificationsRegistered")
          self.pushRegistrationState = .unregisterSuccess
        case .failure:
          self.pushRegistrationState = .unregisterFailed
        }
      }
    }

unregisterPushToken() 메서드에 대한 자세한 내용은 을 참조하십시오[NowPushService - unregisterPushToken(_token: 데이터, pushAppName: 문자열, 환경: NowPushEnvironment, 완료: @escaping(결과\<데이터, NowPushError\>) -\> 무효)](https://servicenow-prod.fluidtopics.net/m40RHsyjLxVTGIfAaYwO0g#NPushServ-unregisterPushToken_O_S_O_O "이전에 등록된 푸시 토큰의 등록을 취소합니다.").

## 푸시 페이로드 구문 분석 {#mobsdk-ios-setup-push-app__section_ofn_dlw_trb}

정보를 수집하고 애플리케이션의 다른 부분에서 데이터를 사용하려면 푸시 알림 페이로드를 `NowPushPayload` 객체로 구문 분석해야 합니다. 현재 가상 에이전트 푸시 알림에만 사용할 수 있습니다. 다음과 유사한 코드를 사용합니다.

    func userNotificationCenter(_ center: UNUserNotificationCenter,
        didReceive response: UNNotificationResponse,
        withCompletionHandler completionHandler: @escaping () -> Void) {
      guard let pushService = pushService else {
        completionHandler()
        return
      }
      let userInfo = response.notification.request.content.userInfo
      _ = pushService.payloadFromUserInfo(userInfo)
        .flatMap(handleNowPushPayload)
    }

    func handleNowPushPayload(_ payload: NowPushPayload) -> Result<Void, NowPushError> {
      guard payload is NowPushVirtualAgent else {
        return .failure(NowPushError.unsupportedData)
      }
      launchVirtualAgent()
      return .success(())
    }


