Skip to main content

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

Project description

kalyke

Test Maintainability Code style: black 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.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

[!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.0.4.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

kalyke_apns-1.0.4-py3-none-any.whl (13.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: kalyke_apns-1.0.4.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1025-azure

File hashes

Hashes for kalyke_apns-1.0.4.tar.gz
Algorithm Hash digest
SHA256 870184f31e9589d35e629bc364af2b0512caf0ae04be2f829eaaba1939e19313
MD5 d2c54de9c6109855bbe573e31de4e0f6
BLAKE2b-256 813185f9cd5244aba271e8aa71dea96851bda3147204b6a7b618884c981a1106

See more details on using hashes here.

Provenance

File details

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

File metadata

  • Download URL: kalyke_apns-1.0.4-py3-none-any.whl
  • Upload date:
  • Size: 13.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.3 CPython/3.12.4 Linux/6.5.0-1025-azure

File hashes

Hashes for kalyke_apns-1.0.4-py3-none-any.whl
Algorithm Hash digest
SHA256 b3d8bbf8a49a60c8457e44727fc73a6482ceb02cfdd7981ef95b53a8e0bef6e6
MD5 13bbf32f3eb309ac59fd60e2fe255e94
BLAKE2b-256 accace74d707b1e2ed90ed770ec4411842931e4ca53cb5116fbc06867d7e6371

See more details on using hashes here.

Provenance

Supported by

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