Metadata-Version: 2.4
Name: pyAPNsKit
Version: 0.2.1
Summary: Send requests to Apple Push Notification service (APNs) to push notifications to users.
Author: Zonglin Phineas Guo
License: Apache
Project-URL: Source, https://github.com/guoPhineas/pyAPNsKit/
Project-URL: Tracker, https://github.com/guoPhineas/pyAPNsKit/issues/
Classifier: Topic :: Software Development
Classifier: Environment :: Web Environment
Classifier: Programming Language :: Python :: 3
Requires-Python: >=3.12
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: aiohappyeyeballs==2.6.1
Requires-Dist: aiohttp==3.13.3
Requires-Dist: aiosignal==1.4.0
Requires-Dist: anyio==4.12.0
Requires-Dist: certifi==2025.11.12
Requires-Dist: cffi==2.0.0
Requires-Dist: cryptography==46.0.3
Requires-Dist: h11==0.16.0
Requires-Dist: h2==4.3.0
Requires-Dist: hpack==4.1.0
Requires-Dist: httpcore==1.0.9
Requires-Dist: httpx==0.28.1
Requires-Dist: hyperframe==6.1.0
Requires-Dist: idna==3.11
Requires-Dist: pycparser==2.23
Requires-Dist: PyJWT==2.10.1
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: license
Dynamic: license-file
Dynamic: project-url
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# pyAPNsKit

> Send requests to Apple Push Notification service (APNs) to push notifications to users via HTTP/2, token-based



```Shell
pip install pyAPNsKit
```



## Get Started

Quickly push notifications to devices (async, batch supported)

```Python
import asyncio
from pyAPNsKit import apns

p8key = ""
with open('AuthKey_KeyID.p8', 'r') as p8file:
    p8key = p8file.read()

client = apns.Client("teamID", "topic", "KeyID", p8key, isSandbox=False)

async def main():
    responses = await client.sendAlert(
        ["deviceToken1", "deviceToken2"],  # support batch
        "title",
        "subtitle",
        "message",
        sound=True,
        apns_collapse_id="Collapse"
    )
    for resp in responses:
        print(resp.isSuccess, resp.status_code, resp.reason, resp.apns_id)

asyncio.run(main())
```

> [!NOTE]
>
> For parameters, their acquisition methods, and instructions, please refer to the [Apple Developer Document](https://developer.apple.com/documentation/usernotifications/setting-up-a-remote-notification-server)



## Customized

```Python

import asyncio
from pyAPNsKit import apns, APNsHeader, APNsBody, types

p8key = ""
with open('AuthKey_KeyID.p8', 'r') as p8file:
    p8key = p8file.read()

header = APNsHeader.APNsHeader(
    teamID="teamID",
    topic="topic",
    keyID="KeyID",
    p8Key=p8key,
    pushType=types.PushType.alert,
    apns_collapse_id="Collapse"
)
body = APNsBody.APNsBody().withAlert(
    title="title",
    subtitle="sub",
    message="message"
).withSound().withBadge(1)

async def main():
    responses = await apns.asyncPushByDeviceTokens(
        ["deviceToken1", "deviceToken2"],
        header,
        body,
        isSandbox=False
    )
    for resp in responses:
        print(resp.isSuccess, resp.status_code, resp.reason, resp.apns_id)

asyncio.run(main())
```

