티스토리 뷰

Mobile/iOS

iOS background push에 관해서

out of coding 2020. 10. 3. 10:40

Android와 iOS의 push는 다르게 동작합니다.

 

Android는 전달되고 나서 개발자가 Notification을 표시하여주게 할지에 대해서 결정하기 때문에 background에서 동작 가능하도록 할 수 있습니다. 태생이 그러니...

 

iOS는 OS에서 받아서 각 앱에 전달을 하여 주는데 이 경우에 Notification을 표현을 하여 줍니다.

앱이 백그라운드 일 경우에 말이죠...

 

그래서 이것과 비슷하게 content-available값을 포함을 시켜서 백그라운드에 전달되도록 할 수가 있습니다.

이렇게 하면 Android와 비슷하게 동작 합니다.

 

하지만 이런 기능을 마구잡이로 풀어줄리가 없죠.

제약이 있는데요. 다음과 같습니다.

 

  1. 낮은 우선순위로 취급합니다.
  2. 알림의 전달성 보장을 하지 않습니다. (원래도 100%는 아닌데...)
  3. 시스템 기준의 최대 제한이 초과 될 경우에 전달이 되지 않음. (Local Push의 경우에도 64개의 제한이 있습니다.)

이 제약은 iOS 13에서 더 강력해졌습니다.

 

13부터는 push header에 apns-push-type, apns-priority 속성을 추가해야 한다고 합니다.

  • apns-push-type은 background or alert를 설정 가능합니다.
  • apns-priority은 5 or 10을 가질수 있습니다. (5가 그래도 더 보장을 하여주는 수치)

그래서 background push의 경우에는 다음과 같이 설정하여야 합니다.

  • content-available: 1
  • apns-push-type: "background"
  • apns-priority: 5

참고하실 점들

apple push

developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/sending_notification_requests_to_apns#2947607

 

Apple Developer Documentation

 

developer.apple.com

apple background push

developer.apple.com/documentation/usernotifications/setting_up_a_remote_notification_server/pushing_background_updates_to_your_app

 

Apple Developer Documentation

 

developer.apple.com

참고로 push receive는 다음의 delegate로 들어오게 됩니다.

애플 문서에 가서 확인 해주세요.

application(_:didReceiveRemoteNotification:fetchCompletionHandler:)

 

Apple Developer Documentation

 

developer.apple.com

마지막으로 한가지 용어가 헷갈릴까봐 말씀을 드리면 제가 background라고 표현을 하였지만

application이 background에서 push를 받는것이 아니라 Notification이 표시되지 않도록 push를 하는 것입니다.

 

댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
«   2024/04   »
1 2 3 4 5 6
7 8 9 10 11 12 13
14 15 16 17 18 19 20
21 22 23 24 25 26 27
28 29 30
글 보관함