-
[iOS] Remote Notification 개념 정리iOS 2024. 3. 15. 00:05
앱 유지 및 보수 중 공지사항 알림기능을 추가하기 위해 Remote Notification 작업을 해야한다.
작업을 하면서 대충 이해하고 넘어가지 않고 스스로 정리를 하면서 진행하기 위해 기록해보려고 한다.
Notification 종류
- Local Notification - 앱에서 직접 주는 Notification
- Remote Notification - 서버와 같은 원격(Remote)에서 주는 Notification
APNs
APNs는 Apple Push Notification Service의 약자로, 앱에 푸시 알람을 보낼 수 있도록 애플이 만든 알람 서비스 플랫폼이다.
앱에 알람을 보내기 위해서는 반드시 APNs를 거쳐야 한다는 것이다.(local 제외)
Push 알림 동작 과정
- App이 APNs에게 Device Token을 요청한다.(Device Token: 푸시가 전송되는 앱의 주소)
- APNs가 App에게 Device Token을 알려준다.
- App이 Push Server에 Device Token을 보낸다
https://developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_serverProvider Server가 앱에 알람을 보내는 과정
4. Provider Server가 APNs에 앱으로부터 받은 Device Token과 메시지 데이터를 같이 보낸다.
5. APNs는 Provider Server로부터 받은 Device Token을 가지고 메시지 데이터를 보낸다.
6. 해당 Device에 알림이 뜬다.
Push 알람의 데이터 형식
Provider Server가 Device Token과 함께 보내는 메시지 데이터의 형식은
JSON 형태여야 하며, payload가 256Byte를 초과하지 않는 작은 크기여야 한다.
{ "aps" : { "alert" : { "body" : "great match!", "title" : "Portugal vs. Denmark", }, "badge" : 1, }, "customKey" : "customValue" }
[참고]
https://zeddios.tistory.com/1373
https://babbab2.tistory.com/58
https://firebase.google.com/docs/cloud-messaging/ios/receive?hl=ko
'iOS' 카테고리의 다른 글
[iOS] Moya를 사용한 Networking (0) 2024.03.17 [iOS] 푸시 알림에서 받은 url을 웹뷰에 띄우기, postman 푸시 테스트 (0) 2024.03.15 [iOS] Push Notification 메소드 정리 (0) 2024.03.15 [iOS] FCM으로 Push Notification 구현하기 (0) 2024.03.15