Send a push notification (Python)

Send a push notification via the Thinwrap Push facade in Python — one call shape for FCM, APNs, Expo and every other push provider.

1. Install

pip install thinwrap-notifications

2. Send the call

import os
from thinwrap.notifications import Push, PushSendInput, FcmConfig, ConnectorError

p = Push(FcmConfig(
    project_id=os.environ["FCM_PROJECT_ID"],
    client_email=os.environ["FCM_CLIENT_EMAIL"],
    private_key=os.environ["FCM_PRIVATE_KEY"],
))

try:
    res = p.send(PushSendInput(
        to=device_token,
        title="Hello",
        body="Hello from Thinwrap",
        data={"deepLink": "/orders/42"},
    ))
    print(res.status.value, res.provider_message_id)
except ConnectorError as err:
    print(f"{err.provider_code.value}: {err.provider_message}")

Same code works for all supported providers — just change the provider ID.