Skip to content

Commit 2e2f1a2

Browse files
committed
feat: Create module to support library-specific enumeration types
Motivation: We never know when we might be implementing or extending the `django-push-notifications` library beyond its current support. It makes sense to have a module to handle critical moments such as that raised in #708 (for `interruption-levels`). This gives control over newly implemented interfaces without having to worry about outdated modules, such as `PyAPNS2`. This allows us to provide wrapper or extend existing library functionalities. Context: This patch address one side of issue by providing an enumeration module that can be used to deal with public and underlying APIs.
1 parent 9bf5fda commit 2e2f1a2

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

push_notifications/enums.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
"""
2+
Enumeration Types for public-facing interfaces.
3+
4+
This module contains enumeration types that are used in public-facing and underlying interfaces of the package -
5+
such as the `InterruptionLevel` of Apple's User Notification System and others.
6+
7+
Created: 2024-03-27 14:13
8+
"""
9+
10+
from enum import Enum, StrEnum
11+
12+
13+
class InterruptionLevel(Enum):
14+
"""
15+
Enumeration of the interruption levels of Apple's User Notification System.
16+
17+
The interruption levels are used to determine the priority of a notification and the way (delivery timing) it is displayed to the user.
18+
19+
Ref: https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel
20+
"""
21+
22+
# The notification is displayed as an alert.
23+
ACTIVE = 0
24+
25+
# The notification is displayed as a time-sensitive alert.
26+
#
27+
# Time-sensitive alerts are displayed immediately,
28+
# even when the device is in Do Not Disturb mode or the notification is set to be delivered silently.
29+
TIME_SENSITIVE = 1
30+
31+
# The notification is displayed as a critical alert.
32+
# Bypasses the Do Not Disturb mode and the silent mode to deliver the notification.
33+
CRITICAL_ALERT = 2
34+
35+
# The notification is displayed as a passive notification.
36+
# Pushes the notification to the Notification Center (or list), essentially making it a silent notification.
37+
PASSIVE = 3

0 commit comments

Comments
 (0)