Skip to main content

A library for interacting with APNs and VoIP using HTTP/2.

Project description

kalyke

Test Maintainability uv Ruff codecov

PyPI Package version Python Supported versions wheel format implementation LICENSE

A library for interacting with APNs and VoIP using HTTP/2.

Installation

kalyke requires python 3.10 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

[!NOTE]

  • The topic suffix must be .push-type.liveactivity.
  • LiveActivityPayload.event default value is LiveActivityEvent.UPDATE.
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

[!NOTE]

  • The topic suffix must be .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).

Project details


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.2.0.tar.gz (10.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kalyke_apns-1.2.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file kalyke_apns-1.2.0.tar.gz.

File metadata

  • Download URL: kalyke_apns-1.2.0.tar.gz
  • Upload date:
  • Size: 10.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kalyke_apns-1.2.0.tar.gz
Algorithm Hash digest
SHA256 6597bd6b8d219831b6c775c1656cbbf2e688ac153a428ce89b1a3c06ab192317
MD5 bbaf841596fbaa9681ab3a0898647b8b
BLAKE2b-256 8669bddcf33af9623b47fa54c07a9576d8edfc5cbbd45795afc32ccc60c4780d

See more details on using hashes here.

Provenance

The following attestation bundles were made for kalyke_apns-1.2.0.tar.gz:

Publisher: release.yml on nnsnodnb/kalyke

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kalyke_apns-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: kalyke_apns-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kalyke_apns-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 28afce03ab688c73e6aab3f52c560b4643498e2dae1dd387765a3f5d60ef321d
MD5 d1302f8cee15e732fabe6e03d3d3e804
BLAKE2b-256 c23c3c76ef2f4c522bed60c292177bf1c5c2b7daff74865003fe9128beabce17

See more details on using hashes here.

Provenance

The following attestation bundles were made for kalyke_apns-1.2.0-py3-none-any.whl:

Publisher: release.yml on nnsnodnb/kalyke

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page