Skip to content

APNSConfig live_activity_token field #875

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

plarson
Copy link

@plarson plarson commented May 1, 2025

Issue: #857

Docs: https://firebase.google.com/docs/cloud-messaging/ios/live-activity

With this field and this configuration I am able to send LiveActivity start messages:

messaging.Message(
        apns=messaging.APNSConfig(
            live_activity_token=live_activity_token,
            payload=messaging.APNSPayload(
                aps=messaging.Aps(
                    alert=messaging.ApsAlert(
                        title="Live Activity Started",
                        body="Your live activity has been started",
                    ),
                    custom_data = {
                        "input-push-token": 1,
                        "event": "start",
                        "timestamp": int(time.time()),
                        "content-state": {
                            "myAttribute": False
                        },
                        "attributes-type": "LiveActivityAttributes",
                        "attributes": {
                            "myAttribute": False
                        },
                    }
                ),
                headers={
                    "apns-priority": "5",
                },
            ),
        ),
        token=cloud_messaging_token,
    )

plarson added 2 commits May 1, 2025 14:00
https://firebase.google.com/docs/cloud-messaging/ios/live-activity

With this field and this configuration I am able to send LiveActivity start messages:

```
messaging.Message(
        apns=messaging.APNSConfig(
            live_activity_token=live_activity_token,
            payload=messaging.APNSPayload(
                aps=messaging.Aps(
                    alert=messaging.ApsAlert(
                        title="Live Activity Started",
                        body="Your live activity has been started",
                    ),
                    custom_data = {
                        "input-push-token": 1,
                        "event": "start",
                        "timestamp": int(time.time()),
                        "content-state": {
                            "myAttribute": False
                        },
                        "attributes-type": "LiveActivityAttributes",
                        "attributes": {
                            "myAttribute": False
                        },
                    }
                ),
                headers={
                    "apns-priority": "5",
                },
            ),
        ),
        token=cloud_messaging_token,
    )
```
@emily-ginsburg
Copy link

Thank you for this!!!

I was able to run a successful "update" event using this code (where token is my device's FCM token, and live_activity_token is the existing live activity's token from pushTokenUpdates), but I was not able to trigger a "start" event. Do you know if there any different/additional params needed from your example?

@plarson
Copy link
Author

plarson commented May 2, 2025

Thank you for this!!!

I was able to run a successful "update" event using this code (where token is my device's FCM token, and live_activity_token is the existing live activity's token from pushTokenUpdates), but I was not able to trigger a "start" event. Do you know if there any different/additional params needed from your example?

The pushToStart token is different than the pushToken. Check out Activity.pushToStartTokenUpdates

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants