Skip to content

A Python package for quickly Creating, Sending & Managing Android notifications with support for various notifications styles in Kivy and Flet apps.

Notifications You must be signed in to change notification settings

Fector101/android_notify

Repository files navigation


Android-Notify

Android Notify is a Python library for effortlessly creating and managing Android notifications in Kivy and Flet apps.

Supports various styles and ensures seamless integration, customization and Pythonic APIs.

Features

  • Multiple Notification Styles: Support for various notification styles including:

    • Simple text notifications
    • Progress bar notifications (determinate and indeterminate)
    • Large icon notifications
    • Big picture notifications
    • Combined image styles
    • Custom notification Icon - images section
    • Big text notifications
    • Inbox-style notifications
    • Colored texts and Icons
  • Rich Functionality:

    • Add action buttons with custom callbacks
    • Update notification content dynamically
    • Manage progress bars with fine-grained control
    • Custom notification channels for Android 8.0+ (Creating and Deleting)
    • Silent notifications
    • Persistent notifications
    • Click handlers and callbacks
    • Cancel Notifications

Quick Start

from android_notify import Notification

# Simple notification
Notification(
    title="Hello",
    message="This is a basic notification."
).send()

Sample Image:
basic notification img sample

Installation

Kivy apps:

In your buildozer.spec file, ensure you include the following:

# Add pyjnius so ensure it's packaged with the build
requirements = python3, kivy, pyjnius, android-notify
# Add permission for notifications
android.permissions = POST_NOTIFICATIONS

# Required dependencies (write exactly as shown, no quotation marks)
android.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0
android.enable_androidx = True
android.api = 35

Flet apps:

In your pyproject.toml file, ensure you include the following:

[tool.flet.android]
dependencies = [
  "pyjnius","https://github.com/Fector101/android_notify/archive/without-androidx.zip"
]

[tool.flet.android.permission]
"android.permission.POST_NOTIFICATIONS" = true

Installing without Androidx

How to use without gradle_dependencies Use https://github.com/Fector101/android_notify/archive/without-androidx.zip to install via pip

In Kivy

# buildozer.spec
requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/without-androidx.zip

On Pydroid 3

On the pydroid 3 mobile app for running python code you can test some features.

  • In pip section where you're asked to insert Libary name paste https://github.com/Fector101/android_notify/archive/without-androidx.zip
  • Minimal working example
# Testing with `https://github.com/Fector101/android_notify/archive/without-androidx.zip` on pydroid
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.uix.button import Button
from android_notify import Notification
from android_notify.core import asks_permission_if_needed


class AndroidNotifyDemoApp(App):
    def build(self):
        layout = BoxLayout(orientation='vertical', spacing=10, padding=20)
        layout.add_widget(Button(
            text="Ask Notification Permission",
            on_release=self.request_permission
        ))
        layout.add_widget(Button(
            text="Send Notification",
            on_release=self.send_notification
        ))
        return layout

    def request_permission(self, *args):
        asks_permission_if_needed(no_androidx=True)

    def send_notification(self, *args):
        Notification(
            title="Hello from Android Notify",
            message="This is a basic notification.",
            channel_id="android_notify_demo",
            channel_name="Android Notify Demo"
        ).send()


if __name__ == "__main__":
    AndroidNotifyDemoApp().run()

For IDE IntelliSense Can be installed via pip install:

pip install android_notify
android-notify -v

Documentation

For Dev Version use requirements = python3, kivy, pyjnius, https://github.com/Fector101/android_notify/archive/main.zip

To use colored text in your notifications:

  • Copy the res folder to your app path.
    Lastly in your buildozer.spec file
  • Add source.include_exts = xml and android.add_resources = ./res

For full documentation, examples, and advanced usage, API reference visit the documentation

☕ Support the Project

If you find this project helpful, consider buying me a coffee! 😊 Or Giving it a star on 🌟 GitHub Your support helps maintain and improve the project.

Buy Me A Coffee

About

A Python package for quickly Creating, Sending & Managing Android notifications with support for various notifications styles in Kivy and Flet apps.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages