Search

[정리] Local Notification

contents

Local Notification

content trigger request
content
사용자에게 어떤 내용을 보여줄지에 대한 정보를 담고 있습니다.
title body badge number userInfo attachments 등이 있습니다.
userInfo : 원하는 정보를 모두 담을 수 있는 Dictionary
→ 사용자가 알림을 눌렀을 때, userInfo에 들어있는 정보를 접근하여 활용
trigger
3가지 타입 time calendar location이 있습니다.
time : 일정시간이 지난 후에 작동되길 원한다
calendar : 특정한 날짜에 작동하기 원한다
location : 특정 위치에 진입할 경우 혹은 나갈 경우에 작동하길 원한다
request
content와 trigger를 가지고 로컬 푸쉬를 등록하기 위해 생성해야 함
생성하기 위해서 identifier를 꼭 지정해야 합니다.
→ 해당 알림을 취소하거나 핸들링할 때 사용
알림을 받고난 후의 이벤트를 핸들링하기 위해선 UNUserNotificationCenterDelegate를 conform함으로서 해결할 수 있습니다.
: AppDelegate의 함수인 application 에서 할당해야 합니다. 만약 이 함수가 호출된 이후에 delegate를 할당하게 된다면 인입되는 알림을 놓칠 수 있습니다.

UN

UNAuthorizationOptions
badge : app badge
sound : play sounds
alert : display alerts
carplay : display notifications in a CarPlay environment
criticalAlert : mute or Do Not Disturb setting를 무시하고 알림을 실행합니다.
providesAppNotificationSettings : in-app notification setting 버튼이 보이게 합니다.
provisional : 알림 센터에 임시로 중단되지 않는 알림을 게시하는 기능
UNNotificationAttachment
alert-based Notification에 오디오, 이미지, 비디오 컨텐츠를 함께 넣고 싶은 경우에 생성합니다.
썸네일의 경우에는 UNNotificationAttachmentOptionsThumbnailClippingRectKey 옵션을 사용하면 됩니다.(image) 움직이는 이미지나 영상의 경우는 UNNotificationAttachmentOptionsThumbnailTimeKey 옵션을 사용하면 됩니다.