<div align="center">
<br>
<h1> Android-Notifiy </h1>
<p> A Python library for effortlessly creating and managing Android notifications in Kivy android apps.</p>
<p>Supports various styles and ensures seamless integration and customization.</p>
<!-- <br> -->
<!-- <img src="https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/democollage.jpg"> -->
</div>
## Features
- Also Compatible with Android 8.0+.
- Supports including images in notifications.
- Support for multiple notification styles:
- [Simple](#basic-usage)
- [Progress](#progress-bar-notification)
- [Big Picture](#notification-with-an-image-big-picture-style)
- [Inbox](#inbox-notification-style)
- [Large Icon](#notification-with-an-image-large-icon-style)
- [Buttons](#notification-with-buttons)
- [Big Text](#big-text-notification-will-display-as-simple-text-if-device-dosent-support)
This module automatically handles:
- Permission requests for notifications
- Customizable notification channels.
## Installation
This package is available on PyPI and can be installed via pip:
```bash
pip install android-notify
```
## **Dependencies**
**Prerequisites:**
- Kivy
In your **`buildozer.spec`** file, ensure you include the following:
```ini
# 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
```
---
## Basic Usage
```python
from android_notify import Notification
# Create a simple notification
notification = Notification(
title="Hello",
message="This is a basic notification."
)
notification.send()
```
**Sample Image:**
![basic notification img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/basicnoti.jpg)
## Notification Styles
The library supports multiple notification styles:
1. `simple` - Basic notification with title and message
2. `progress` - Shows a progress bar
3. `big_text` - Expandable notification with long text
4. `inbox` - List-style notification
5. `big_picture` - Notification with a large image
6. `large_icon` - Notification with a custom icon
7. `both_imgs` - Combines big picture and large icon
8. `custom` - For custom notification styles
### Style Examples
#### Progress Bar notification
```python
from kivy.clock import Clock
notification = Notification(
title="Downloading...",
message="0% downloaded",
style="progress",
progress_max_value=100,
progress_current_value=0
)
notification.send()
Clock.schedule_once(lambda dt: notification.updateProgressBar(30, "30% downloaded"), 350)
```
**Sample Image:**
![progress img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/progress.jpg)
#### Notification with an Image (Big Picture Style)
```python
# Image notification
notification = Notification(
title='Picture Alert!',
message='This notification includes an image.',
style="big_picture",
big_picture_path="assets/imgs/photo.png"
)
notification.send()
```
**Sample Image:**
![big_picture img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/bigpicturenoti.jpg)
#### Inbox Notification Style
```python
# Send a notification with inbox style
notification = Notification(
title='Inbox Notification',
message='Line 1\nLine 2\nLine 3',
style='inbox'
)
notification.send()
```
**Sample Image:**
![Inbox Notification sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/inboxnoti.jpg)
#### Notification with an Image (Large Icon Style)
```python
notification = Notification(
title="Completed download",
message="profile.jpg",
style="large_icon",
large_icon_path="assets/imgs/profile.png"
)
```
**Sample Image:**
![large_icon img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/large_icon.jpg)
#### Notification with Buttons
```python
notification = Notification(title="Jane Dough", message="How to use android-notify #coding #purepython")
def playVideo():
print('Playing Video')
def turnOffNoti():
print('Please Turn OFf Noti')
def watchLater():
print('Add to Watch Later')
notification.addButton(text="Play",on_release=playVideo)
notification.addButton(text="Turn Off",on_release=turnOffNoti)
notification.addButton(text="Watch Later",on_release=watchLater)
notification.send()
```
**Sample Image:**
![btns img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/btns.jpg)
#### Big text notification (Will Display as normal text if Device dosen't support)
```python
notification = Notification(
title="Article",
message="Long article content...",
style="big_text"
)
```
## Advanced Features
### Updating Notifications
```python
notification = Notification(title="Initial Title")
notification.send()
# Update title
notification.updateTitle("New Title")
# Update message
notification.updateMessage("New Message")
```
### Progress Bar Management
```python
notification = Notification(
title="Download..",
style="progress"
)
# Update progress
notification.updateProgressBar(30, "30% downloaded")
# Remove progress bar
notification.removeProgressBar("Download Complete")
```
### Channel Management
Notifications are organized into channels. You can customize the channel name and ID:
- Custom Channel Name's Gives User ability to turn on/off specific
```python
notification = Notification(
title="Download finished",
message="How to Catch a Fish.mp4",
channel_name="Download Notifications", # Will create User-visible name "Download Notifications"
channel_id="downloads_notifications" # Optional: specify custom channel ID
)
```
**Sample Image:**
![channels img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/channel_name.jpg)
### Silent Notifications
To send a notification without sound or heads-up display:
```python
notification = Notification(title="Silent Update")
notification.send(silent=True)
```
### Assist
- How to Copy image to app folder
```python
import shutil,os # These modules come packaged with python
from android.storage import app_storage_path # type: ignore -- This works only on android
app_path = os.path.join(app_storage_path(),'app')
image_path= "/storage/emulated/0/Download/profile.png"
shutil.copy(image_path, os.path.join(app_path, "profile.png"))
```
- Avoiding Human Error when using different notification styles
```python
from android_notify import Notification, NotificationStyles
Notification(
title="New Photo",
message="Check out this image",
style=NotificationStyles.BIG_PICTURE,
big_picture_path="assets/imgs/photo.png"
).send()
```
## Development Mode
When developing on non-Android platforms, the library provides debugging output:
```python
# Enable logs (default is True when not on Android)
Notification.logs = True
# Create notification for testing
notification = Notification(title="Test")
notification.send()
# Will print notification properties instead of sending
```
## Image Requirements
- Images must be located within your app's folder
- Supported paths are relative to your app's storage path
- Example: `assets/imgs/icon.png`
## Error Handling
The library validates arguments and provides helpful error messages:
- Invalid style names will suggest the closest matching style
- Invalid arguments will list all valid options
- Missing image files will raise FileNotFoundError with the attempted path
## Limitations
1. Only works on Android devices
2. Images must be within the app's storage path
3. Channel names are limited to 40 characters
4. Channel IDs are limited to 50 characters
## Best Practices
1. Always handle permissions appropriately
2. Use meaningful channel names for organization
3. Keep progress bar updates reasonable (don't update too frequently)
4. Test notifications on different Android versions
5. Consider using silent notifications for frequent updates
## Debugging Tips
1. Enable logs during development: `Notification.logs = True`
2. Check channel creation with Android's notification settings
3. Verify image paths before sending notifications
4. Test different styles to ensure proper display
Remember to check Android's notification documentation for best practices and guidelines regarding notification frequency and content.
## Contribution
Feel free to open issues or submit pull requests for improvements!
## Reporting Issues
Found a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.
## Author
- Fabian - <fector101@yahoo.com>
- GitHub: [Android Notify Repo](https://github.com/Fector101/android_notify)
- Twitter: [FabianDev_](https://twitter.com/intent/user?user_id=1246911115319263233)
For feedback or contributions, feel free to reach out!
---
## ☕ Support the Project
If you find this project helpful, consider buying me a coffee! 😊 Or Giving it a star on 🌟 [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project.
<a href="https://www.buymeacoffee.com/fector101" target="_blank">
<img src="https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png" alt="Buy Me A Coffee" height="60">
</a>
---
## Acknowledgments
- This Project was thoroughly Tested by the [Laner Project](https://github.com/Fector101/Laner/) - A application for Securely Transfering Files Wirelessly between your PC and Phone.
- Thanks to the Kivy and Pyjnius communities.
---
## 🌐 **Links**
- **PyPI:** [android-notify on PyPI](https://pypi.org/project/android-notify/)
- **GitHub:** [Source Code Repository](https://github.com/Fector101/android_notify/)
Raw data
{
"_id": null,
"home_page": "https://github.com/fector101/android-notify",
"name": "android-notify",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.6",
"maintainer_email": null,
"keywords": "android, notifications, kivy, mobile, post-notifications, pyjnius, android-notifications, kivy-notifications, python-android, mobile-development, push-notifications, mobile-app, kivy-application",
"author": "Fabian",
"author_email": "fector101@yahoo.com",
"download_url": "https://files.pythonhosted.org/packages/ca/e5/f601665b6b9032c86742a2d8dd738c4b9b3bd82b1756bdbf85adccb1f82d/android_notify-1.40.tar.gz",
"platform": null,
"description": "<div align=\"center\">\n <br>\n <h1> Android-Notifiy </h1>\n <p> A Python library for effortlessly creating and managing Android notifications in Kivy android apps.</p>\n <p>Supports various styles and ensures seamless integration and customization.</p>\n <!-- <br> -->\n <!-- <img src=\"https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/democollage.jpg\"> -->\n</div>\n\n## Features\n\n- Also Compatible with Android 8.0+.\n- Supports including images in notifications.\n- Support for multiple notification styles:\n - [Simple](#basic-usage)\n - [Progress](#progress-bar-notification)\n - [Big Picture](#notification-with-an-image-big-picture-style)\n - [Inbox](#inbox-notification-style)\n - [Large Icon](#notification-with-an-image-large-icon-style)\n - [Buttons](#notification-with-buttons)\n - [Big Text](#big-text-notification-will-display-as-simple-text-if-device-dosent-support)\n\nThis module automatically handles:\n\n- Permission requests for notifications\n- Customizable notification channels.\n\n## Installation\n\nThis package is available on PyPI and can be installed via pip:\n\n```bash\npip install android-notify\n```\n\n## **Dependencies**\n\n**Prerequisites:** \n\n- Kivy\n\nIn your **`buildozer.spec`** file, ensure you include the following:\n\n```ini\n# Add pyjnius so ensure it's packaged with the build\nrequirements = python3, kivy, pyjnius, android-notify\n\n# Add permission for notifications\nandroid.permissions = POST_NOTIFICATIONS\n\n# Required dependencies (write exactly as shown, no quotation marks)\nandroid.gradle_dependencies = androidx.core:core:1.6.0, androidx.core:core-ktx:1.15.0\nandroid.enable_androidx = True\n```\n\n---\n\n## Basic Usage\n\n```python\nfrom android_notify import Notification\n\n# Create a simple notification\nnotification = Notification(\n title=\"Hello\",\n message=\"This is a basic notification.\"\n)\nnotification.send()\n```\n\n**Sample Image:** \n![basic notification img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/basicnoti.jpg)\n\n## Notification Styles\n\nThe library supports multiple notification styles:\n\n1. `simple` - Basic notification with title and message\n2. `progress` - Shows a progress bar\n3. `big_text` - Expandable notification with long text\n4. `inbox` - List-style notification\n5. `big_picture` - Notification with a large image\n6. `large_icon` - Notification with a custom icon\n7. `both_imgs` - Combines big picture and large icon\n8. `custom` - For custom notification styles\n\n### Style Examples\n\n#### Progress Bar notification\n\n```python\nfrom kivy.clock import Clock\n\nnotification = Notification(\n title=\"Downloading...\",\n message=\"0% downloaded\",\n style=\"progress\",\n progress_max_value=100,\n progress_current_value=0\n)\nnotification.send()\nClock.schedule_once(lambda dt: notification.updateProgressBar(30, \"30% downloaded\"), 350)\n```\n\n**Sample Image:**\n![progress img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/progress.jpg)\n\n#### Notification with an Image (Big Picture Style)\n\n```python\n# Image notification\nnotification = Notification(\n title='Picture Alert!',\n message='This notification includes an image.',\n style=\"big_picture\",\n big_picture_path=\"assets/imgs/photo.png\"\n)\nnotification.send()\n\n```\n\n**Sample Image:**\n![big_picture img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/bigpicturenoti.jpg)\n\n#### Inbox Notification Style\n\n```python\n# Send a notification with inbox style\nnotification = Notification(\n title='Inbox Notification',\n message='Line 1\\nLine 2\\nLine 3',\n style='inbox'\n)\nnotification.send()\n\n```\n\n**Sample Image:**\n![Inbox Notification sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/inboxnoti.jpg)\n\n#### Notification with an Image (Large Icon Style)\n\n```python\nnotification = Notification(\n title=\"Completed download\",\n message=\"profile.jpg\",\n style=\"large_icon\",\n large_icon_path=\"assets/imgs/profile.png\"\n)\n\n```\n\n**Sample Image:** \n![large_icon img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/large_icon.jpg)\n\n#### Notification with Buttons\n\n```python\nnotification = Notification(title=\"Jane Dough\", message=\"How to use android-notify #coding #purepython\")\ndef playVideo():\n print('Playing Video')\n\ndef turnOffNoti():\n print('Please Turn OFf Noti')\n\ndef watchLater():\n print('Add to Watch Later')\n\nnotification.addButton(text=\"Play\",on_release=playVideo)\nnotification.addButton(text=\"Turn Off\",on_release=turnOffNoti)\nnotification.addButton(text=\"Watch Later\",on_release=watchLater)\nnotification.send()\n```\n\n**Sample Image:** \n![btns img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/btns.jpg)\n\n#### Big text notification (Will Display as normal text if Device dosen't support)\n\n```python\nnotification = Notification(\n title=\"Article\",\n message=\"Long article content...\",\n style=\"big_text\"\n)\n```\n\n## Advanced Features\n\n### Updating Notifications\n\n```python\nnotification = Notification(title=\"Initial Title\")\nnotification.send()\n\n# Update title\nnotification.updateTitle(\"New Title\")\n\n# Update message\nnotification.updateMessage(\"New Message\")\n```\n\n### Progress Bar Management\n\n```python\nnotification = Notification(\n title=\"Download..\",\n style=\"progress\"\n)\n\n# Update progress\nnotification.updateProgressBar(30, \"30% downloaded\")\n\n# Remove progress bar\nnotification.removeProgressBar(\"Download Complete\")\n```\n\n### Channel Management\n\nNotifications are organized into channels. You can customize the channel name and ID:\n\n- Custom Channel Name's Gives User ability to turn on/off specific\n\n```python\nnotification = Notification(\n title=\"Download finished\",\n message=\"How to Catch a Fish.mp4\",\n channel_name=\"Download Notifications\", # Will create User-visible name \"Download Notifications\"\n channel_id=\"downloads_notifications\" # Optional: specify custom channel ID\n)\n```\n\n**Sample Image:** \n![channels img sample](https://raw.githubusercontent.com/Fector101/android_notify/main/docs/imgs/channel_name.jpg)\n\n### Silent Notifications\n\nTo send a notification without sound or heads-up display:\n\n```python\nnotification = Notification(title=\"Silent Update\")\nnotification.send(silent=True)\n```\n\n### Assist\n\n- How to Copy image to app folder\n\n```python\nimport shutil,os # These modules come packaged with python\nfrom android.storage import app_storage_path # type: ignore -- This works only on android \n\napp_path = os.path.join(app_storage_path(),'app')\nimage_path= \"/storage/emulated/0/Download/profile.png\"\n\nshutil.copy(image_path, os.path.join(app_path, \"profile.png\"))\n```\n\n- Avoiding Human Error when using different notification styles\n\n```python\nfrom android_notify import Notification, NotificationStyles\nNotification(\n title=\"New Photo\",\n message=\"Check out this image\",\n style=NotificationStyles.BIG_PICTURE,\n big_picture_path=\"assets/imgs/photo.png\"\n).send()\n```\n\n## Development Mode\n\nWhen developing on non-Android platforms, the library provides debugging output:\n\n```python\n# Enable logs (default is True when not on Android)\nNotification.logs = True\n\n# Create notification for testing\nnotification = Notification(title=\"Test\")\nnotification.send()\n# Will print notification properties instead of sending\n```\n\n## Image Requirements\n\n- Images must be located within your app's folder\n- Supported paths are relative to your app's storage path\n- Example: `assets/imgs/icon.png`\n\n## Error Handling\n\nThe library validates arguments and provides helpful error messages:\n\n- Invalid style names will suggest the closest matching style\n- Invalid arguments will list all valid options\n- Missing image files will raise FileNotFoundError with the attempted path\n\n## Limitations\n\n1. Only works on Android devices\n2. Images must be within the app's storage path\n3. Channel names are limited to 40 characters\n4. Channel IDs are limited to 50 characters\n\n## Best Practices\n\n1. Always handle permissions appropriately\n2. Use meaningful channel names for organization\n3. Keep progress bar updates reasonable (don't update too frequently)\n4. Test notifications on different Android versions\n5. Consider using silent notifications for frequent updates\n\n## Debugging Tips\n\n1. Enable logs during development: `Notification.logs = True`\n2. Check channel creation with Android's notification settings\n3. Verify image paths before sending notifications\n4. Test different styles to ensure proper display\n\nRemember to check Android's notification documentation for best practices and guidelines regarding notification frequency and content.\n\n## Contribution\n\nFeel free to open issues or submit pull requests for improvements!\n\n## Reporting Issues\n\nFound a bug? Please open an issue on our [GitHub Issues](https://github.com/Fector101/android_notify/issues) page.\n\n## Author\n\n- Fabian - <fector101@yahoo.com>\n- GitHub: [Android Notify Repo](https://github.com/Fector101/android_notify)\n- Twitter: [FabianDev_](https://twitter.com/intent/user?user_id=1246911115319263233)\n\nFor feedback or contributions, feel free to reach out!\n\n---\n\n## \u2615 Support the Project\n\nIf you find this project helpful, consider buying me a coffee! \ud83d\ude0a Or Giving it a star on \ud83c\udf1f [GitHub](https://github.com/Fector101/android_notify/) Your support helps maintain and improve the project.\n\n<a href=\"https://www.buymeacoffee.com/fector101\" target=\"_blank\">\n <img src=\"https://cdn.buymeacoffee.com/buttons/v2/default-yellow.png\" alt=\"Buy Me A Coffee\" height=\"60\">\n</a>\n\n---\n\n## Acknowledgments\n\n- This Project was thoroughly Tested by the [Laner Project](https://github.com/Fector101/Laner/) - A application for Securely Transfering Files Wirelessly between your PC and Phone.\n- Thanks to the Kivy and Pyjnius communities.\n\n---\n\n## \ud83c\udf10 **Links**\n\n- **PyPI:** [android-notify on PyPI](https://pypi.org/project/android-notify/)\n- **GitHub:** [Source Code Repository](https://github.com/Fector101/android_notify/)\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "A Python package that simpilfies creating Android notifications in Kivy apps.",
"version": "1.40",
"project_urls": {
"Documentation": "https://github.com/fector101/android-notify/",
"Funding": "https://www.buymeacoffee.com/fector101",
"Homepage": "https://github.com/fector101/android-notify",
"Source": "https://github.com/fector101/android-notify",
"Tracker": "https://github.com/fector101/android-notify/issues"
},
"split_keywords": [
"android",
" notifications",
" kivy",
" mobile",
" post-notifications",
" pyjnius",
" android-notifications",
" kivy-notifications",
" python-android",
" mobile-development",
" push-notifications",
" mobile-app",
" kivy-application"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "19353ff49bd2d78c2f4da14cb3f5d268c38baf58c0f89759800dd631f7be650b",
"md5": "7491c4b7c6b95c0fe06098cfca234a46",
"sha256": "fc23c7c56053011261a13f1d465b9e6fb817c5e9df0f8d817630d9b73cfa3ca3"
},
"downloads": -1,
"filename": "android_notify-1.40-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7491c4b7c6b95c0fe06098cfca234a46",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.6",
"size": 13163,
"upload_time": "2025-01-08T22:33:17",
"upload_time_iso_8601": "2025-01-08T22:33:17.749203Z",
"url": "https://files.pythonhosted.org/packages/19/35/3ff49bd2d78c2f4da14cb3f5d268c38baf58c0f89759800dd631f7be650b/android_notify-1.40-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "cae5f601665b6b9032c86742a2d8dd738c4b9b3bd82b1756bdbf85adccb1f82d",
"md5": "e7a9749bc1dd8b9b91bc66456803f3c6",
"sha256": "f93f4496d53dd80996cf0cb3c30ad8664b207be733dfb6ae5afaa761dc9b10db"
},
"downloads": -1,
"filename": "android_notify-1.40.tar.gz",
"has_sig": false,
"md5_digest": "e7a9749bc1dd8b9b91bc66456803f3c6",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.6",
"size": 14869,
"upload_time": "2025-01-08T22:33:22",
"upload_time_iso_8601": "2025-01-08T22:33:22.675874Z",
"url": "https://files.pythonhosted.org/packages/ca/e5/f601665b6b9032c86742a2d8dd738c4b9b3bd82b1756bdbf85adccb1f82d/android_notify-1.40.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-01-08 22:33:22",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "fector101",
"github_project": "android-notify",
"github_not_found": true,
"lcname": "android-notify"
}