Notification Manager
Ce contenu n’est pas encore disponible dans votre langue.
Introduction
Section titled “Introduction”Working with the Notification Manager allows you to:
- Replacing a built-in notification service with a custom implementation.
- Disabling one or more notification services at runtime.
- Discovering which schemas and plugins are currently available.
- Safely handling schema conflicts caused by decorators or import order.
If you are trying to override a built-in service (for example, Discord), the recommended solution is:
from apprise.plugins import N_MGR
N_MGR.add(MyCustomNotify, schemas="discord", force=True)The Notification Manager is the central registry responsible for discovering, registering, and resolving notification plugins within Apprise.
It maps notification URL schemas such as schema://... to their corresponding Python
implementation and controls whether those implementations are enabled, disabled, or overridden.
The manager is a singleton and is typically accessed via:
from apprise.plugins import N_MGRCore Concepts
Section titled “Core Concepts”Schema Mapping
Section titled “Schema Mapping”A schema maps to exactly one notify implementation at a time.
- Any URL beginning with
schema://routes to the notify class registered for that schema. - Schemas are case-insensitive and normalized internally.
- By default, schema collisions are rejected to prevent accidental overrides.
Lazy Loading
Section titled “Lazy Loading”The manager uses lazy loading:
- Built-in plugins are discovered only when needed.
- Most operations trigger discovery automatically.
- Calling
load_modules()forces immediate discovery.
Custom Plugin Loading
Section titled “Custom Plugin Loading”Custom notification plugins can be introduced in two ways:
- Python classes discovered via plugin search paths.
- Decorator-based custom notifications created using the
@notifydecorator.
Decorator-based notifications are wrapped and registered through the same manager APIs as class-based plugins.
API Reference
Section titled “API Reference”Registers a notification plugin or decorator wrapper for one or more schemas.
Definition:
add(plugin, *, schemas=None, force=False)Behaviour:
- Fails if a schema already exists.
- Supports registering multiple schemas at once.
- Does not modify existing mappings unless explicitly forced.
Example:
N_MGR.add(MyNotifyClass, schemas="schema")remove()
Section titled “remove()”Removes one or more schema mappings from the registry.
Definition:
remove(*schemas, unload=True)Behaviour:
- By default, removes the schema mapping and may unload unused modules.
- Supports removing multiple schemas in a single call.
Example:
N_MGR.remove("schema1", "schema2")disable()
Section titled “disable()”Disables one or more notification services without removing their schema mappings.
Definition:
disable(*schemas)Behaviour:
- Prevents usage while preserving registration state.
- Supports disabling multiple schemas at once.
Example:
N_MGR.disable("schema1", "schema2")enable()
Section titled “enable()”Re-enables previously disabled notification services.
Definition:
enable(*schemas)Behaviour:
- Restores availability of disabled schemas.
- Has no effect if a schema was not disabled.
load_modules()
Section titled “load_modules()”Forces immediate discovery of built-in notification plugins.
Definition:
load_modules()Behavioural Notes
Section titled “Behavioural Notes”Unmap vs Unload
Section titled “Unmap vs Unload”Removing a schema can mean:
-
Unmap only
The schema mapping is removed, but imported Python modules remain loaded. -
Unmap and unload
The schema mapping is removed and unused modules may be removed from memory.
Unloading modules can affect third-party code that imports or subclasses notify classes. Use unmap-only behaviour when class identity stability matters.
Force Overrides
Section titled “Force Overrides”Using force=True when calling add():
- Removes any existing mapping for the schema.
- Does not unload previously imported modules.
- Registers the new implementation atomically.
This is the recommended way to replace built-in services.
Import Order and Decorators
Section titled “Import Order and Decorators”Decorator-based notifications may register schemas at import time.
If ordering is uncertain, force=True ensures predictable behaviour regardless of when modules are loaded.
Examples
Section titled “Examples”Replace a Built-in Service
Section titled “Replace a Built-in Service”N_MGR.add(MyCustomNotify, schemas="discord", force=True)Disable vs Remove
Section titled “Disable vs Remove”# Disable schema - can be enabled again using N_MGR.enable("schema")N_MGR.disable("schema")
# Remove completelyN_MGR.remove("schema")Multiple Schema Operations
Section titled “Multiple Schema Operations”N_MGR.disable("schema1", "schema2")N_MGR.remove("schema3", "schema4", unload=False)Troubleshooting
Section titled “Troubleshooting”Schema Already Defined
Section titled “Schema Already Defined”If a schema already exists, registration will fail unless explicitly overridden. Consider:
- Choosing a unique schema.
- Use
add(..., force=True)for intentional overrides.
Import-Order Issues
Section titled “Import-Order Issues”If schemas are registered during module import, conflicts may occur before manual intervention.
Using force=True avoids these timing issues.