kalyke
A library for interacting with APNs and VoIP using HTTP/2.
Installation
kalyke requires python 3.9 or later.
$ pip install kalyke-apns
Usage
APNs
import asyncio
from kalyke import ApnsClient, ApnsConfig, Payload, PayloadAlert
client = ApnsClient(
use_sandbox=True,
team_id="YOUR_TEAM_ID",
auth_key_id="AUTH_KEY_ID",
auth_key_filepath="/path/to/AuthKey_AUTH_KEY_ID.p8",
)
registration_id = "a8a799ba6c21e0795b07b577b562b8537418570c0fb8f7a64dca5a86a5a3b500"
payload_alert = PayloadAlert(title="YOUR TITLE", body="YOUR BODY")
payload = Payload(alert=payload_alert, badge=1, sound="default")
config = ApnsConfig(topic="com.example.App")
asyncio.run(
client.send_message(
device_token=registration_id,
payload=payload,
apns_config=config,
)
)
LiveActivity
import asyncio
from datetime import datetime
from kalyke import LiveActivityClient, LiveActivityApnsConfig, LiveActivityEvent, LiveActivityPayload, PayloadAlert
client = LiveActivityClient(
use_sandbox=True,
team_id="YOUR_TEAM_ID",
auth_key_id="AUTH_KEY_ID",
auth_key_filepath="/path/to/AuthKey_AUTH_KEY_ID.p8",
)
registration_id = "a8a799ba6c21e0795b07b577b562b8537418570c0fb8f7a64dca5a86a5a3b500"
payload_alert = PayloadAlert(title="YOUR TITLE", body="YOUR BODY")
payload = LiveActivityPayload(
alert=payload_alert,
badge=1,
sound="default",
timestamp=datetime.now(),
event=LiveActivityEvent.UPDATE,
content_state={
"currentHealthLevel": 100,
"eventDescription": "Adventure has begun!",
},
)
config = LiveActivityApnsConfig(
topic="com.example.App.push-type.liveactivity",
)
asyncio.run(
client.send_message(
device_token=registration_id,
payload=payload,
apns_config=config,
)
)
VoIP
import asyncio
from pathlib import Path
from kalyke import VoIPApnsConfig, VoIPClient
client = VoIPClient(
use_sandbox=True,
auth_key_filepath=Path("/") / "path" / "to" / "YOUR_VOIP_CERTIFICATE.pem",
)
registration_id = "a8a799ba6c21e0795b07b577b562b8537418570c0fb8f7a64dca5a86a5a3b500"
payload = {"key": "value"}
config = VoIPApnsConfig(
topic="com.example.App.voip",
)
asyncio.run(
client.send_message(
device_token=registration_id,
payload=payload,
apns_config=config,
)
)
License
This software is licensed under the MIT License (See LICENSE).
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
kalyke_apns-1.0.2.tar.gz
(9.8 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file kalyke_apns-1.0.2.tar.gz.
File metadata
- Download URL: kalyke_apns-1.0.2.tar.gz
- Upload date:
- Size: 9.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ba6427a4812cb54d11c150dbf42ac8668159c540ebf1f47dfc39ccaee4c15d9e
|
|
| MD5 |
91acb37d2b28651acee1e8b0a28aa3a8
|
|
| BLAKE2b-256 |
776ddf105008647e272bc1dc0037663d33d0cb768bc8d3672c0c406f0018696a
|
File details
Details for the file kalyke_apns-1.0.2-py3-none-any.whl.
File metadata
- Download URL: kalyke_apns-1.0.2-py3-none-any.whl
- Upload date:
- Size: 13.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.7.1 CPython/3.12.1 Linux/6.2.0-1018-azure
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43f32d27b709a421bc40b28593a5573289842367bd37c2b22596be3b9c0273fb
|
|
| MD5 |
a881bf8fa9e873b33b7912486a83d283
|
|
| BLAKE2b-256 |
7d5e9bd8a5de94afe30df1d31ad306df86bc7eecfb3fbf7a8503958de2f712a0
|