Skip to content

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

@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?

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

That worked! As a heads up to anyone testing, I also needed to add apns-push-type and apns-topic to my headers. Very excited for this change!

@lahirumaramba lahirumaramba self-requested a review May 8, 2025 18:16
@lahirumaramba lahirumaramba self-assigned this May 8, 2025
@lahirumaramba
Copy link
Member

Hi @plarson, Thank you for your contribution! We appreciate it!
Could you fix the lint errors and add a unit test to cover the new property, please? Thanks!

@jonathanedey
Copy link
Contributor

Completed in #880

@dr-contributor
Copy link

I know this is already closed and handled on a different PR, but wanted to ask if you guys have been able to successfully close a live activity, i.e. send an end event. I get a success response from the server, but the live activity on the mobile device is not closed. I can successfully start and update the live activity.

@lahirumaramba
Copy link
Member

@dr-contributor Could you please open a new issue for this? Please include as many details as you can (or even a minimal repro) so we can get the right team to look at this. Thanks!

@firebase firebase locked as resolved and limited conversation to collaborators Aug 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants