-
Notifications
You must be signed in to change notification settings - Fork 58
Add Live Activities Support for iOS Push Notifications #153
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
Add Live Activities Support for iOS Push Notifications #153
Conversation
dwightwatson
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this.
Happy to add support for live activities - trying to find the best path forward and appreciate your help understanding the implementation.
Wondering if there is a case to have a separate "message" object for sending a live activity? If we go that path perhaps I need to break out additional message classes like Message, VoipMessage and BackgroundMessage.
src/ApnAdapter.php
Outdated
| $alert = null; | ||
|
|
||
| if ($message->pushType !== ApnMessage::PUSH_TYPE_BACKGROUND) { | ||
| if ($message->pushType !== ApnMessage::PUSH_TYPE_BACKGROUND && $message->pushType !== ApnMessage::PUSH_TYPE_LIVE_ACTIVITY) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Forgive me, as I'm a little out of touch with where APNS is at these days. How many options for push type are there? Looks like internally we have null, background and voip supported.
I wonder if these should be moved into an enum like some of the other ones in the package - ApnMessageType.
Is a liveactivity effectively a background type as well?
| /** | ||
| * The attributes for live activities. | ||
| */ | ||
| public array $attributes = []; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My concern with things like this (and perhaps timestamp too) is it it's not clear that these are specific to live activities at all without reading the comment.
Is there instead a possibility that a Live Activity should be represented by a different class than an ApnMessage? Am I right in thinking that when sending a live activity update you aren't sending any of the normal ApnMessage attributes?
4c9dd29
into
laravel-notification-channels:master
|
Thanks for this - I've merged it in and I'm going to massage a little bit. I may leave on the master branch for a bit to explore before tagging into a new release. Let me know if you run into any trouble. |
Add Live Activities Support for iOS Push Notifications
Summary
This PR adds comprehensive support for iOS Live Activities push notifications by introducing new properties and methods to the
ApnMessageclass and updating theApnAdapterto properly handle these fields when creating push notification payloads.Changes
New Properties and Methods in
ApnMessagecontentState(?array $contentState)- Sets the content state for live activitiesevent(?string $event)- Sets the event type for live activitiestimestamp(?int $timestamp)- Sets the timestamp for live activitiesattributesType(?string $attributesType)- Sets the attributes type for live activitiesattribute(string $key, mixed $value)- Adds a single attribute for live activitiessetAttributes(array $attributes)- Sets all attributes for live activitiesdismissalDate(?int $dismissalDate)- Sets the dismissal date for live activitiesUpdates to
ApnAdaptercontentState,event,timestamp,attributesType,attributes, anddismissalDatefromApnMessageto the Pushok payloadTest Coverage
ApnMessageTestApnAdapterTestto verify proper payload adaptationUsage Example