aipkgs-notifications


Nameaipkgs-notifications JSON
Version 1.0.2 PyPI version JSON
download
home_pagehttps://github.com/AlexyIbrahim/Notifications
SummaryA simple package to send notifications to your devices using Firebase Cloud Messaging.
upload_time2024-05-26 16:10:27
maintainerNone
docs_urlNone
authorAlexy
requires_python<4.0.0,>=3.11.4
licenseMIT
keywords ai
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # APNS Push Notification

This Python script allows you to send push notifications to Apple devices manually. It uses the Apple Push Notification service (APNS) to deliver notifications to your application users.

## Why use initialize_apns?

The `initialize_apns` function is used to set up the APNS with your application's specific details. This includes your key ID, team ID, bundle ID, and the path to your p8 or pem file. You can also specify whether you want to use the production or sandbox environment (default is sandbox).

## How to use the script?

First, import the necessary modules:

```python
import apns
```

Then, initialize the APNS with your application's details:

```python
KEY_ID = ''
TEAM_ID = ''
BUNDLE_ID = 'com.test.app'
IS_PROD = False
P8_KEY_PATH = 'path/to/p8/key'
PEM_FILE_PATH = 'path/to/pem/file'
APNS_PRIORITY = 10
APNS_EXPIRATION = 0

apns.initialize_apns(key_id=KEY_ID,
                     team_id=TEAM_ID,
                     bundle_id=BUNDLE_ID,
                     is_prod=IS_PROD,
                     p8_key_path=P8_KEY_PATH,
                     pem_file_path=PEM_FILE_PATH,
                     apns_priority=APNS_PRIORITY,
                     apns_expiration=APNS_EXPIRATION)

apns.apns_config().verbose = True
```

Now, you can send a push notification:

```python
device_token = ""  
data = {}  
title = "Hello World!"

response: APNSResponse = apns.push(device_token=device_token, title=title, data=data, badge=1, push_type=apns.PushType.alert, collapse_id=None)
```

## Using p8 or pem file

Depending on your preference or requirements, you can use either a p8 or pem file for authentication. If you want to use a p8 file, pass the path to the `p8_key_path` parameter in the `initialize_apns` function. If you want to use a pem file, pass the path to the `pem_file_path` parameter.

## Getting a p8 file or pem file
To get the p8 or pem file for APNS push notification, you can follow these steps:

1. For p8 file:
   - Go to the Apple Developer Portal.
   - Navigate to the "Certificates, Identifiers & Profiles" section.
   - Under the "Keys" section, click on the "+" button to create a new key. (make sure to select **Apple Push Notifications service (APNs)** from the checkbox)
   - Make sure to write down the **Key ID** as you will need it later.
   - Download the generated p8 file and save it to a secure location.

2. For pem file:
   - Convert the exported .p12 file to a .pem file using the following command in the terminal:
     ```
     openssl pkcs12 -clcerts -legacy -nodes -in Certificates.p12 -out AuthKey.pem
     ```
     Replace "Certificates.p12" with the path to your .p12 file or keep it if you're in the same directory as your .p12 file.
   - Enter the password for the .p12 file when prompted (hit Enter if blank).
   - The converted pem file will be saved as "AuthKey.pem" in the current directory.

