본문 바로가기
#모바일 [Mobile]/iOS

[iOS] Apple 푸쉬 알림 서비스 (APNs, Apple Push Notification service)

by cy_mos 2021. 11. 16.
반응형
카테고리 (Category) 작성 날짜 (Write Date) 최근 수정 날자 (Recent Write Date) 작성자 (Writer)
iOS 2021년 11월 16일 15시 12분 2021월 11월 22일 20시 25분 Dev.Yang

 

Apple Push Notification service

 

Apple Push Notification service (Apple Notification Service, APNs)는 애플에서 개발 한 알림 서비스이며, 해당 기능은 푸쉬 알림을 받을 애플리케이션이 설치 된 애플 장비에 알림 정보를 전송하는 기능입니다. 알림을 통하여 보낼 수 있는 정보는 Badges, Sounds, Newsstand Updates, Text 등을 사용자에게 전송할 수 있습니다.

 

즉, Apple 장비들은 서버로부터 직접적인 통신하여 푸쉬 알림 서비스를 제공할 수 없습니다. 오직 APNs를 통하여 서버로 부터 푸쉬 알림 서비스를 제공받을 수 있습니다.

 

Apple Push Notification service (Apple Notification Service, APNs)에 대한 구동방식은 Provider (= 알림 서비스를 제공하는 서버), APNs, Client Application (= 알림 서비스를 받는 사용자) 대상들을 중심으로 구동이 이루어집니다.

 

  • APNS(Apple 푸시 알림 서비스)를 이용하려면 macOS, iOS, tvOS 및 watchOS 기기가 이더넷이나 셀룰러 데이터(사용 가능한 경우) 또는 Wi-Fi를 통해 Apple 서버에 지속적으로 연결되어 있어야 합니다.
  • APNs 사용하기 위해서는 아래의 명시 된 포트에 대하여 허용하여야 합니다.
    • APNS와 통신할 경우 TCP 포트 5223번
    • APNS에 알림을 보낼 경우 TCP 포트 443번 또는 2197번
    • 그 이외에 추가적인 네트워크 호스트 정보는 Apple 기기에서 Apple 푸시 알림을 받지 못하는 경우 문서를 확인하시면 됩니다.

🛠 첫 번째, Provider to APNs 구동방식

Establishing and using token-based provider connection trust

  1. Provider는 APNs는TLS(Transport Layer Security)를 사용하여 통신하며, 통신을 위한 APNs Certificate를 요청합니다.
  2. APNs는 Provider에게 유효한 APNs Certificate를 제공합니다.
  3. Apple Developer 계정을 통해서 얻은 Provider Certificate를 APNs에 전송합니다.
  4. APNs는 Provider에게 제공받은 Provider Certificate를 검증하여 Provider와 TLS 통신을 통하여 연결합니다.

[추가정보]

  • Provider는 제공받은 APNs Certificate를 사용하여 Provider는 APNs와 TLS 통신이 연결 된 상태에서, 사용자에게 Push Notification 보낼 때 JWT Authentication Token 포함하여 APNs에 전송합니다.
  • Provider에게 전송받은 Push Notification 작업은 HTTP/2 response 형태로 응답합니다.

🛠 두 번째, APNs to Client Application 구동방식

Establishing connection trust between a device and APNs

 

  1. Device는 APNs는TLS(Transport Layer Security)를 사용하여 통신하며, 통신을 위한 APNs Certificate를 요청합니다.
  2. APNs는 Device에게 유효한 APNs Certificate를 제공합니다.
  3. Device는 APNs에게 유효한 Device Certificate를 제공합니다.
  4. APNs는 Device로부터 제공받은 Device Certificate를 검증하여 APNs와 TLS 통신을 통하여 연결합니다.

[추가정보]

  • APNs와 Device간에 TLS 연결이 설정 된 경우에 애플리케이션은 Push Notification Service를 받기위해 APNs에 등록하여 Device내에 애플리케이션 별 Device Token을 받을 수 있습니다. Device Token을 받는 방법은 아래의 이미지와 같습니다.

 

Managing the device token

  1. 위의 Device와 APNs 통신과정을 통하여 연결을 수행합니다.
  2. APNs는 이전에 받은 Device Certificate를 통하여 Device Token을 생성합니다. 생성 된 Device Token은 암호화 작업을 통하여 Device에게 전달합니다.
  3. 전달받은 Device Token은 Provider에게도 전달합니다.

🛠 세 번째, 전체적인 구동방식

Remote notification path from provider to device

  1. Device는 APNs로 부터 제공받은 암호화 된 Device Token을 APNs에 전달하면서 연결 요청 작업을 수행합니다.
  2. 암호화 된 Device Token을 제공받은 APNs는 이전에 제공받은 Device Certificate를 사용하여 Device Token을 복호화합니다. 그리고 복호화 된 Device Token 값을 검증하여 Device 연결 요청 작업을 승인합니다.
  3. Device에게 보낼 자료가 있는 Provicder는 Device에게 제공받은 “Device Token, Payload”를 APNs에게 전달합니다.
  4. APNs는 Provider에게 전달받은 Device Token를 바탕으로 해당 Device Token을 등록 한 Device에게 “Device Token, Payload”를 Device에게 전달합니다.

🚀 REFERENCE

 

Local and Remote Notification Programming Guide: APNs Overview

Apple Push Notification service (APNs) is the centerpiece of the remote notifications feature. It is a robust, secure, and highly efficient service for app developers to propagate information to iOS (and, indirectly, watchOS), tvOS, and macOS devices. On i

developer.apple.com

 

Apple Push Notification service - Wikipedia

Apple Push Notification service (commonly referred to as Apple Notification Service or APNs) is a platform notification service created by Apple Inc. that enables third party application developers to send notification data to applications installed on App

en.wikipedia.org

 

반응형

댓글