Skip to content

Commit

Permalink
feat: Create module to support library-specific enumeration types
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
50-Course committed Mar 28, 2024
1 parent 9bf5fda commit 2e2f1a2
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions push_notifications/enums.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
"""
Enumeration Types for public-facing interfaces.
This module contains enumeration types that are used in public-facing and underlying interfaces of the package -
such as the `InterruptionLevel` of Apple's User Notification System and others.
Created: 2024-03-27 14:13
"""

from enum import Enum, StrEnum


class InterruptionLevel(Enum):
"""
Enumeration of the interruption levels of Apple's User Notification System.
The interruption levels are used to determine the priority of a notification and the way (delivery timing) it is displayed to the user.
Ref: https://developer.apple.com/documentation/usernotifications/unnotificationinterruptionlevel
"""

# The notification is displayed as an alert.
ACTIVE = 0

# The notification is displayed as a time-sensitive alert.
#
# Time-sensitive alerts are displayed immediately,
# even when the device is in Do Not Disturb mode or the notification is set to be delivered silently.
TIME_SENSITIVE = 1

# The notification is displayed as a critical alert.
# Bypasses the Do Not Disturb mode and the silent mode to deliver the notification.
CRITICAL_ALERT = 2

# The notification is displayed as a passive notification.
# Pushes the notification to the Notification Center (or list), essentially making it a silent notification.
PASSIVE = 3

0 comments on commit 2e2f1a2

Please sign in to comment.