Once you have obtained the p8 or pem file, you can use it in the `initialize_apns` function by providing the path to the file in the `p8_key_path` or `pem_file_path` parameter, respectively.
            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/AlexyIbrahim/Notifications",
    "name": "aipkgs-notifications",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0.0,>=3.11.4",
    "maintainer_email": null,
    "keywords": "ai",
    "author": "Alexy",
    "author_email": "alexy.ib@outlook.com",
    "download_url": "https://files.pythonhosted.org/packages/56/49/fc7f66ef4a5755e2850dd366a7042e5e94f5322a7ed39e300d050db72f22/aipkgs_notifications-1.0.2.tar.gz",
    "platform": null,
    "description": "# APNS Push Notification\n\nThis Python script allows you to send push notifications to Apple devices manually. It uses the Apple Push Notification service (APNS) to deliver notifications to your application users.\n\n## Why use initialize_apns?\n\nThe `initialize_apns` function is used to set up the APNS with your application's specific details. This includes your key ID, team ID, bundle ID, and the path to your p8 or pem file. You can also specify whether you want to use the production or sandbox environment (default is sandbox).\n\n## How to use the script?\n\nFirst, import the necessary modules:\n\n```python\nimport apns\n```\n\nThen, initialize the APNS with your application's details:\n\n```python\nKEY_ID = ''\nTEAM_ID = ''\nBUNDLE_ID = 'com.test.app'\nIS_PROD = False\nP8_KEY_PATH = 'path/to/p8/key'\nPEM_FILE_PATH = 'path/to/pem/file'\nAPNS_PRIORITY = 10\nAPNS_EXPIRATION = 0\n\napns.initialize_apns(key_id=KEY_ID,\n                     team_id=TEAM_ID,\n                     bundle_id=BUNDLE_ID,\n                     is_prod=IS_PROD,\n                     p8_key_path=P8_KEY_PATH,\n                     pem_file_path=PEM_FILE_PATH,\n                     apns_priority=APNS_PRIORITY,\n                     apns_expiration=APNS_EXPIRATION)\n\napns.apns_config().verbose = True\n```\n\nNow, you can send a push notification:\n\n```python\ndevice_token = \"\"  \ndata = {}  \ntitle = \"Hello World!\"\n\nresponse: APNSResponse = apns.push(device_token=device_token, title=title, data=data, badge=1, push_type=apns.PushType.alert, collapse_id=None)\n```\n\n## Using p8 or pem file\n\nDepending on your preference or requirements, you can use either a p8 or pem file for authentication. If you want to use a p8 file, pass the path to the `p8_key_path` parameter in the `initialize_apns` function. If you want to use a pem file, pass the path to the `pem_file_path` parameter.\n\n## Getting a p8 file or pem file\nTo get the p8 or pem file for APNS push notification, you can follow these steps:\n\n1. For p8 file:\n   - Go to the Apple Developer Portal.\n   - Navigate to the \"Certificates, Identifiers & Profiles\" section.\n   - Under the \"Keys\" section, click on the \"+\" button to create a new key. (make sure to select **Apple Push Notifications service (APNs)** from the checkbox)\n   - Make sure to write down the **Key ID** as you will need it later.\n   - Download the generated p8 file and save it to a secure location.\n\n2. For pem file:\n   - Convert the exported .p12 file to a .pem file using the following command in the terminal:\n     ```\n     openssl pkcs12 -clcerts -legacy -nodes -in Certificates.p12 -out AuthKey.pem\n     ```\n     Replace \"Certificates.p12\" with the path to your .p12 file or keep it if you're in the same directory as your .p12 file.\n   - Enter the password for the .p12 file when prompted (hit Enter if blank).\n   - The converted pem file will be saved as \"AuthKey.pem\" in the current directory.\n\nOnce you have obtained the p8 or pem file, you can use it in the `initialize_apns` function by providing the path to the file in the `p8_key_path` or `pem_file_path` parameter, respectively.",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "A simple package to send notifications to your devices using Firebase Cloud Messaging.",
    "version": "1.0.2",
    "project_urls": {
        "Homepage": "https://github.com/AlexyIbrahim/Notifications",
        "Repository": "https://github.com/AlexyIbrahim/Notifications"
    },
    "split_keywords": [
        "ai"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b851804bf6af6c8e517884e72e817a242fa987d5f5a19e45c81aa7e57fd84460",
                "md5": "734bc1123ff742159c63ed29f0aefcb4",
                "sha256": "548c7760198f3fa5e62c57fde09cd27c09a6d23edd5089439ac37be797d25bec"
            },
            "downloads": -1,
            "filename": "aipkgs_notifications-1.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "734bc1123ff742159c63ed29f0aefcb4",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0.0,>=3.11.4",
            "size": 9649,
            "upload_time": "2024-05-26T16:10:25",
            "upload_time_iso_8601": "2024-05-26T16:10:25.922564Z",
            "url": "https://files.pythonhosted.org/packages/b8/51/804bf6af6c8e517884e72e817a242fa987d5f5a19e45c81aa7e57fd84460/aipkgs_notifications-1.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5649fc7f66ef4a5755e2850dd366a7042e5e94f5322a7ed39e300d050db72f22",
                "md5": "31e59e8c360d1bd75114a2ddf1df4778",
                "sha256": "22790d339333de3abd1f0cd817dc2e17238c5f1c919c9480e4b35659dcfa3940"
            },
            "downloads": -1,
            "filename": "aipkgs_notifications-1.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "31e59e8c360d1bd75114a2ddf1df4778",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0.0,>=3.11.4",
            "size": 8821,
            "upload_time": "2024-05-26T16:10:27",
            "upload_time_iso_8601": "2024-05-26T16:10:27.583573Z",
            "url": "https://files.pythonhosted.org/packages/56/49/fc7f66ef4a5755e2850dd366a7042e5e94f5322a7ed39e300d050db72f22/aipkgs_notifications-1.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-26 16:10:27",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "AlexyIbrahim",
    "github_project": "Notifications",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "aipkgs-notifications"
}
        
Elapsed time: 0.22289s